step8_controller.js 64 KB

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