step8_controller.js 62 KB

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