step8_controller.js 64 KB

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