step8_controller.js 63 KB

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