step8_controller.js 62 KB

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