step8_controller.js 71 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. var stringUtils = require('utils/string_utils');
  20. App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, {
  21. name: 'wizardStep8Controller',
  22. /**
  23. * List of raw data about cluster that should be displayed
  24. * @type {Array}
  25. */
  26. rawContent: [
  27. {
  28. config_name: 'Admin',
  29. display_name: 'Admin Name',
  30. config_value: ''
  31. },
  32. {
  33. config_name: 'cluster',
  34. display_name: 'Cluster Name',
  35. config_value: ''
  36. },
  37. {
  38. config_name: 'hosts',
  39. display_name: 'Total Hosts',
  40. config_value: ''
  41. },
  42. {
  43. config_name: 'Repo',
  44. display_name: 'Local Repository',
  45. config_value: ''
  46. }
  47. ],
  48. /**
  49. * List of data about cluster (based on formatted <code>rawContent</code>)
  50. * @type {Object[]}
  51. */
  52. clusterInfo: [],
  53. /**
  54. * List of services with components assigned to hosts
  55. * @type {Object[]}
  56. */
  57. services: [],
  58. /**
  59. * @type {Object[]}
  60. */
  61. configs: [],
  62. /**
  63. * All configs
  64. * @type {Array}
  65. */
  66. configMapping: function () {
  67. return App.config.get('configMapping').all(true);
  68. }.property('App.config.configMapping'),
  69. /**
  70. *
  71. */
  72. slaveComponentConfig: null,
  73. /**
  74. * Should Submit button be disabled
  75. * @type {bool}
  76. */
  77. isSubmitDisabled: false,
  78. /**
  79. * Should Back button be disabled
  80. * @type {bool}
  81. */
  82. isBackBtnDisabled: false,
  83. /**
  84. * Is error appears while <code>ajaxQueue</code> executes
  85. * @type {bool}
  86. */
  87. hasErrorOccurred: false,
  88. /**
  89. * Are services installed
  90. * Used to hide Deploy Progress Bar
  91. * @type {bool}
  92. */
  93. servicesInstalled: false,
  94. /**
  95. * List of service config tags
  96. * @type {Object[]}
  97. */
  98. serviceConfigTags: [],
  99. /**
  100. * Ajax-requests queue
  101. * @type {App.ajaxQueue}
  102. */
  103. ajaxRequestsQueue: null,
  104. /**
  105. * Is cluster security enabled
  106. * @type {bool}
  107. */
  108. securityEnabled: function () {
  109. return App.router.get('mainAdminSecurityController.securityEnabled');
  110. }.property('App.router.mainAdminSecurityController.securityEnabled'),
  111. /**
  112. * Selected config group
  113. * @type {Object}
  114. */
  115. selectedConfigGroup: null,
  116. /**
  117. * List of config groups
  118. * @type {Object[]}
  119. */
  120. configGroups: [],
  121. /**
  122. * List of selected but not installed services
  123. * @type {Object[]}
  124. */
  125. selectedServices: function () {
  126. return this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false);
  127. }.property('content.services.@each.isSelected','content.services.@each.isInstalled').cacheable(),
  128. /**
  129. * List of installed services
  130. * @type {Object[]}
  131. */
  132. installedServices: function () {
  133. return this.get('content.services').filterProperty('isInstalled');
  134. }.property('content.services').cacheable(),
  135. /**
  136. * Ajax-requests count
  137. * @type {number}
  138. */
  139. ajaxQueueLength: 0,
  140. /**
  141. * Current cluster name
  142. * @type {string}
  143. */
  144. clusterName: function () {
  145. return this.get('content.cluster.name');
  146. }.property('content.cluster.name'),
  147. /**
  148. * List of existing cluster names
  149. * @type {string[]}
  150. */
  151. clusterNames: [],
  152. /**
  153. * Clear current step data
  154. * @method clearStep
  155. */
  156. clearStep: function () {
  157. this.get('services').clear();
  158. this.get('configs').clear();
  159. this.get('clusterInfo').clear();
  160. this.get('serviceConfigTags').clear();
  161. this.set('servicesInstalled', false);
  162. this.set('ajaxQueueLength', 0);
  163. this.set('ajaxRequestsQueue', App.ajaxQueue.create());
  164. this.set('ajaxRequestsQueue.finishedCallback', this.ajaxQueueFinished);
  165. },
  166. /**
  167. * Load current step data
  168. * @method loadStep
  169. */
  170. loadStep: function () {
  171. console.log("TRACE: Loading step8: Review Page");
  172. this.clearStep();
  173. if (this.get('content.serviceConfigProperties')) {
  174. this.formatProperties();
  175. this.loadConfigs();
  176. if (this.get('content.controllerName') != 'installerController' && this.get('securityEnabled')) {
  177. this.prepareSecureConfigs();
  178. this.get('content.services').filterProperty('isSelected', true)
  179. .mapProperty('serviceName').forEach(function (serviceName) {
  180. var config = this.get('secureConfigs').findProperty('serviceName', serviceName);
  181. if (config) {
  182. this.setPrincipalValue(serviceName, config.name);
  183. }
  184. }, this);
  185. }
  186. }
  187. this.loadClusterInfo();
  188. this.loadServices();
  189. this.set('isSubmitDisabled', false);
  190. this.set('isBackBtnDisabled', false);
  191. },
  192. /**
  193. * replace whitespace character with coma between directories
  194. * @method formatProperties
  195. */
  196. formatProperties: function () {
  197. this.get('content.serviceConfigProperties').forEach(function (_configProperty) {
  198. _configProperty.value = App.config.trimProperty(_configProperty, false);
  199. });
  200. },
  201. /**
  202. * Remove unused Sink configs
  203. * @param {Ember.Enumerable} configs
  204. * @returns {Ember.Enumerable}
  205. * @method removeSinkConfigs
  206. */
  207. removeSinkConfigs: function (configs) {
  208. var sinkDb = configs.findProperty('name', 'sink_database');
  209. var sinkDbType = configs.findProperty('name', 'sink_database_type');
  210. if (sinkDbType) {
  211. var sink_properties = Em.A([]);
  212. switch (sinkDb.value) {
  213. case 'Existing MSSQL Server database with integrated authentication':
  214. configs.findProperty('name', 'sink.dbservername').value = configs.findProperty('name', 'sink_existing_mssql_server_host').value;
  215. sinkDbType.value = 'mssql';
  216. sink_properties = Em.A(['sink_existing_mssql_server_2_database', 'sink_existing_mssql_server_2_host']);
  217. break;
  218. case 'Existing MSSQL Server database with sql auth':
  219. configs.findProperty('name', 'sink.dbservername').value = configs.findProperty('name', 'sink_existing_mssql_server_2_host').value;
  220. sinkDbType.value = 'mssql';
  221. sink_properties = Em.A(['sink_existing_mssql_server_database', 'sink_existing_mssql_server_host']);
  222. break;
  223. }
  224. sink_properties.forEach(function (property) {
  225. configs = configs.without(configs.findProperty('name', property));
  226. });
  227. }
  228. return configs;
  229. },
  230. /**
  231. * Remove unused Hive configs
  232. * @param {Ember.Enumerable} configs
  233. * @returns {Ember.Enumerable}
  234. * @method removeHiveConfigs
  235. */
  236. removeHiveConfigs: function (configs) {
  237. var hiveDb = configs.findProperty('name', 'hive_database');
  238. var hiveDbType = configs.findProperty('name', 'hive_database_type');
  239. if (hiveDbType) {
  240. var hive_properties = Em.A([]);
  241. switch (hiveDb.value) {
  242. case 'New MySQL Database':
  243. if (configs.someProperty('name', 'hive_ambari_host')) {
  244. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_ambari_host').value;
  245. hiveDbType.value = 'mysql';
  246. }
  247. hive_properties = Em.A(['hive_existing_mysql_host', 'hive_existing_mysql_database', 'hive_existing_oracle_host',
  248. 'hive_existing_oracle_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database',
  249. 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_host',
  250. 'hive_existing_mssql_server_2_database', 'hive_existing_mssql_server_2_host']);
  251. break;
  252. case 'New PostgreSQL Database':
  253. if (configs.someProperty('name', 'hive_ambari_host')) {
  254. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_ambari_host').value;
  255. hiveDbType.value = 'postgres';
  256. }
  257. hive_properties = Em.A(['hive_existing_mysql_host', 'hive_existing_mysql_database', 'hive_existing_oracle_host',
  258. 'hive_existing_oracle_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database']);
  259. break;
  260. case 'Existing MySQL Database':
  261. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_mysql_host').value;
  262. hiveDbType.value = 'mysql';
  263. hive_properties = Em.A(['hive_ambari_host', 'hive_ambari_database', 'hive_existing_oracle_host',
  264. 'hive_existing_oracle_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database',
  265. 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_host',
  266. 'hive_existing_mssql_server_2_database', 'hive_existing_mssql_server_2_host']);
  267. break;
  268. case Em.I18n.t('services.service.config.hive.oozie.postgresql'):
  269. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_postgresql_host').value;
  270. hiveDbType.value = 'postgres';
  271. hive_properties = Em.A(['hive_ambari_host', 'hive_ambari_database', 'hive_existing_oracle_host',
  272. 'hive_existing_oracle_database', 'hive_existing_mysql_host', 'hive_existing_mysql_database',
  273. 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_host',
  274. 'hive_existing_mssql_server_2_database', 'hive_existing_mssql_server_2_host']);
  275. break;
  276. case 'Existing MSSQL Server database with integrated authentication':
  277. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_mssql_server_2_host').value;
  278. hiveDbType.value = 'mssql';
  279. hive_properties = Em.A(['hive_ambari_host', 'hive_ambari_database', 'hive_existing_oracle_host',
  280. 'hive_existing_oracle_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database',
  281. 'hive_existing_mysql_host', 'hive_existing_mysql_database', 'hive_existing_mssql_server_database',
  282. 'hive_existing_mssql_server_host', 'hive_existing_mssql_server_2_database', 'hive_existing_mssql_server_2_host']);
  283. break;
  284. case 'Existing MSSQL Server database with sql auth':
  285. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_mssql_server_host').value;
  286. hiveDbType.value = 'mssql';
  287. hive_properties = Em.A(['hive_ambari_host', 'hive_ambari_database', 'hive_existing_oracle_host',
  288. 'hive_existing_oracle_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database',
  289. 'hive_existing_mysql_host', 'hive_existing_mysql_database', 'hive_existing_mssql_server_database',
  290. 'hive_existing_mssql_server_host', 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_host']);
  291. break;
  292. default:
  293. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_oracle_host').value;
  294. hiveDbType.value = 'oracle';
  295. hive_properties = Em.A(['hive_ambari_host', 'hive_ambari_database', 'hive_existing_mysql_host',
  296. 'hive_existing_mysql_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database',
  297. 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_host',
  298. 'hive_existing_mssql_server_2_database', 'hive_existing_mssql_server_2_host']);
  299. break;
  300. }
  301. hive_properties.forEach(function (property) {
  302. configs = configs.without(configs.findProperty('name', property));
  303. });
  304. }
  305. return configs;
  306. },
  307. /**
  308. * Remove unused Oozie configs
  309. * @param {Ember.Enumerable} configs
  310. * @returns {Ember.Enumerable}
  311. * @method removeOozieConfigs
  312. */
  313. removeOozieConfigs: function (configs) {
  314. var oozieDb = configs.findProperty('name', 'oozie_database');
  315. var oozieDbType = configs.findProperty('name', 'oozie_database_type');
  316. if (oozieDbType) {
  317. var oozie_properties = Em.A(['oozie_ambari_host', 'oozie_ambari_database']);
  318. switch (oozieDb.value) {
  319. case 'New Derby Database':
  320. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_ambari_host').value;
  321. oozieDbType.value = 'derby';
  322. oozie_properties = Em.A(['oozie_ambari_host', 'oozie_ambari_database', 'oozie_existing_mysql_host',
  323. 'oozie_existing_mysql_database', 'oozie_existing_oracle_host', 'oozie_existing_oracle_database',
  324. 'oozie_existing_postgresql_host', 'oozie_existing_postgresql_database',
  325. 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_host',
  326. 'oozie_existing_mssql_server_2_database', 'oozie_existing_mssql_server_2_host']);
  327. break;
  328. case 'Existing MySQL Database':
  329. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_existing_mysql_host').value;
  330. oozieDbType.value = 'mysql';
  331. oozie_properties = Em.A(['oozie_ambari_host', 'oozie_ambari_database', 'oozie_existing_oracle_host',
  332. 'oozie_existing_oracle_database', 'oozie_derby_database', 'oozie_existing_postgresql_host', 'oozie_existing_postgresql_database',
  333. 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_host',
  334. 'oozie_existing_mssql_server_2_database', 'oozie_existing_mssql_server_2_host']);
  335. break;
  336. case Em.I18n.t('services.service.config.hive.oozie.postgresql'):
  337. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_existing_postgresql_host').value;
  338. oozieDbType.value = 'postgresql';
  339. oozie_properties = Em.A(['oozie_ambari_host', 'oozie_ambari_database', 'oozie_existing_oracle_host',
  340. 'oozie_existing_oracle_database', 'oozie_existing_mysql_host', 'oozie_existing_mysql_database',
  341. 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_host',
  342. 'oozie_existing_mssql_server_2_database', 'oozie_existing_mssql_server_2_host']);
  343. break;
  344. case 'Existing MSSQL Server database with integrated authentication':
  345. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_existing_mysql_host').value;
  346. oozieDbType.value = 'mssql';
  347. hive_properties = Em.A(['hive_ambari_host', 'hive_ambari_database', 'oozie_existing_oracle_host',
  348. 'oozie_existing_oracle_database', 'oozie_existing_postgresql_host', 'oozie_existing_postgresql_database',
  349. 'oozie_existing_mysql_host', 'oozie_existing_mysql_database',
  350. 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_host',
  351. 'oozie_existing_mssql_server_2_database', 'oozie_existing_mssql_server_2_host']);
  352. break;
  353. case 'Existing MSSQL Server database with sql auth':
  354. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_existing_mysql_host').value;
  355. oozieDbType.value = 'mssql';
  356. hive_properties = Em.A(['hive_ambari_host', 'hive_ambari_database', 'oozie_existing_oracle_host',
  357. 'oozie_existing_oracle_database', 'oozie_existing_postgresql_host', 'oozie_existing_postgresql_database',
  358. 'oozie_existing_mysql_host', 'oozie_existing_mysql_database',
  359. 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_host',
  360. 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_host']);
  361. break;
  362. default:
  363. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_existing_oracle_host').value;
  364. oozieDbType.value = 'oracle';
  365. oozie_properties = Em.A(['oozie_ambari_host', 'oozie_ambari_database', 'oozie_existing_mysql_host',
  366. 'oozie_existing_mysql_database', 'oozie_derby_database', 'oozie_existing_postgresql_host',
  367. 'oozie_existing_postgresql_database', 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_host',
  368. 'oozie_existing_mssql_server_2_database', 'oozie_existing_mssql_server_2_host']);
  369. break;
  370. }
  371. oozie_properties.forEach(function (property) {
  372. configs = configs.without(configs.findProperty('name', property));
  373. });
  374. }
  375. return configs;
  376. },
  377. /**
  378. * Load all site properties
  379. * @method loadConfigs
  380. */
  381. loadConfigs: function () {
  382. //storedConfigs contains custom configs as well
  383. var configs = this.get('content.serviceConfigProperties');
  384. if (configs.someProperty('name', 'hive_database')) {
  385. configs = this.removeHiveConfigs(configs);
  386. }
  387. if (configs.someProperty('name', 'sink_database')) {
  388. configs = this.removeSinkConfigs(configs);
  389. }
  390. if (configs.someProperty('name', 'oozie_database')) {
  391. configs = this.removeOozieConfigs(configs);
  392. }
  393. configs.forEach(function (_config) {
  394. _config.value = (typeof _config.value === "boolean") ? _config.value.toString() : _config.value;
  395. });
  396. var mappedConfigs = App.config.excludeUnsupportedConfigs(this.get('configMapping'), this.get('selectedServices').mapProperty('serviceName'));
  397. var uiConfigs = this.loadUiSideConfigs(mappedConfigs);
  398. var customGroupConfigs = [];
  399. var allConfigs = configs.concat(uiConfigs).filter(function (config) {
  400. if (config.group) {
  401. customGroupConfigs.push(config);
  402. return false;
  403. } else {
  404. return true;
  405. }
  406. });
  407. this.set('customNonDefaultGroupConfigs', customGroupConfigs);
  408. this.set('configs', allConfigs);
  409. },
  410. /**
  411. * Load UI configs
  412. * @param {Array} configMapping
  413. * @return {Array}
  414. * @method loadUiSideConfigs
  415. */
  416. loadUiSideConfigs: function (configMapping) {
  417. var uiConfig = [];
  418. var configs = configMapping.filterProperty('foreignKey', null);
  419. this.addDynamicProperties(configs);
  420. configs.forEach(function (_config) {
  421. var valueWithOverrides = this.getGlobConfigValueWithOverrides(_config.templateName, _config.value, _config.name);
  422. uiConfig.pushObject({
  423. "id": "site property",
  424. "name": _config.name,
  425. "value": valueWithOverrides.value,
  426. "filename": _config.filename,
  427. "overrides": valueWithOverrides.overrides
  428. });
  429. }, this);
  430. var dependentConfig = $.extend(true, [], configMapping.filterProperty('foreignKey'));
  431. dependentConfig.forEach(function (_config) {
  432. App.config.setConfigValue(uiConfig, this.get('content.serviceConfigProperties'), _config);
  433. uiConfig.pushObject({
  434. "id": "site property",
  435. "name": _config._name || _config.name,
  436. "value": _config.value,
  437. "filename": _config.filename
  438. });
  439. }, this);
  440. return uiConfig;
  441. },
  442. /**
  443. * Add dynamic properties to configs
  444. * @param {Array} configs
  445. * @method addDynamicProperties
  446. */
  447. addDynamicProperties: function (configs) {
  448. var templetonHiveProperty = this.get('content.serviceConfigProperties').someProperty('name', 'templeton.hive.properties');
  449. if (!templetonHiveProperty) {
  450. configs.pushObject({
  451. "name": "templeton.hive.properties",
  452. "templateName": ["hivemetastore_host"],
  453. "foreignKey": null,
  454. "value": "hive.metastore.local=false,hive.metastore.uris=thrift://<templateName[0]>:9083,hive.metastore.sasl.enabled=yes,hive.metastore.execute.setugi=true,hive.metastore.warehouse.dir=/apps/hive/warehouse",
  455. "filename": "webhcat-site.xml"
  456. });
  457. }
  458. },
  459. /**
  460. * Format <code>content.hosts</code> from Object to Array
  461. * @returns {Array}
  462. * @method getRegisteredHosts
  463. */
  464. getRegisteredHosts: function () {
  465. var allHosts = this.get('content.hosts');
  466. var hosts = [];
  467. for (var hostName in allHosts) {
  468. if (allHosts.hasOwnProperty(hostName)) {
  469. if (allHosts[hostName].bootStatus == 'REGISTERED') {
  470. allHosts[hostName].hostName = allHosts[hostName].name;
  471. hosts.pushObject(allHosts[hostName]);
  472. }
  473. }
  474. }
  475. return hosts;
  476. },
  477. /**
  478. * Set all site property that are derived from other puppet-variable
  479. * @param {String} templateName
  480. * @param {String} expression
  481. * @param {String} name
  482. * @return {Object}
  483. * example: <code>{
  484. * value: '...',
  485. * overrides: [
  486. * {
  487. * value: 'v1',
  488. * hosts: ['h1', 'h2']
  489. * },
  490. * {
  491. * value: 'v2',
  492. * hosts: ['h2', 'h3']
  493. * },
  494. * ....
  495. * ]
  496. * }</code>
  497. * @method getGlobConfigValueWithOverrides
  498. */
  499. getGlobConfigValueWithOverrides: function (templateName, expression, name) {
  500. var express = expression.match(/<(.*?)>/g);
  501. var value = expression;
  502. if (express == null) {
  503. return { value: expression, overrides: []}; // if site property do not map any global property then return the value
  504. }
  505. var overrideHostToValue = {};
  506. express.forEach(function (_express) {
  507. //console.log("The value of template is: " + _express);
  508. var index = parseInt(_express.match(/\[([\d]*)(?=\])/)[1]);
  509. if (this.get('configs').someProperty('name', templateName[index])) {
  510. //console.log("The name of the variable is: " + this.get('content.serviceConfigProperties').findProperty('name', templateName[index]).name);
  511. var globalObj = this.get('configs').findProperty('name', templateName[index]);
  512. var globValue = globalObj.value;
  513. // Hack for templeton.zookeeper.hosts
  514. var preReplaceValue = null;
  515. if (value !== null) { // if the property depends on more than one template name like <templateName[0]>/<templateName[1]> then don't proceed to the next if the prior is null or not found in the global configs
  516. preReplaceValue = value;
  517. value = this._replaceConfigValues(name, _express, value, globValue);
  518. }
  519. if (globalObj.overrides != null) {
  520. globalObj.overrides.forEach(function (override) {
  521. var ov = override.value;
  522. var hostsArray = override.hosts;
  523. hostsArray.forEach(function (host) {
  524. if (!(host in overrideHostToValue)) {
  525. overrideHostToValue[host] = this._replaceConfigValues(name, _express, preReplaceValue, ov);
  526. } else {
  527. overrideHostToValue[host] = this._replaceConfigValues(name, _express, overrideHostToValue[host], ov);
  528. }
  529. }, this);
  530. }, this);
  531. }
  532. } else {
  533. /*
  534. console.log("ERROR: The variable name is: " + templateName[index]);
  535. console.log("ERROR: mapped config from configMapping file has no corresponding variable in " +
  536. "content.serviceConfigProperties. Two possible reasons for the error could be: 1) The service is not selected. " +
  537. "and/OR 2) The service_config metadata file has no corresponding global var for the site property variable");
  538. */
  539. value = null;
  540. }
  541. }, this);
  542. var valueWithOverrides = {
  543. value: value,
  544. overrides: []
  545. };
  546. var overrideValueToHostMap = {};
  547. if (!jQuery.isEmptyObject(overrideHostToValue)) {
  548. for (var host in overrideHostToValue) {
  549. var hostVal = overrideHostToValue[host];
  550. if (!(hostVal in overrideValueToHostMap)) {
  551. overrideValueToHostMap[hostVal] = [];
  552. }
  553. overrideValueToHostMap[hostVal].push(host);
  554. }
  555. }
  556. for (var val in overrideValueToHostMap) {
  557. valueWithOverrides.overrides.push({
  558. value: val,
  559. hosts: overrideValueToHostMap[val]
  560. });
  561. }
  562. return valueWithOverrides;
  563. },
  564. /**
  565. * replace some values in config property
  566. * @param {string} name
  567. * @param {string} express
  568. * @param {string} value
  569. * @param {string} globValue
  570. * @return {string}
  571. * @private
  572. * @method _replaceConfigValues
  573. */
  574. _replaceConfigValues: function (name, express, value, globValue) {
  575. return value.replace(express, globValue);
  576. },
  577. /**
  578. * Load all info about cluster to <code>clusterInfo</code> variable
  579. * @method loadClusterInfo
  580. */
  581. loadClusterInfo: function () {
  582. //Admin name
  583. var admin = this.rawContent.findProperty('config_name', 'Admin');
  584. admin.config_value = App.db.getLoginName();
  585. console.log("STEP8: the value of content cluster name: " + App.db.getLoginName());
  586. if (admin.config_value) {
  587. this.get('clusterInfo').pushObject(Ember.Object.create(admin));
  588. }
  589. // cluster name
  590. var cluster = this.rawContent.findProperty('config_name', 'cluster');
  591. cluster.config_value = this.get('content.cluster.name');
  592. console.log("STEP8: the value of content cluster name: " + this.get('content.cluster.name'));
  593. this.get('clusterInfo').pushObject(Ember.Object.create(cluster));
  594. //hosts
  595. var newHostsCount = 0;
  596. var totalHostsCount = 0;
  597. var hosts = this.get('content.hosts');
  598. for (var hostName in hosts) {
  599. newHostsCount += ~~(!hosts[hostName].isInstalled);
  600. totalHostsCount++;
  601. }
  602. var totalHostsObj = this.rawContent.findProperty('config_name', 'hosts');
  603. totalHostsObj.config_value = totalHostsCount + ' (' + newHostsCount + ' new)';
  604. this.get('clusterInfo').pushObject(Em.Object.create(totalHostsObj));
  605. //repo
  606. if (['addHostController', 'addServiceController'].contains(this.get('content.controllerName'))) {
  607. this.loadRepoInfo();
  608. } else {
  609. // from install wizard
  610. var selectedStack = App.Stack.find().findProperty('isSelected');
  611. var allRepos = [];
  612. if (selectedStack && selectedStack.get('operatingSystems')) {
  613. selectedStack.get('operatingSystems').forEach(function (os) {
  614. if (os.get('isSelected')) {
  615. os.get('repositories').forEach(function(repo) {
  616. allRepos.push(Em.Object.create({
  617. base_url: repo.get('baseUrl'),
  618. os_type: repo.get('osType'),
  619. repo_id: repo.get('repoId')
  620. }));
  621. }, this);
  622. }
  623. }, this);
  624. }
  625. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  626. this.get('clusterInfo').set('repoInfo', allRepos);
  627. }
  628. },
  629. /**
  630. * Load repo info for add Service/Host wizard review page
  631. * @return {$.ajax|null}
  632. * @method loadRepoInfo
  633. */
  634. loadRepoInfo: function () {
  635. var nameVersionCombo = App.get('currentStackVersion').split('-');
  636. return App.ajax.send({
  637. name: 'cluster.load_repositories',
  638. sender: this,
  639. data: {
  640. stackName: nameVersionCombo[0],
  641. stackVersion: nameVersionCombo[1]
  642. },
  643. success: 'loadRepoInfoSuccessCallback',
  644. error: 'loadRepoInfoErrorCallback'
  645. });
  646. },
  647. /**
  648. * Save all repo base URL of all OS type to <code>repoInfo<code>
  649. * @param {object} data
  650. * @method loadRepoInfoSuccessCallback
  651. */
  652. loadRepoInfoSuccessCallback: function (data) {
  653. var allRepos = [];
  654. data.items.forEach(function (os) {
  655. os.repositories.forEach(function (repository) {
  656. allRepos.push(Em.Object.create({
  657. base_url: repository.Repositories.base_url,
  658. os_type: repository.Repositories.os_type,
  659. repo_id: repository.Repositories.repo_id
  660. }));
  661. });
  662. }, this);
  663. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  664. this.get('clusterInfo').set('repoInfo', allRepos);
  665. },
  666. /**
  667. * @param {object} request
  668. * @method loadRepoInfoErrorCallback
  669. */
  670. loadRepoInfoErrorCallback: function (request) {
  671. console.log('Error message is: ' + request.responseText);
  672. var allRepos = [];
  673. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  674. this.get('clusterInfo').set('repoInfo', allRepos);
  675. },
  676. /**
  677. * Load all info about services to <code>services</code> variable
  678. * @method loadServices
  679. */
  680. loadServices: function () {
  681. this.get('selectedServices').filterProperty('isHiddenOnSelectServicePage', false).forEach(function (service) {
  682. console.log('INFO: step8: Name of the service from getService function: ' + service.get('serviceName'));
  683. var serviceObj = Em.Object.create({
  684. service_name: service.get('serviceName'),
  685. display_name: service.get('displayNameOnSelectServicePage'),
  686. service_components: Em.A([])
  687. });
  688. service.get('serviceComponents').forEach(function (component) {
  689. // show clients for services that have only clients components
  690. if ((component.get('isClient') || component.get('isClientBehavior')) && !service.get('isClientOnlyService')) return;
  691. // skip components that was hide on assign master page
  692. if (component.get('isMaster') && !component.get('isShownOnInstallerAssignMasterPage')) return;
  693. // no HA component
  694. if (component.get('isHAComponentOnly')) return;
  695. var displayName;
  696. if (component.get('isClient')) {
  697. displayName = Em.I18n.t('common.clients')
  698. } else {
  699. // remove service name from component display name
  700. displayName = App.format.role(component.get('componentName')).replace(new RegExp('^' + service.get('serviceName') + '\\s', 'i'), '');
  701. }
  702. serviceObj.get('service_components').pushObject(Em.Object.create({
  703. component_name: component.get('isClient') ? Em.I18n.t('common.client').toUpperCase() : component.get('componentName'),
  704. display_name: displayName,
  705. component_value: this.assignComponentHosts(component)
  706. }));
  707. }, this);
  708. if (service.get('customReviewHandler')) {
  709. for (var displayName in service.get('customReviewHandler')) {
  710. serviceObj.get('service_components').pushObject(Em.Object.create({
  711. display_name: displayName,
  712. component_value: this.assignComponentHosts(Em.Object.create({
  713. customHandler: service.get('customReviewHandler.' + displayName)
  714. }))
  715. }));
  716. }
  717. }
  718. this.get('services').pushObject(serviceObj);
  719. }, this);
  720. },
  721. /**
  722. * Set <code>component_value</code> property to <code>component</code>
  723. * @param {Em.Object} component
  724. * @return {String}
  725. * @method assignComponentHosts
  726. */
  727. assignComponentHosts: function (component) {
  728. var componentValue;
  729. if (component.get('customHandler')) {
  730. componentValue = this[component.get('customHandler')].call(this, component);
  731. }
  732. else {
  733. if (component.get('isMaster')) {
  734. componentValue = this.getMasterComponentValue(component.get('componentName'));
  735. }
  736. else {
  737. console.log(' --- ---INFO: step8: NOT component isMaster');
  738. var componentName = component.get('isClient') ? Em.I18n.t('common.client').toUpperCase() : component.get('componentName');
  739. var hostsLength = this.get('content.slaveComponentHosts')
  740. .findProperty('componentName', componentName).hosts.length;
  741. componentValue = hostsLength + Em.I18n.t('installer.step8.host' + ((hostsLength > 1) ? 's' : ''));
  742. }
  743. }
  744. return componentValue;
  745. },
  746. getMasterComponentValue: function (componentName) {
  747. var masterComponents = this.get('content.masterComponentHosts');
  748. var hostsCount = masterComponents.filterProperty('component', componentName).length;
  749. return stringUtils.pluralize(hostsCount,
  750. masterComponents.findProperty('component', componentName).hostName,
  751. hostsCount + ' ' + Em.I18n.t('installer.step8.hosts'));
  752. },
  753. /**
  754. * Set displayed MetricsSink DB value based on DB type
  755. * @param {Ember.Object} dbComponent
  756. * @method loadSinkDbValue
  757. */
  758. loadSinkDbValue: function () {
  759. var db, serviceConfigProperties = this.get('wizardController').getDBProperty('serviceConfigProperties'),
  760. sinkDb = serviceConfigProperties.findProperty('name', 'sink_database');
  761. if (sinkDb.value === 'Existing MSSQL Server database with integrated authentication') {
  762. db = serviceConfigProperties.findProperty('name', 'sink_existing_mssql_server_database');
  763. return db.value + ' (' + sinkDb.value + ')';
  764. }
  765. else {
  766. if (sinkDb.value === 'Existing MSSQL Server database with sql auth') {
  767. db = serviceConfigProperties.findProperty('name', 'sink_existing_mssql_server_2_database');
  768. return db.value + ' (' + sinkDb.value + ')';
  769. }
  770. }
  771. },
  772. /**
  773. * Set dispalyed Hive DB value based on DB type
  774. * @param {Ember.Object} dbComponent
  775. * @method loadHiveDbValue
  776. */
  777. loadHiveDbValue: function () {
  778. var db, serviceConfigPreoprties = this.get('wizardController').getDBProperty('serviceConfigProperties'),
  779. hiveDb = serviceConfigPreoprties.findProperty('name', 'hive_database');
  780. if (hiveDb.value === 'New MySQL Database') {
  781. return 'MySQL (New Database)';
  782. } else if (hiveDb.value === 'New PostgreSQL Database') {
  783. return 'Postgres (New Database)';
  784. }
  785. else {
  786. if (hiveDb.value === 'Existing MySQL Database') {
  787. db = serviceConfigPreoprties.findProperty('name', 'hive_existing_mysql_database');
  788. return db.value + ' (' + hiveDb.value + ')';
  789. }
  790. else {
  791. if (hiveDb.value === Em.I18n.t('services.service.config.hive.oozie.postgresql')) {
  792. db = serviceConfigPreoprties.findProperty('name', 'hive_existing_postgresql_database');
  793. return db.value + ' (' + hiveDb.value + ')';
  794. }
  795. else {
  796. if (hiveDb.value === 'Existing MSSQL Server database with integrated authentication') {
  797. db = serviceConfigPreoprties.findProperty('name', 'hive_existing_mssql_server_database');
  798. return db.value + ' (' + hiveDb.value + ')';
  799. }
  800. else {
  801. if (hiveDb.value === 'Existing MSSQL Server database with sql auth') {
  802. db = serviceConfigPreoprties.findProperty('name', 'hive_existing_mssql_server_2_database');
  803. return db.value + ' (' + hiveDb.value + ')';
  804. }
  805. else {
  806. // existing oracle database
  807. db = serviceConfigPreoprties.findProperty('name', 'hive_existing_oracle_database');
  808. return db.value + ' (' + hiveDb.value + ')';
  809. }
  810. }
  811. }
  812. }
  813. }
  814. },
  815. /**
  816. * Set displayed HBase master value
  817. * @param {Object} hbaseMaster
  818. * @method loadHbaseMasterValue
  819. */
  820. loadHbaseMasterValue: function (hbaseMaster) {
  821. var hbaseHostName = this.get('content.masterComponentHosts').filterProperty('component', hbaseMaster.component_name);
  822. if (hbaseHostName.length == 1) {
  823. hbaseMaster.set('component_value', hbaseHostName[0].hostName);
  824. } else {
  825. hbaseMaster.set('component_value', hbaseHostName[0].hostName + " " + Em.I18n.t('installer.step8.other').format(hbaseHostName.length - 1));
  826. }
  827. },
  828. /**
  829. * Set displayed ZooKeeper Server value
  830. * @param {Object} serverComponent
  831. * @method loadZkServerValue
  832. */
  833. loadZkServerValue: function (serverComponent) {
  834. var zkHostNames = this.get('content.masterComponentHosts').filterProperty('component', serverComponent.component_name).length;
  835. var hostSuffix;
  836. if (zkHostNames === 1) {
  837. hostSuffix = Em.I18n.t('installer.step8.host');
  838. } else {
  839. hostSuffix = Em.I18n.t('installer.step8.hosts');
  840. }
  841. serverComponent.set('component_value', zkHostNames + hostSuffix);
  842. },
  843. /**
  844. * Set displayed Oozie DB value based on DB type
  845. * @param {Object} dbComponent
  846. * @method loadOozieDbValue
  847. */
  848. loadOozieDbValue: function () {
  849. var db, oozieDb = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_database');
  850. if (oozieDb.value === 'New Derby Database') {
  851. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_derby_database');
  852. return db.value + ' (' + oozieDb.value + ')';
  853. }
  854. else {
  855. if (oozieDb.value === 'Existing MySQL Database') {
  856. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_mysql_database');
  857. return db.value + ' (' + oozieDb.value + ')';
  858. }
  859. else {
  860. if (oozieDb.value === Em.I18n.t('services.service.config.hive.oozie.postgresql')) {
  861. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_postgresql_database');
  862. return db.value + ' (' + oozieDb.value + ')';
  863. }
  864. else {
  865. if (oozieDb.value === 'Existing MSSQL Server database with integrated authentication') {
  866. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_mssql_server_database');
  867. return db.value + ' (' + oozieDb.value + ')';
  868. }
  869. else {
  870. if (oozieDb.value === 'Existing MSSQL Server database with sql auth') {
  871. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_mssql_server_2_database');
  872. return db.value + ' (' + oozieDb.value + ')';
  873. }
  874. else {
  875. // existing oracle database
  876. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_oracle_database');
  877. return db.value + ' (' + oozieDb.value + ')';
  878. }
  879. }
  880. }
  881. }
  882. }
  883. },
  884. /**
  885. * Set displayed Nagion Admin value
  886. * @param {Object} nagiosAdmin
  887. * @method loadNagiosAdminValue
  888. */
  889. loadNagiosAdminValue: function () {
  890. var config = this.get('content.serviceConfigProperties');
  891. var adminLoginName = config.findProperty('name', 'nagios_web_login');
  892. var adminEmail = config.findProperty('name', 'nagios_contact');
  893. return adminLoginName.value + ' / (' + adminEmail.value + ')';
  894. },
  895. /**
  896. * Onclick handler for <code>next</code> button
  897. * @method submit
  898. * @return {App.ModalPopup|null}
  899. */
  900. submit: function () {
  901. if (this.get('isSubmitDisabled')) return null;
  902. if ((this.get('content.controllerName') == 'addHostController') && this.get('securityEnabled')) {
  903. var self = this;
  904. return App.showConfirmationPopup(function () {
  905. self.submitProceed();
  906. }, Em.I18n.t('installer.step8.securityConfirmationPopupBody'));
  907. }
  908. else {
  909. return this.submitProceed();
  910. }
  911. },
  912. /**
  913. * Update configurations for installed services.
  914. * Do separated PUT-request for each siteName for each service
  915. *
  916. * @param {Array} fileNamesToUpdate - file names that should be updated
  917. * @method updateConfigurations
  918. */
  919. updateConfigurations: function (fileNamesToUpdate) {
  920. var configurationController = App.router.get('mainServiceInfoConfigsController');
  921. var configs = this.get('configs').slice(0);
  922. var configsMap = [];
  923. fileNamesToUpdate.forEach(function (fileName) {
  924. if (!fileName || /^(core)/.test(fileName)) return;
  925. var tagName = 'version' + (new Date).getTime();
  926. var configsToSave = configs.filterProperty('filename', fileName);
  927. configsToSave.forEach(function (item) {
  928. item.value = App.config.trimProperty(item, false);
  929. });
  930. configsMap.push(configurationController.createSiteObj(fileName.replace(".xml", ""), tagName, configsToSave));
  931. }, this);
  932. if (!configsMap.length) return;
  933. this.applyConfigurationsToCluster(configsMap);
  934. },
  935. /**
  936. * Prepare <code>ajaxQueue</code> and start to execute it
  937. * @method submitProceed
  938. */
  939. submitProceed: function () {
  940. var self = this;
  941. this.set('isSubmitDisabled', true);
  942. this.set('isBackBtnDisabled', true);
  943. if (this.get('content.controllerName') == 'addHostController') {
  944. App.router.get('addHostController').setLowerStepsDisable(4);
  945. }
  946. // checkpoint the cluster status on the server so that the user can resume from where they left off
  947. switch (this.get('content.controllerName')) {
  948. case 'installerController':
  949. App.clusterStatus.setClusterStatus({
  950. clusterName: this.get('clusterName'),
  951. clusterState: 'CLUSTER_DEPLOY_PREP_2',
  952. wizardControllerName: this.get('content.controllerName'),
  953. localdb: App.db.data
  954. });
  955. break;
  956. case 'addHostController':
  957. App.clusterStatus.setClusterStatus({
  958. clusterName: this.get('clusterName'),
  959. clusterState: 'ADD_HOSTS_DEPLOY_PREP_2',
  960. wizardControllerName: this.get('content.controllerName'),
  961. localdb: App.db.data
  962. });
  963. break;
  964. case 'addServiceController':
  965. App.clusterStatus.setClusterStatus({
  966. clusterName: this.get('clusterName'),
  967. clusterState: 'ADD_SERVICES_DEPLOY_PREP_2',
  968. wizardControllerName: this.get('content.controllerName'),
  969. localdb: App.db.data
  970. });
  971. break;
  972. default:
  973. break;
  974. }
  975. // delete any existing clusters to start from a clean slate
  976. // before creating a new cluster in install wizard
  977. // TODO: modify for multi-cluster support
  978. this.getExistingClusterNames().complete(function () {
  979. var clusterNames = self.get('clusterNames');
  980. if (self.get('content.controllerName') == 'installerController' && (!App.get('testMode')) && clusterNames.length) {
  981. self.deleteClusters(clusterNames);
  982. } else {
  983. self.deleteClustersCallback(null, null, {isLast: true});
  984. }
  985. });
  986. },
  987. /**
  988. * Get list of existing cluster names
  989. * @returns {object|null}
  990. * returns an array of existing cluster names.
  991. * returns an empty array if there are no existing clusters.
  992. * @method getExistingClusterNames
  993. */
  994. getExistingClusterNames: function () {
  995. return App.ajax.send({
  996. name: 'wizard.step8.existing_cluster_names',
  997. sender: this,
  998. success: 'getExistingClusterNamesSuccessCallBack',
  999. error: 'getExistingClusterNamesErrorCallback'
  1000. });
  1001. },
  1002. /**
  1003. * Save received list to <code>clusterNames</code>
  1004. * @param {Object} data
  1005. * @method getExistingClusterNamesSuccessCallBack
  1006. */
  1007. getExistingClusterNamesSuccessCallBack: function (data) {
  1008. var clusterNames = data.items.mapProperty('Clusters.cluster_name');
  1009. console.log("Got existing cluster names: " + clusterNames);
  1010. this.set('clusterNames', clusterNames);
  1011. },
  1012. /**
  1013. * If error appears, set <code>clusterNames</code> to <code>[]</code>
  1014. * @method getExistingClusterNamesErrorCallback
  1015. */
  1016. getExistingClusterNamesErrorCallback: function () {
  1017. console.log("Failed to get existing cluster names");
  1018. this.set('clusterNames', []);
  1019. },
  1020. /**
  1021. * Delete cluster by name
  1022. * One request for one cluster!
  1023. * @param {string[]} clusterNames
  1024. * @method deleteClusters
  1025. */
  1026. deleteClusters: function (clusterNames) {
  1027. clusterNames.forEach(function (clusterName, index) {
  1028. App.ajax.send({
  1029. name: 'common.delete.cluster',
  1030. sender: this,
  1031. data: {
  1032. name: clusterName,
  1033. isLast: index == clusterNames.length - 1
  1034. },
  1035. success: 'deleteClustersCallback',
  1036. error: 'deleteClustersCallback'
  1037. });
  1038. }, this);
  1039. },
  1040. deleteClustersCallback: function (response, request, data) {
  1041. if (data.isLast) {
  1042. this.createCluster();
  1043. this.createSelectedServices();
  1044. if (this.get('content.controllerName') !== 'addHostController') {
  1045. if (this.get('wizardController').getDBProperty('fileNamesToUpdate') && this.get('wizardController').getDBProperty('fileNamesToUpdate').length) {
  1046. this.updateConfigurations(this.get('wizardController').getDBProperty('fileNamesToUpdate'));
  1047. }
  1048. this.createConfigurations();
  1049. this.applyConfigurationsToCluster(this.get('serviceConfigTags'));
  1050. }
  1051. this.createComponents();
  1052. this.registerHostsToCluster();
  1053. this.createConfigurationGroups();
  1054. this.createMasterHostComponents();
  1055. this.createSlaveAndClientsHostComponents();
  1056. if (this.get('content.controllerName') === 'addServiceController') {
  1057. this.createAdditionalClientComponents();
  1058. }
  1059. this.createAdditionalHostComponents();
  1060. this.set('ajaxQueueLength', this.get('ajaxRequestsQueue.queue.length'));
  1061. this.get('ajaxRequestsQueue').start();
  1062. }
  1063. },
  1064. /**
  1065. * *******************************************************************
  1066. * The following create* functions are called upon submitting Step 8.
  1067. * *******************************************************************
  1068. */
  1069. /**
  1070. * Create cluster using selected stack version
  1071. * Queued request
  1072. * @method createCluster
  1073. */
  1074. createCluster: function () {
  1075. if (this.get('content.controllerName') !== 'installerController') return;
  1076. var stackVersion = (this.get('content.installOptions.localRepo')) ? App.currentStackVersion.replace(/(-\d+(\.\d)*)/ig, "Local$&") : App.currentStackVersion;
  1077. this.addRequestToAjaxQueue({
  1078. name: 'wizard.step8.create_cluster',
  1079. data: {
  1080. data: JSON.stringify({ "Clusters": {"version": stackVersion }})
  1081. },
  1082. success: 'createClusterSuccess'
  1083. });
  1084. },
  1085. createClusterSuccess: function (data, xhr, params) {
  1086. App.set('clusterName', params.cluster)
  1087. },
  1088. /**
  1089. * Create selected to install services
  1090. * Queued request
  1091. * Skipped if no services where selected!
  1092. * @method createSelectedServices
  1093. */
  1094. createSelectedServices: function () {
  1095. var data = this.createSelectedServicesData();
  1096. if (!data.length) return;
  1097. this.addRequestToAjaxQueue({
  1098. name: 'wizard.step8.create_selected_services',
  1099. data: {
  1100. data: JSON.stringify(data)
  1101. }
  1102. });
  1103. },
  1104. /**
  1105. * Format data for <code>createSelectedServices</code> request
  1106. * @returns {Object[]}
  1107. * @method createSelectedServicesData
  1108. */
  1109. createSelectedServicesData: function () {
  1110. return this.get('selectedServices').map(function (_service) {
  1111. return {"ServiceInfo": { "service_name": _service.get('serviceName') }};
  1112. });
  1113. },
  1114. /**
  1115. * Create components for selected services
  1116. * Queued requests
  1117. * One request for each service!
  1118. * @method createComponents
  1119. */
  1120. createComponents: function () {
  1121. var serviceComponents = App.StackServiceComponent.find();
  1122. this.get('selectedServices').forEach(function (_service) {
  1123. var serviceName = _service.get('serviceName');
  1124. var componentsData = serviceComponents.filterProperty('serviceName', serviceName).map(function (_component) {
  1125. return { "ServiceComponentInfo": { "component_name": _component.get('componentName') } };
  1126. });
  1127. // Service must be specified in terms of a query for creating multiple components at the same time.
  1128. // See AMBARI-1018.
  1129. this.addRequestToAjaxQueue({
  1130. name: 'wizard.step8.create_components',
  1131. data: {
  1132. data: JSON.stringify({"components": componentsData}),
  1133. serviceName: serviceName
  1134. }
  1135. });
  1136. }, this);
  1137. },
  1138. /**
  1139. * Error callback for new service component request
  1140. * So, if component doesn't exist we should create it
  1141. * @param {object} request
  1142. * @param {object} ajaxOptions
  1143. * @param {string} error
  1144. * @param {object} opt
  1145. * @param {object} params
  1146. * @method newServiceComponentErrorCallback
  1147. */
  1148. newServiceComponentErrorCallback: function (request, ajaxOptions, error, opt, params) {
  1149. this.addRequestToAjaxQueue({
  1150. name: 'wizard.step8.create_components',
  1151. data: {
  1152. serviceName: params.serviceName,
  1153. data: JSON.stringify({
  1154. "components": [
  1155. {
  1156. "ServiceComponentInfo": {
  1157. "component_name": params.componentName
  1158. }
  1159. }
  1160. ]
  1161. })
  1162. }
  1163. });
  1164. },
  1165. /**
  1166. * Register hosts
  1167. * Queued request
  1168. * @method registerHostsToCluster
  1169. */
  1170. registerHostsToCluster: function () {
  1171. var data = this.createRegisterHostData();
  1172. if (!data.length) return;
  1173. this.addRequestToAjaxQueue({
  1174. name: 'wizard.step8.register_host_to_cluster',
  1175. data: {
  1176. data: JSON.stringify(data)
  1177. }
  1178. });
  1179. },
  1180. /**
  1181. * Format request-data for <code>registerHostsToCluster</code>
  1182. * @returns {Object}
  1183. * @method createRegisterHostData
  1184. */
  1185. createRegisterHostData: function () {
  1186. return this.getRegisteredHosts().filterProperty('isInstalled', false).map(function (host) {
  1187. return {"Hosts": { "host_name": host.hostName}};
  1188. });
  1189. },
  1190. /**
  1191. * Register new master components
  1192. * @uses registerHostsToComponent
  1193. * @method createMasterHostComponents
  1194. */
  1195. createMasterHostComponents: function () {
  1196. // create master components for only selected services.
  1197. var selectedMasterComponents = this.get('content.masterComponentHosts').filter(function (_component) {
  1198. return this.get('selectedServices').mapProperty('serviceName').contains(_component.serviceId)
  1199. }, this);
  1200. selectedMasterComponents.mapProperty('component').uniq().forEach(function (component) {
  1201. var hostNames = selectedMasterComponents.filterProperty('component', component).filterProperty('isInstalled', false).mapProperty('hostName');
  1202. this.registerHostsToComponent(hostNames, component);
  1203. }, this);
  1204. },
  1205. getClientsToMasterMap: function () {
  1206. var clientNames = App.StackServiceComponent.find().filterProperty('isClient').mapProperty('componentName'),
  1207. clientsMap = {},
  1208. dependedComponents = App.StackServiceComponent.find().filterProperty('isMaster');
  1209. clientNames.forEach(function (clientName) {
  1210. clientsMap[clientName] = Em.A([]);
  1211. dependedComponents.forEach(function (component) {
  1212. if (component.get('dependencies').mapProperty('componentName').contains(clientName)) clientsMap[clientName].push(component.get('componentName'));
  1213. });
  1214. if (!clientsMap[clientName].length) delete clientsMap[clientName];
  1215. });
  1216. return clientsMap;
  1217. },
  1218. /**
  1219. * Register slave components and clients
  1220. * @uses registerHostsToComponent
  1221. * @method createSlaveAndClientsHostComponents
  1222. */
  1223. createSlaveAndClientsHostComponents: function () {
  1224. var masterHosts = this.get('content.masterComponentHosts');
  1225. var slaveHosts = this.get('content.slaveComponentHosts');
  1226. var clients = this.get('content.clients').filterProperty('isInstalled', false);
  1227. /**
  1228. * Determines on which hosts client should be installed (based on availability of master components on hosts)
  1229. * @type {Object}
  1230. * Format:
  1231. * <code>
  1232. * {
  1233. * CLIENT1: Em.A([MASTER1, MASTER2, ...]),
  1234. * CLIENT2: Em.A([MASTER3, MASTER1, ...])
  1235. * ...
  1236. * }
  1237. * </code>
  1238. */
  1239. var clientsToMasterMap = this.getClientsToMasterMap();
  1240. slaveHosts.forEach(function (_slave) {
  1241. if (_slave.componentName !== 'CLIENT') {
  1242. var hostNames = _slave.hosts.filterProperty('isInstalled', false).mapProperty('hostName');
  1243. this.registerHostsToComponent(hostNames, _slave.componentName);
  1244. }
  1245. else {
  1246. clients.forEach(function (_client) {
  1247. var hostNames = _slave.hosts.mapProperty('hostName');
  1248. // The below logic to install clients to existing/New master hosts should not be applied to Add Host wizard.
  1249. // This is with the presumption that Add Host controller does not add any new Master component to the cluster
  1250. if (this.get('content.controllerName') !== 'addHostController') {
  1251. if (clientsToMasterMap[_client.component_name]) {
  1252. clientsToMasterMap[_client.component_name].forEach(function (componentName) {
  1253. masterHosts.filterProperty('component', componentName).forEach(function (_masterHost) {
  1254. hostNames.pushObject(_masterHost.hostName);
  1255. });
  1256. });
  1257. }
  1258. }
  1259. hostNames = hostNames.uniq();
  1260. this.registerHostsToComponent(hostNames, _client.component_name);
  1261. }, this);
  1262. }
  1263. }, this);
  1264. },
  1265. /**
  1266. * This function is specific to addServiceController
  1267. * Newly introduced master components requires some existing client components to be hosted along with them
  1268. */
  1269. createAdditionalClientComponents: function () {
  1270. var masterHosts = this.get('content.masterComponentHosts');
  1271. var clientsToMasterMap = this.getClientsToMasterMap();
  1272. var installedClients = [];
  1273. // Get all the installed Client components
  1274. this.get('content.services').filterProperty('isInstalled').forEach(function (_service) {
  1275. var serviceClients = App.StackServiceComponent.find().filterProperty('serviceName', _service.get('serviceName')).filterProperty('isClient');
  1276. serviceClients.forEach(function (client) {
  1277. installedClients.push(client.get('componentName'));
  1278. }, this);
  1279. }, this);
  1280. // Check if there is a dependency for being co-hosted between existing client and selected new master
  1281. installedClients.forEach(function (_clientName) {
  1282. if (clientsToMasterMap[_clientName]) {
  1283. var hostNames = [];
  1284. clientsToMasterMap[_clientName].forEach(function (componentName) {
  1285. masterHosts.filterProperty('component', componentName).filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1286. hostNames.pushObject(_masterHost.hostName);
  1287. }, this);
  1288. }, this);
  1289. hostNames = hostNames.uniq();
  1290. if (hostNames.length > 0) {
  1291. this.get('content.additionalClients').pushObject({hostNames: hostNames, componentName: _clientName});
  1292. // If a dependency for being co-hosted is derived between existing client and selected new master but that
  1293. // dependency is already satisfied in the cluster then disregard the derived dependency
  1294. this.removeClientsFromList(_clientName, hostNames);
  1295. this.registerHostsToComponent(hostNames, _clientName);
  1296. }
  1297. }
  1298. }, this);
  1299. },
  1300. /**
  1301. *
  1302. * @param clientName
  1303. * @param hostList
  1304. */
  1305. removeClientsFromList: function (clientName, hostList) {
  1306. var clientHosts = [];
  1307. var installedHosts = this.get('content.hosts');
  1308. for (var hostName in installedHosts) {
  1309. if (installedHosts[hostName].isInstalled) {
  1310. if (installedHosts[hostName].hostComponents.mapProperty('HostRoles.component_name').contains(clientName)) {
  1311. clientHosts.push(hostName);
  1312. }
  1313. }
  1314. }
  1315. if (clientHosts.length > 0) {
  1316. clientHosts.forEach(function (hostName) {
  1317. if (hostList.contains(hostName)) {
  1318. hostList.splice(hostList.indexOf(hostName), 1);
  1319. }
  1320. }, this);
  1321. }
  1322. },
  1323. /**
  1324. * Register additional components
  1325. * Based on availability of some services
  1326. * @uses registerHostsToComponent
  1327. * @method createAdditionalHostComponents
  1328. */
  1329. createAdditionalHostComponents: function () {
  1330. var masterHosts = this.get('content.masterComponentHosts');
  1331. // add MySQL Server if Hive is selected
  1332. // add Ganglia Monitor (Slave) to all hosts if Ganglia service is selected
  1333. var gangliaService = this.get('content.services').filterProperty('isSelected').findProperty('serviceName', 'GANGLIA');
  1334. if (gangliaService) {
  1335. var hosts = this.getRegisteredHosts();
  1336. if (gangliaService.get('isInstalled')) {
  1337. hosts = hosts.filterProperty('isInstalled', false);
  1338. }
  1339. if (hosts.length) {
  1340. this.registerHostsToComponent(hosts.mapProperty('hostName'), 'GANGLIA_MONITOR');
  1341. }
  1342. }
  1343. var hiveService = this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).findProperty('serviceName', 'HIVE');
  1344. if (hiveService) {
  1345. var hiveDb = this.get('content.serviceConfigProperties').findProperty('name', 'hive_database');
  1346. if (hiveDb.value == "New MySQL Database") {
  1347. this.registerHostsToComponent(masterHosts.filterProperty('component', 'HIVE_SERVER').mapProperty('hostName'), 'MYSQL_SERVER');
  1348. } else if (hiveDb.value === "New PostgreSQL Database") {
  1349. this.registerHostsToComponent(masterHosts.filterProperty('component', 'HIVE_SERVER').mapProperty('hostName'), 'POSTGRESQL_SERVER');
  1350. }
  1351. }
  1352. },
  1353. /**
  1354. * Register component to hosts
  1355. * Queued request
  1356. * @param {String[]} hostNames
  1357. * @param {String} componentName
  1358. * @method registerHostsToComponent
  1359. */
  1360. registerHostsToComponent: function (hostNames, componentName) {
  1361. if (!hostNames.length) return;
  1362. var queryStr = '';
  1363. hostNames.forEach(function (hostName) {
  1364. queryStr += 'Hosts/host_name=' + hostName + '|';
  1365. });
  1366. //slice off last symbol '|'
  1367. queryStr = queryStr.slice(0, -1);
  1368. var data = {
  1369. "RequestInfo": {
  1370. "query": queryStr
  1371. },
  1372. "Body": {
  1373. "host_components": [
  1374. {
  1375. "HostRoles": {
  1376. "component_name": componentName
  1377. }
  1378. }
  1379. ]
  1380. }
  1381. };
  1382. this.addRequestToAjaxQueue({
  1383. name: 'wizard.step8.register_host_to_component',
  1384. data: {
  1385. data: JSON.stringify(data)
  1386. }
  1387. });
  1388. },
  1389. /**
  1390. * Compare generated config object with current configs that were filled
  1391. * on "Customize Services" page.
  1392. *
  1393. * @param {Object} properties - generated by createSiteObj|createCoreSiteObj
  1394. * @param {Array} configs - current configs to compare
  1395. * @return {Boolean}
  1396. * @method isConfigsChanged
  1397. **/
  1398. isConfigsChanged: function (properties, configs) {
  1399. var isChanged = false;
  1400. for (var property in properties) {
  1401. var config = configs.findProperty('name', property);
  1402. // if config not found then it's looks like a new config
  1403. if (!config) {
  1404. isChanged = true;
  1405. } else {
  1406. if (!config.hasInitialValue || config.isNotDefaultValue) {
  1407. isChanged = true;
  1408. }
  1409. }
  1410. }
  1411. return isChanged;
  1412. },
  1413. /**
  1414. * Create config objects for cluster and services
  1415. * @method createConfigurations
  1416. */
  1417. createConfigurations: function () {
  1418. var selectedServices = this.get('selectedServices');
  1419. var coreSiteObject = this.createCoreSiteObj();
  1420. var tag = 'version1';
  1421. var clusterSiteObj = this.createSiteObj('cluster-env', tag);
  1422. if (this.get('content.controllerName') == 'installerController') {
  1423. this.get('serviceConfigTags').pushObject(clusterSiteObj);
  1424. }
  1425. if (this.get('content.controllerName') == 'addServiceController') {
  1426. tag = 'version' + (new Date).getTime();
  1427. coreSiteObject.tag = tag;
  1428. var coreSiteConfigs = this.get('configs').filterProperty('filename', 'core-site.xml');
  1429. if (this.isConfigsChanged(coreSiteObject.properties, coreSiteConfigs)) {
  1430. this.get('serviceConfigTags').pushObject(coreSiteObject);
  1431. }
  1432. }
  1433. selectedServices.forEach(function (service) {
  1434. Object.keys(service.get('configTypes')).forEach(function (type) {
  1435. if (!this.get('serviceConfigTags').someProperty('type', type)) {
  1436. var serviceVersionNotes = Em.I18n.t('dashboard.configHistory.table.notes.default').format(service.get('displayName'));
  1437. if (service.get('serviceName') === 'MAPREDUCE' && (type === 'capacity-scheduler' || type === 'mapred-queue-acls')) {
  1438. return;
  1439. } else if (type === 'core-site') {
  1440. coreSiteObject.service_config_version_note = serviceVersionNotes
  1441. this.get('serviceConfigTags').pushObject(coreSiteObject);
  1442. } else if (type === 'storm-site') {
  1443. var obj = this.createStormSiteObj(tag);
  1444. obj.service_config_version_note = serviceVersionNotes;
  1445. this.get('serviceConfigTags').pushObject(obj);
  1446. } else {
  1447. var obj = this.createSiteObj(type, tag);
  1448. obj.service_config_version_note = serviceVersionNotes;
  1449. this.get('serviceConfigTags').pushObject(obj);
  1450. }
  1451. }
  1452. }, this);
  1453. }, this);
  1454. },
  1455. /**
  1456. * Send <code>serviceConfigTags</code> to server
  1457. * Queued request
  1458. * One request for each service config tag
  1459. * @param serviceConfigTags
  1460. * @method applyConfigurationsToCluster
  1461. */
  1462. applyConfigurationsToCluster: function (serviceConfigTags) {
  1463. var allServices = this.get('installedServices').concat(this.get('selectedServices'));
  1464. var allConfigData = [];
  1465. allServices.forEach(function (service) {
  1466. var serviceConfigData = [];
  1467. Object.keys(service.get('configTypesRendered')).forEach(function (type) {
  1468. var serviceConfigTag = serviceConfigTags.findProperty('type', type);
  1469. if (serviceConfigTag) {
  1470. serviceConfigData.pushObject(serviceConfigTag);
  1471. }
  1472. }, this);
  1473. if (serviceConfigData.length) {
  1474. allConfigData.pushObject(JSON.stringify({
  1475. Clusters: {
  1476. desired_config: serviceConfigData
  1477. }
  1478. }));
  1479. }
  1480. }, this);
  1481. var clusterConfig = serviceConfigTags.findProperty('type', 'cluster-env');
  1482. if (clusterConfig) {
  1483. allConfigData.pushObject(JSON.stringify({
  1484. Clusters: {
  1485. desired_config: [clusterConfig]
  1486. }
  1487. }));
  1488. }
  1489. this.addRequestToAjaxQueue({
  1490. name: 'common.across.services.configurations',
  1491. data: {
  1492. data: '[' + allConfigData.toString() + ']'
  1493. }
  1494. });
  1495. },
  1496. /**
  1497. * Create and update config groups
  1498. * @method createConfigurationGroups
  1499. */
  1500. createConfigurationGroups: function () {
  1501. var configGroups = this.get('content.configGroups').filterProperty('isDefault', false);
  1502. var clusterName = this.get('clusterName');
  1503. var sendData = [];
  1504. var updateData = [];
  1505. var serviceConfigController = App.router.get('mainServiceInfoConfigsController');
  1506. var timeTag = (new Date).getTime();
  1507. var groupsToDelete = App.router.get(this.get('content.controllerName')).getDBProperty('groupsToDelete');
  1508. if (groupsToDelete && groupsToDelete.length > 0) {
  1509. this.removeInstalledServicesConfigurationGroups(groupsToDelete);
  1510. }
  1511. configGroups.forEach(function (configGroup) {
  1512. var groupConfigs = [];
  1513. var groupData = {
  1514. "cluster_name": clusterName,
  1515. "group_name": configGroup.name,
  1516. "tag": configGroup.service.id,
  1517. "description": configGroup.description,
  1518. "hosts": [],
  1519. "desired_configs": []
  1520. };
  1521. configGroup.hosts.forEach(function (hostName) {
  1522. groupData.hosts.push({"host_name": hostName});
  1523. });
  1524. // get properties that was created for non-default config group
  1525. configGroup.properties = configGroup.properties.concat(this.get('customNonDefaultGroupConfigs').filterProperty('group', configGroup.name));
  1526. //wrap properties into Em.Object to make them compatible with buildGroupDesiredConfigs method
  1527. configGroup.properties.forEach(function (property) {
  1528. groupConfigs.push(Em.Object.create(property));
  1529. });
  1530. groupData.desired_configs = serviceConfigController.buildGroupDesiredConfigs.call(serviceConfigController, groupConfigs, timeTag);
  1531. // check for group from installed service
  1532. if (configGroup.isForInstalledService === true) {
  1533. // if group is a new one, create it
  1534. if (!configGroup.id) {
  1535. sendData.push({"ConfigGroup": groupData});
  1536. } else if (configGroup.isForUpdate){
  1537. // update an existing group
  1538. groupData.id = configGroup.id;
  1539. updateData.push({"ConfigGroup": groupData});
  1540. }
  1541. } else {
  1542. sendData.push({"ConfigGroup": groupData});
  1543. }
  1544. //each group should have unique tag to prevent overriding configs from common sites
  1545. timeTag++;
  1546. }, this);
  1547. if (sendData.length > 0) {
  1548. this.applyConfigurationGroups(sendData);
  1549. }
  1550. if (updateData.length > 0) {
  1551. this.applyInstalledServicesConfigurationGroup(updateData);
  1552. }
  1553. },
  1554. /**
  1555. * Create new config groups request
  1556. * Queued request
  1557. * @param {Object[]} sendData
  1558. * @method applyConfigurationGroups
  1559. */
  1560. applyConfigurationGroups: function (sendData) {
  1561. this.addRequestToAjaxQueue({
  1562. name: 'wizard.step8.apply_configuration_groups',
  1563. data: {
  1564. data: JSON.stringify(sendData)
  1565. }
  1566. });
  1567. },
  1568. /**
  1569. * Update existed config groups
  1570. * Separated request for each group
  1571. * @param {Object[]} updateData
  1572. * @method applyInstalledServicesConfigurationGroup
  1573. */
  1574. applyInstalledServicesConfigurationGroup: function (updateData) {
  1575. updateData.forEach(function (item) {
  1576. App.router.get('mainServiceInfoConfigsController').putConfigGroupChanges(item);
  1577. });
  1578. },
  1579. /**
  1580. * Delete selected config groups
  1581. * @param {Object[]} groupsToDelete
  1582. * @method removeInstalledServicesConfigurationGroups
  1583. */
  1584. removeInstalledServicesConfigurationGroups: function (groupsToDelete) {
  1585. groupsToDelete.forEach(function (item) {
  1586. App.config.deleteConfigGroup(Em.Object.create(item));
  1587. });
  1588. },
  1589. /**
  1590. * proxyuser configs which depend on service
  1591. */
  1592. optionalCoreSiteConfigs: [
  1593. {
  1594. serviceName: 'OOZIE',
  1595. user: 'oozie_user'
  1596. },
  1597. {
  1598. serviceName: 'HIVE',
  1599. user: 'hive_user'
  1600. },
  1601. {
  1602. serviceName: 'HIVE',
  1603. user: 'hcat_user'
  1604. },
  1605. {
  1606. serviceName: 'FALCON',
  1607. user: 'falcon_user'
  1608. }
  1609. ],
  1610. /**
  1611. * push proxyuser properties to core-site if they required by dependencies
  1612. * @param coreSiteObj
  1613. * @param installedAndSelectedServices
  1614. * @return {Object}
  1615. */
  1616. resolveProxyuserDependecies: function (coreSiteObj, installedAndSelectedServices) {
  1617. var coreSiteProperties = {};
  1618. var optionalCoreSiteConfigs = this.get('optionalCoreSiteConfigs');
  1619. var proxyuserGroup = this.get('configs').findProperty('name', 'proxyuser_group');
  1620. coreSiteObj.forEach(function (_coreSiteObj) {
  1621. //proxyuser_group property should be added only if proxyuser properties are used
  1622. if (_coreSiteObj.name === proxyuserGroup.name) return;
  1623. // exclude some configs if service wasn't selected
  1624. var addProperty = optionalCoreSiteConfigs.every(function (config) {
  1625. var userValue = this.get('configs').someProperty('name', config.user) ? this.get('configs').findProperty('name', config.user).value : null
  1626. return (installedAndSelectedServices.someProperty('serviceName', config.serviceName) ||
  1627. (_coreSiteObj.name != 'hadoop.proxyuser.' + userValue + '.hosts' && _coreSiteObj.name != 'hadoop.proxyuser.' + userValue + '.groups'))
  1628. }, this);
  1629. if (addProperty) {
  1630. coreSiteProperties[_coreSiteObj.name] = _coreSiteObj.value;
  1631. }
  1632. }, this);
  1633. if (!App.isEmptyObject(coreSiteProperties) && proxyuserGroup) {
  1634. coreSiteProperties[proxyuserGroup.name] = proxyuserGroup.value;
  1635. }
  1636. return coreSiteProperties;
  1637. },
  1638. /**
  1639. * Create Core Site object
  1640. * @returns {{type: string, tag: string, properties: {}}}
  1641. * @method createCoreSiteObj
  1642. */
  1643. createCoreSiteObj: function () {
  1644. var installedAndSelectedServices = Em.A([]);
  1645. installedAndSelectedServices.pushObjects(this.get('installedServices'));
  1646. installedAndSelectedServices.pushObjects(this.get('selectedServices'));
  1647. var coreSiteObj = this.get('configs').filterProperty('filename', 'core-site.xml'),
  1648. coreSiteProperties = this.resolveProxyuserDependecies(coreSiteObj, installedAndSelectedServices),
  1649. isGLUSTERFSSelected = installedAndSelectedServices.someProperty('serviceName', 'GLUSTERFS');
  1650. coreSiteObj.forEach(function (_coreSiteObj) {
  1651. if (isGLUSTERFSSelected && _coreSiteObj.name == "fs.default.name") {
  1652. coreSiteProperties[_coreSiteObj.name] =
  1653. this.get('configs').someProperty('name', 'fs_glusterfs_default_name') ?
  1654. this.get('configs').findProperty('name', 'fs_glusterfs_default_name').value : null;
  1655. }
  1656. if (isGLUSTERFSSelected && _coreSiteObj.name == "fs.defaultFS") {
  1657. coreSiteProperties[_coreSiteObj.name] =
  1658. this.get('configs').someProperty('name', 'glusterfs_defaultFS_name') ?
  1659. this.get('configs').findProperty('name', 'glusterfs_defaultFS_name').value : null;
  1660. }
  1661. }, this);
  1662. var attributes = App.router.get('mainServiceInfoConfigsController').getConfigAttributes(coreSiteObj);
  1663. var configObj = {"type": "core-site", "tag": "version1", "properties": coreSiteProperties};
  1664. if (attributes) {
  1665. configObj['properties_attributes'] = attributes;
  1666. }
  1667. return configObj;
  1668. },
  1669. /**
  1670. * Create siteObj for custom service with it own configs
  1671. * @param {string} site
  1672. * @param tag
  1673. * @returns {{type: string, tag: string, properties: {}}}
  1674. * @method createSiteObj
  1675. */
  1676. createSiteObj: function (site, tag) {
  1677. var properties = {};
  1678. var configs = this.get('configs').filterProperty('filename', site + '.xml');
  1679. var attributes = App.router.get('mainServiceInfoConfigsController').getConfigAttributes(configs);
  1680. configs.forEach(function (_configProperty) {
  1681. var heapsizeExceptions = ['hadoop_heapsize', 'yarn_heapsize', 'nodemanager_heapsize', 'resourcemanager_heapsize', 'apptimelineserver_heapsize', 'jobhistory_heapsize'];
  1682. // do not pass any globals whose name ends with _host or _hosts
  1683. if (_configProperty.isRequiredByAgent !== false) {
  1684. // append "m" to JVM memory options except for heapsizeExtensions
  1685. if (/_heapsize|_newsize|_maxnewsize|_permsize|_maxpermsize$/.test(_configProperty.name) && !heapsizeExceptions.contains(_configProperty.name) && !(_configProperty.value).endsWith("m")) {
  1686. properties[_configProperty.name] = _configProperty.value + "m";
  1687. } else {
  1688. properties[_configProperty.name] = _configProperty.value;
  1689. }
  1690. }
  1691. }, this);
  1692. var configObj = {"type": site, "tag": tag, "properties": properties };
  1693. if (attributes) {
  1694. configObj['properties_attributes'] = attributes;
  1695. }
  1696. return configObj;
  1697. },
  1698. /**
  1699. * Create site obj for Storm
  1700. * Some config-properties should be modified in custom way
  1701. * @param tag
  1702. * @returns {{type: string, tag: string, properties: {}}}
  1703. * @method createStormSiteObj
  1704. */
  1705. createStormSiteObj: function (tag) {
  1706. var configs = this.get('configs').filterProperty('filename', 'storm-site.xml');
  1707. var stormProperties = {};
  1708. configs.forEach(function (_configProperty) {
  1709. if (_configProperty.name == "storm.zookeeper.servers") {
  1710. stormProperties[_configProperty.name] = JSON.stringify(_configProperty.value).replace(/"/g, "'");
  1711. } else {
  1712. stormProperties[_configProperty.name] = _configProperty.value;
  1713. }
  1714. }, this);
  1715. return {type: 'storm-site', tag: tag, properties: stormProperties};
  1716. },
  1717. /**
  1718. * Navigate to next step after all requests are sent
  1719. * @method ajaxQueueFinished
  1720. */
  1721. ajaxQueueFinished: function () {
  1722. console.log('everything is loaded');
  1723. App.router.send('next');
  1724. },
  1725. /**
  1726. * We need to do a lot of ajax calls async in special order. To do this,
  1727. * generate array of ajax objects and then send requests step by step. All
  1728. * ajax objects are stored in <code>ajaxRequestsQueue</code>
  1729. *
  1730. * @param {Object} params object with ajax-request parameters like url, type, data etc
  1731. * @method addRequestToAjaxQueue
  1732. */
  1733. addRequestToAjaxQueue: function (params) {
  1734. if (App.get('testMode')) return;
  1735. params = jQuery.extend({
  1736. sender: this,
  1737. error: 'ajaxQueueRequestErrorCallback'
  1738. }, params);
  1739. params.data['cluster'] = this.get('clusterName');
  1740. this.get('ajaxRequestsQueue').addRequest(params);
  1741. },
  1742. /**
  1743. * Error callback for each queued ajax-request
  1744. * @param {object} xhr
  1745. * @param {string} status
  1746. * @param {string} error
  1747. * @method ajaxQueueRequestErrorCallback
  1748. */
  1749. ajaxQueueRequestErrorCallback: function (xhr, status, error) {
  1750. var responseText = JSON.parse(xhr.responseText);
  1751. var controller = App.router.get(App.clusterStatus.wizardControllerName);
  1752. controller.registerErrPopup(Em.I18n.t('common.error'), responseText.message);
  1753. this.set('hasErrorOccurred', true);
  1754. // an error will break the ajax call chain and allow submission again
  1755. this.set('isSubmitDisabled', false);
  1756. this.set('isBackBtnDisabled', false);
  1757. App.router.get(this.get('content.controllerName')).setStepsEnable();
  1758. }
  1759. });