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