step8_controller.js 63 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759
  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. if (this.get('content.controllerName') == 'installerController' && (!App.get('testMode'))) {
  821. this.deleteClusters(this.getExistingClusterNames());
  822. }
  823. if (this.get('wizardController').getDBProperty('configsToUpdate')) {
  824. this.updateConfigurations(this.get('wizardController').getDBProperty('configsToUpdate'));
  825. }
  826. this.setLocalRepositories();
  827. this.createCluster();
  828. this.createSelectedServices();
  829. if (this.get('content.controllerName') !== 'addHostController') {
  830. this.createConfigurations();
  831. this.applyConfigurationsToCluster();
  832. }
  833. this.createComponents();
  834. this.registerHostsToCluster();
  835. if (App.get('supports.hostOverridesInstaller')) {
  836. this.createConfigurationGroups();
  837. }
  838. this.createMasterHostComponents();
  839. this.createSlaveAndClientsHostComponents();
  840. this.createAdditionalHostComponents();
  841. this.set('ajaxQueueLength', this.get('ajaxRequestsQueue.queue.length'));
  842. this.get('ajaxRequestsQueue').start();
  843. },
  844. /**
  845. * Get list of existing cluster names
  846. * @returns {string[]}
  847. * returns an array of existing cluster names.
  848. * returns an empty array if there are no existing clusters.
  849. * @method getExistingClusterNames
  850. */
  851. getExistingClusterNames: function () {
  852. App.ajax.send({
  853. name: 'wizard.step8.existing_cluster_names',
  854. sender: this,
  855. success: 'getExistingClusterNamesSuccessCallBack',
  856. error: 'getExistingClusterNamesErrorCallback'
  857. });
  858. return this.get('clusterNames');
  859. },
  860. /**
  861. * Save received list to <code>clusterNames</code>
  862. * @param {Object} data
  863. * @method getExistingClusterNamesSuccessCallBack
  864. */
  865. getExistingClusterNamesSuccessCallBack: function (data) {
  866. var clusterNames = data.items.mapProperty('Clusters.cluster_name');
  867. console.log("Got existing cluster names: " + clusterNames);
  868. this.set('clusterNames', clusterNames);
  869. },
  870. /**
  871. * If error appears, set <code>clusterNames</code> to <code>[]</code>
  872. * @method getExistingClusterNamesErrorCallback
  873. */
  874. getExistingClusterNamesErrorCallback: function () {
  875. console.log("Failed to get existing cluster names");
  876. this.set('clusterNames', []);
  877. },
  878. /**
  879. * Delete cluster by name
  880. * One request for one cluster!
  881. * @param {string[]} clusterNames
  882. * @method deleteClusters
  883. */
  884. deleteClusters: function (clusterNames) {
  885. clusterNames.forEach(function (clusterName) {
  886. App.ajax.send({
  887. name: 'wizard.step8.delete_cluster',
  888. sender: this,
  889. data: {
  890. name: clusterName
  891. }
  892. });
  893. }, this);
  894. },
  895. /**
  896. * Updates local repositories for the Ambari server.
  897. * @method setLocalRepositories
  898. * @return {bool} true - requests are sent, false - requests not sent
  899. */
  900. setLocalRepositories: function () {
  901. if (this.get('content.controllerName') !== 'installerController' || !App.get('supports.localRepositories')) return false;
  902. var self = this,
  903. stack = this.get('content.stacks').findProperty('isSelected', true);
  904. stack.operatingSystems.forEach(function (os) {
  905. if (os.baseUrl !== os.originalBaseUrl) {
  906. console.log("Updating local repository URL from " + os.originalBaseUrl + " -> " + os.baseUrl + ". ", os);
  907. self.addRequestToAjaxQueue({
  908. name: 'wizard.step8.set_local_repos',
  909. data: {
  910. osType: os.osType,
  911. repoId: os.repoId,
  912. stackVersionURL: App.get('stackVersionURL'),
  913. data: JSON.stringify({
  914. "Repositories": {
  915. "base_url": os.baseUrl,
  916. "verify_base_url": false
  917. }
  918. })
  919. }
  920. });
  921. }
  922. });
  923. return true;
  924. },
  925. /**
  926. * *******************************************************************
  927. * The following create* functions are called upon submitting Step 8.
  928. * *******************************************************************
  929. */
  930. /**
  931. * Create cluster using selected stack version
  932. * Queued request
  933. * @method createCluster
  934. */
  935. createCluster: function () {
  936. if (this.get('content.controllerName') !== 'installerController') return;
  937. var stackVersion = (this.get('content.installOptions.localRepo')) ? App.currentStackVersion.replace(/(-\d+(\.\d)*)/ig, "Local$&") : App.currentStackVersion;
  938. this.addRequestToAjaxQueue({
  939. name: 'wizard.step8.create_cluster',
  940. data: {
  941. data: JSON.stringify({ "Clusters": {"version": stackVersion }})
  942. }
  943. });
  944. },
  945. /**
  946. * Create selected to install services
  947. * Queued request
  948. * Skipped if no services where selected!
  949. * @method createSelectedServices
  950. */
  951. createSelectedServices: function () {
  952. var data = this.createSelectedServicesData();
  953. if (!data.length) return;
  954. this.addRequestToAjaxQueue({
  955. name: 'wizard.step8.create_selected_services',
  956. data: {
  957. data: JSON.stringify(data)
  958. }
  959. });
  960. },
  961. /**
  962. * Format data for <code>createSelectedServices</code> request
  963. * @returns {Object[]}
  964. * @method createSelectedServicesData
  965. */
  966. createSelectedServicesData: function () {
  967. return this.get('selectedServices').map(function (_service) {
  968. return {"ServiceInfo": { "service_name": _service.get('serviceName') }};
  969. });
  970. },
  971. /**
  972. * Create components for selected services
  973. * Queued requests
  974. * One request for each service!
  975. * @method createComponents
  976. */
  977. createComponents: function () {
  978. var serviceComponents = App.StackServiceComponent.find();
  979. this.get('selectedServices').forEach(function (_service) {
  980. var serviceName = _service.get('serviceName');
  981. var componentsData = serviceComponents.filterProperty('serviceName', serviceName).map(function (_component) {
  982. return { "ServiceComponentInfo": { "component_name": _component.get('componentName') } };
  983. });
  984. // Service must be specified in terms of a query for creating multiple components at the same time.
  985. // See AMBARI-1018.
  986. this.addRequestToAjaxQueue({
  987. name: 'wizard.step8.create_components',
  988. data: {
  989. data: JSON.stringify({"components": componentsData}),
  990. serviceName: serviceName
  991. }
  992. });
  993. }, this);
  994. if (this.get('content.controllerName') == 'addServiceController' && !App.get('testMode')) {
  995. // Add service-components which show up in newer versions but did not
  996. // exist in older ones.
  997. var self = this;
  998. var newServiceComponents = {};
  999. if (App.get('isHadoop21Stack')) {
  1000. if (App.YARNService.find().objectAt(0)) {
  1001. newServiceComponents['APP_TIMELINE_SERVER'] = 'YARN';
  1002. }
  1003. }
  1004. for (var componentName in newServiceComponents) {
  1005. if (newServiceComponents.hasOwnProperty(componentName)) {
  1006. var serviceName = newServiceComponents[componentName];
  1007. // Create only if it doesnt exist
  1008. App.ajax.send({
  1009. name: 'service.service_component',
  1010. sender: self,
  1011. data: {
  1012. serviceName: serviceName,
  1013. componentName: componentName,
  1014. async: false
  1015. },
  1016. error: 'newServiceComponentErrorCallback'
  1017. });
  1018. }
  1019. }
  1020. }
  1021. },
  1022. /**
  1023. * Error callback for new service component request
  1024. * So, if component doesn't exist we should create it
  1025. * @param {object} request
  1026. * @param {object} ajaxOptions
  1027. * @param {string} error
  1028. * @param {object} opt
  1029. * @param {object} params
  1030. * @method newServiceComponentErrorCallback
  1031. */
  1032. newServiceComponentErrorCallback: function (request, ajaxOptions, error, opt, params) {
  1033. this.addRequestToAjaxQueue({
  1034. name: 'wizard.step8.create_components',
  1035. data: {
  1036. serviceName: params.serviceName,
  1037. data: JSON.stringify({
  1038. "components": [
  1039. {
  1040. "ServiceComponentInfo": {
  1041. "component_name": params.componentName
  1042. }
  1043. }
  1044. ]
  1045. })
  1046. }
  1047. });
  1048. },
  1049. /**
  1050. * Register hosts
  1051. * Queued request
  1052. * @method registerHostsToCluster
  1053. */
  1054. registerHostsToCluster: function () {
  1055. var data = this.createRegisterHostData();
  1056. if (!data.length) return;
  1057. this.addRequestToAjaxQueue({
  1058. name: 'wizard.step8.register_host_to_cluster',
  1059. data: {
  1060. data: JSON.stringify(data)
  1061. }
  1062. });
  1063. },
  1064. /**
  1065. * Format request-data for <code>registerHostsToCluster</code>
  1066. * @returns {Object}
  1067. * @method createRegisterHostData
  1068. */
  1069. createRegisterHostData: function () {
  1070. return this.getRegisteredHosts().filterProperty('isInstalled', false).map(function (host) {
  1071. return {"Hosts": { "host_name": host.hostName}};
  1072. });
  1073. },
  1074. /**
  1075. * Register new master components
  1076. * @uses registerHostsToComponent
  1077. * @method createMasterHostComponents
  1078. */
  1079. createMasterHostComponents: function () {
  1080. var masterHosts = this.get('content.masterComponentHosts');
  1081. masterHosts.mapProperty('component').uniq().forEach(function (component) {
  1082. var hostNames = masterHosts.filterProperty('component', component).filterProperty('isInstalled', false).mapProperty('hostName');
  1083. this.registerHostsToComponent(hostNames, component);
  1084. }, this);
  1085. },
  1086. /**
  1087. * Register slave components and clients
  1088. * @uses registerHostsToComponent
  1089. * @method createSlaveAndClientsHostComponents
  1090. */
  1091. createSlaveAndClientsHostComponents: function () {
  1092. var masterHosts = this.get('content.masterComponentHosts'),
  1093. slaveHosts = this.get('content.slaveComponentHosts'),
  1094. clients = this.get('content.clients');
  1095. /**
  1096. * Determines on which hosts client should be installed (based on availability of master components on hosts)
  1097. * @type {Object}
  1098. * Format:
  1099. * <code>
  1100. * {
  1101. * CLIENT1: Em.A([MASTER1, MASTER2, ...]),
  1102. * CLIENT2: Em.A([MASTER3, MASTER1, ...])
  1103. * ...
  1104. * }
  1105. * </code>
  1106. */
  1107. var clientsToMasterMap = {
  1108. HDFS_CLIENT: Em.A(['HBASE_MASTER', 'HBASE_REGIONSERVER', 'WEBHCAT_SERVER', 'HISTORYSERVER', 'OOZIE_SERVER']),
  1109. MAPREDUCE_CLIENT: Em.A(['HIVE_SERVER', 'OOZIE_SERVER', 'NAGIOS_SERVER', 'WEBHCAT_SERVER']),
  1110. OOZIE_CLIENT: Em.A(['NAGIOS_SERVER']),
  1111. ZOOKEEPER_CLIENT: Em.A(['WEBHCAT_SERVER']),
  1112. HIVE_CLIENT: Em.A(['WEBHCAT_SERVER', 'HIVE_SERVER']),
  1113. HCAT: Em.A(['NAGIOS_SERVER']),
  1114. YARN_CLIENT: Em.A(['NAGIOS_SERVER', 'HIVE_SERVER', 'OOZIE_SERVER', 'WEBHCAT_SERVER']),
  1115. TEZ_CLIENT: Em.A(['NAGIOS_SERVER', 'HIVE_SERVER'])
  1116. };
  1117. slaveHosts.forEach(function (_slave) {
  1118. if (_slave.componentName !== 'CLIENT') {
  1119. var hostNames = _slave.hosts.filterProperty('isInstalled', false).mapProperty('hostName');
  1120. this.registerHostsToComponent(hostNames, _slave.componentName);
  1121. }
  1122. else {
  1123. clients.forEach(function (_client) {
  1124. var hostNames = _slave.hosts.mapProperty('hostName');
  1125. if (clientsToMasterMap[_client.component_name]) {
  1126. clientsToMasterMap[_client.component_name].forEach(function (componentName) {
  1127. masterHosts.filterProperty('component', componentName).filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1128. hostNames.pushObject(_masterHost.hostName);
  1129. });
  1130. });
  1131. }
  1132. hostNames = hostNames.uniq();
  1133. if (_client.isInstalled) {
  1134. /**
  1135. * check whether clients are already installed on selected master hosts!!!
  1136. */
  1137. var clientHosts = [];
  1138. var installedHosts = this.get('content.hosts');
  1139. for (var hostName in installedHosts) {
  1140. if (installedHosts[hostName].isInstalled &&
  1141. installedHosts[hostName].hostComponents.filterProperty('HostRoles.state', 'INSTALLED').mapProperty('HostRoles.component_name').contains(_client.component_name)) {
  1142. clientHosts.push(hostName);
  1143. }
  1144. }
  1145. if (clientHosts.length > 0) {
  1146. clientHosts.forEach(function (hostName) {
  1147. if (hostNames.contains(hostName)) {
  1148. hostNames.splice(hostNames.indexOf(hostName), 1);
  1149. }
  1150. }, this);
  1151. }
  1152. /**
  1153. * For Add Service Only
  1154. * if client is not added to host or is not installed add Object
  1155. * {
  1156. * componentName: {String},
  1157. * hostName: {String}
  1158. * }
  1159. * to content.additionalClients
  1160. * later it will be used to install client on host before istalling new services
  1161. */
  1162. if (this.get('content.controllerName') === 'addServiceController' && hostNames.length > 0) {
  1163. hostNames.forEach(function (hostName) {
  1164. this.get('content.additionalClients').push(Em.Object.create({
  1165. componentName: _client.component_name, hostName: hostName
  1166. }))
  1167. }, this)
  1168. }
  1169. }
  1170. this.registerHostsToComponent(hostNames, _client.component_name);
  1171. }, this);
  1172. }
  1173. }, this);
  1174. },
  1175. /**
  1176. * Register additional components
  1177. * Based on availability of some services
  1178. * @uses registerHostsToComponent
  1179. * @method createAdditionalHostComponents
  1180. */
  1181. createAdditionalHostComponents: function () {
  1182. var masterHosts = this.get('content.masterComponentHosts');
  1183. // add Ganglia Monitor (Slave) to all hosts if Ganglia service is selected
  1184. var gangliaService = this.get('content.services').filterProperty('isSelected', true).findProperty('serviceName', 'GANGLIA');
  1185. if (gangliaService) {
  1186. var hosts = this.getRegisteredHosts();
  1187. if (gangliaService.get('isInstalled')) {
  1188. hosts = hosts.filterProperty('isInstalled', false);
  1189. }
  1190. if (hosts.length) {
  1191. this.registerHostsToComponent(hosts.mapProperty('hostName'), 'GANGLIA_MONITOR');
  1192. }
  1193. }
  1194. // add MySQL Server if Hive is selected
  1195. var hiveService = this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).findProperty('serviceName', 'HIVE');
  1196. if (hiveService) {
  1197. var hiveDb = this.get('content.serviceConfigProperties').findProperty('name', 'hive_database');
  1198. if (hiveDb.value == "New MySQL Database") {
  1199. this.registerHostsToComponent(masterHosts.filterProperty('component', 'HIVE_SERVER').mapProperty('hostName'), 'MYSQL_SERVER');
  1200. }
  1201. }
  1202. },
  1203. /**
  1204. * Register component to hosts
  1205. * Queued request
  1206. * @param {String[]} hostNames
  1207. * @param {String} componentName
  1208. * @method registerHostsToComponent
  1209. */
  1210. registerHostsToComponent: function (hostNames, componentName) {
  1211. if (!hostNames.length) return;
  1212. var queryStr = '';
  1213. hostNames.forEach(function (hostName) {
  1214. queryStr += 'Hosts/host_name=' + hostName + '|';
  1215. });
  1216. //slice off last symbol '|'
  1217. queryStr = queryStr.slice(0, -1);
  1218. var data = {
  1219. "RequestInfo": {
  1220. "query": queryStr
  1221. },
  1222. "Body": {
  1223. "host_components": [
  1224. {
  1225. "HostRoles": {
  1226. "component_name": componentName
  1227. }
  1228. }
  1229. ]
  1230. }
  1231. };
  1232. this.addRequestToAjaxQueue({
  1233. name: 'wizard.step8.register_host_to_component',
  1234. data: {
  1235. data: JSON.stringify(data)
  1236. }
  1237. });
  1238. },
  1239. /**
  1240. * Create config objects for cluster and services
  1241. * @method createConfigurations
  1242. */
  1243. createConfigurations: function () {
  1244. var self = this;
  1245. var selectedServices = this.get('selectedServices');
  1246. var coreSiteObject = this.createCoreSiteObj();
  1247. var tag = 'version1';
  1248. if (this.get('content.controllerName') == 'installerController') {
  1249. this.get('serviceConfigTags').pushObject(coreSiteObject);
  1250. this.get('serviceConfigTags').pushObject(this.createSiteObj('hdfs-site', false, tag));
  1251. this.get('serviceConfigTags').pushObject(this.createLog4jObj('hdfs', tag));
  1252. }
  1253. var globalSiteObj = this.createGlobalSiteObj(tag);
  1254. if (this.get('content.controllerName') == 'addServiceController') {
  1255. tag = 'version' + (new Date).getTime();
  1256. globalSiteObj.tag = tag;
  1257. coreSiteObject.tag = tag;
  1258. this.get('serviceConfigTags').pushObject(coreSiteObject);
  1259. //for Add Service save config of new and installed services either
  1260. selectedServices = selectedServices.concat(this.get('installedServices'));
  1261. }
  1262. this.get('serviceConfigTags').pushObject(globalSiteObj);
  1263. var objMap = {
  1264. MAPREDUCE: {site: [
  1265. {filename: 'mapred-site', isXmlFile: true}
  1266. ], log4j: ['mapreduce']},
  1267. MAPREDUCE2: {site: [
  1268. {filename: 'mapred-site', isXmlFile: true}
  1269. ], log4j: ['mapreduce2']},
  1270. YARN: {site: [
  1271. {filename: 'yarn-site', isXmlFile: true},
  1272. {filename: 'capacity-scheduler', isXmlFile: true}
  1273. ], log4j: ['yarn']},
  1274. HBASE: {site: [
  1275. {filename: 'hbase-site', isXmlFile: true}
  1276. ], log4j: ['hbase']},
  1277. OOZIE: {site: [
  1278. {filename: 'oozie-site', isXmlFile: true}
  1279. ], log4j: ['oozie']},
  1280. HIVE: {site: [
  1281. {filename: 'hive-site', isXmlFile: true}
  1282. ], log4j: ['hive', 'hive-exec']},
  1283. WEBHCAT: {site: [
  1284. {filename: 'webhcat-site', isXmlFile: true}
  1285. ], log4j: []},
  1286. HUE: {site: [
  1287. {filename: 'hue-site', isXmlFile: true}
  1288. ], log4j: []},
  1289. PIG: {site: [
  1290. {filename: 'pig-properties', isXmlFile: false}
  1291. ], log4j: ['pig']},
  1292. FALCON: {site: [
  1293. {filename: 'falcon-startup.properties', isXmlFile: false},
  1294. {filename: 'falcon-runtime.properties', isXmlFile: false}
  1295. ], log4j: []},
  1296. TEZ: {site: [
  1297. {filename: 'tez-site', isXmlFile: true}
  1298. ], log4j: []},
  1299. ZOOKEEPER: {site: [], log4j: ['zookeeper']},
  1300. FLUME: {site: [
  1301. {filename: 'flume-conf', isXmlFile: false}
  1302. ], log4j: []}
  1303. };
  1304. if (App.supports.capacitySchedulerUi) {
  1305. objMap['MAPREDUCE'].site.pushObjects([
  1306. {filename: 'capacity-scheduler', isXmlFile: true},
  1307. {filename: 'mapred-queue-acls', isXmlFile: true}
  1308. ]);
  1309. }
  1310. for (var serviceName in objMap) {
  1311. if (objMap.hasOwnProperty(serviceName)) {
  1312. if (selectedServices.someProperty('serviceName', serviceName)) {
  1313. objMap[serviceName].site.forEach(function (site) {
  1314. self.get('serviceConfigTags').pushObject(self.createSiteObj(site.filename, !site.isXmlFile, tag));
  1315. });
  1316. objMap[serviceName].log4j.forEach(function (log4j) {
  1317. self.get('serviceConfigTags').pushObject(self.createLog4jObj(log4j, tag));
  1318. });
  1319. }
  1320. }
  1321. }
  1322. if (selectedServices.someProperty('serviceName', 'STORM')) {
  1323. this.get('serviceConfigTags').pushObject(this.createStormSiteObj(tag));
  1324. }
  1325. if (selectedServices.someProperty('serviceName', 'ZOOKEEPER')) {
  1326. this.get('serviceConfigTags').pushObject(this.createZooCfgObj(tag));
  1327. }
  1328. },
  1329. /**
  1330. * Send <code>serviceConfigTags</code> to server
  1331. * Queued request
  1332. * One request for each service config tag
  1333. * @method applyConfigurationsToCluster
  1334. */
  1335. applyConfigurationsToCluster: function () {
  1336. var configData = this.get('serviceConfigTags').map(function (_serviceConfig) {
  1337. return JSON.stringify({
  1338. Clusters: {
  1339. desired_config: {
  1340. type: _serviceConfig.type,
  1341. tag: _serviceConfig.tag,
  1342. properties: _serviceConfig.properties
  1343. }
  1344. }
  1345. });
  1346. }, this).toString();
  1347. this.addRequestToAjaxQueue({
  1348. name: 'wizard.step8.apply_configuration_to_cluster',
  1349. data: {
  1350. data: '[' + configData + ']'
  1351. }
  1352. });
  1353. },
  1354. /**
  1355. * Create and update config groups
  1356. * @method createConfigurationGroups
  1357. */
  1358. createConfigurationGroups: function () {
  1359. var configGroups = this.get('content.configGroups').filterProperty('isDefault', false);
  1360. var clusterName = this.get('clusterName');
  1361. var sendData = [];
  1362. var updateData = [];
  1363. var serviceConfigController = App.router.get('mainServiceInfoConfigsController');
  1364. var timeTag = (new Date).getTime();
  1365. var groupsToDelete = App.router.get(this.get('content.controllerName')).getDBProperty('groupsToDelete');
  1366. if (groupsToDelete && groupsToDelete.length > 0) {
  1367. this.removeInstalledServicesConfigurationGroups(groupsToDelete);
  1368. }
  1369. configGroups.forEach(function (configGroup) {
  1370. var groupConfigs = [];
  1371. var groupData = {
  1372. "cluster_name": clusterName,
  1373. "group_name": configGroup.name,
  1374. "tag": configGroup.service.id,
  1375. "description": configGroup.description,
  1376. "hosts": [],
  1377. "desired_configs": []
  1378. };
  1379. configGroup.hosts.forEach(function (hostName) {
  1380. groupData.hosts.push({"host_name": hostName});
  1381. });
  1382. //wrap properties into Em.Object to make them compatible with buildGroupDesiredConfigs method
  1383. configGroup.properties.forEach(function (property) {
  1384. groupConfigs.push(Em.Object.create(property));
  1385. });
  1386. groupData.desired_configs = serviceConfigController.buildGroupDesiredConfigs.call(serviceConfigController, groupConfigs, timeTag);
  1387. // check for group from installed service
  1388. if (configGroup.isForUpdate === true) {
  1389. // if group is a new one, create it
  1390. if (!configGroup.id) {
  1391. sendData.push({"ConfigGroup": groupData});
  1392. } else {
  1393. // update an existing group
  1394. groupData.id = configGroup.id;
  1395. updateData.push({"ConfigGroup": groupData});
  1396. }
  1397. } else {
  1398. sendData.push({"ConfigGroup": groupData});
  1399. }
  1400. //each group should have unique tag to prevent overriding configs from common sites
  1401. timeTag++;
  1402. }, this);
  1403. if (sendData.length > 0) {
  1404. this.applyConfigurationGroups(sendData);
  1405. }
  1406. if (updateData.length > 0) {
  1407. this.applyInstalledServicesConfigurationGroup(updateData);
  1408. }
  1409. },
  1410. /**
  1411. * Create new config groups request
  1412. * Queued request
  1413. * @param {Object[]} sendData
  1414. * @method applyConfigurationGroups
  1415. */
  1416. applyConfigurationGroups: function (sendData) {
  1417. this.addRequestToAjaxQueue({
  1418. name: 'wizard.step8.apply_configuration_groups',
  1419. data: {
  1420. data: JSON.stringify(sendData)
  1421. }
  1422. });
  1423. },
  1424. /**
  1425. * Update existed config groups
  1426. * Separated request for each group
  1427. * @param {Object[]} updateData
  1428. * @method applyInstalledServicesConfigurationGroup
  1429. */
  1430. applyInstalledServicesConfigurationGroup: function (updateData) {
  1431. updateData.forEach(function (item) {
  1432. App.router.get('mainServiceInfoConfigsController').putConfigGroupChanges(item);
  1433. });
  1434. },
  1435. /**
  1436. * Delete selected config groups
  1437. * @param {Object[]} groupsToDelete
  1438. * @method removeInstalledServicesConfigurationGroups
  1439. */
  1440. removeInstalledServicesConfigurationGroups: function (groupsToDelete) {
  1441. groupsToDelete.forEach(function (item) {
  1442. App.config.deleteConfigGroup(Em.Object.create(item));
  1443. });
  1444. },
  1445. /**
  1446. * Create Global Site object
  1447. * @returns {{type: string, tag: string, properties: {}}}
  1448. * @method createGlobalSiteObj
  1449. */
  1450. createGlobalSiteObj: function (tag) {
  1451. var globalSiteProperties = {};
  1452. var globalSiteObj = this.get('globals');
  1453. var isGLUSTERFSSelected = this.get('selectedServices').someProperty('serviceName', 'GLUSTERFS');
  1454. // screen out the GLUSTERFS-specific global config entries when they are not required
  1455. if (!isGLUSTERFSSelected) {
  1456. globalSiteObj = globalSiteObj.filter(function (_config) {
  1457. return !_config.name.contains("fs_glusterfs");
  1458. });
  1459. }
  1460. globalSiteObj.forEach(function (globalConfig) {
  1461. var heapsizeExceptions = ['hadoop_heapsize', 'yarn_heapsize', 'nodemanager_heapsize', 'resourcemanager_heapsize', 'apptimelineserver_heapsize', 'jobhistory_heapsize'];
  1462. // do not pass any globals whose name ends with _host or _hosts
  1463. if (globalConfig.isRequiredByAgent !== false) {
  1464. // append "m" to JVM memory options except for heapsizeExtensions
  1465. if (/_heapsize|_newsize|_maxnewsize$/.test(globalConfig.name) && !heapsizeExceptions.contains(globalConfig.name)) {
  1466. globalSiteProperties[globalConfig.name] = globalConfig.value + "m";
  1467. } else {
  1468. globalSiteProperties[globalConfig.name] = App.config.escapeXMLCharacters(globalConfig.value);
  1469. }
  1470. }
  1471. }, this);
  1472. // we don't expose gmond_user to the user; it needs to be the same as gmetad_user
  1473. globalSiteProperties['gmond_user'] = globalSiteProperties['gmetad_user'];
  1474. return {"type": "global", "tag": tag, "properties": globalSiteProperties};
  1475. },
  1476. /**
  1477. * Create Core Site object
  1478. * @returns {{type: string, tag: string, properties: {}}}
  1479. * @method createCoreSiteObj
  1480. */
  1481. createCoreSiteObj: function () {
  1482. var coreSiteObj = this.get('configs').filterProperty('filename', 'core-site.xml'),
  1483. coreSiteProperties = {},
  1484. // some configs needs to be skipped if services are not selected
  1485. isOozieSelected = this.get('selectedServices').someProperty('serviceName', 'OOZIE'),
  1486. oozieUser = this.get('globals').someProperty('name', 'oozie_user') ? this.get('globals').findProperty('name', 'oozie_user').value : null,
  1487. isHiveSelected = this.get('selectedServices').someProperty('serviceName', 'HIVE'),
  1488. hiveUser = this.get('globals').someProperty('name', 'hive_user') ? this.get('globals').findProperty('name', 'hive_user').value : null,
  1489. isHcatSelected = this.get('selectedServices').someProperty('serviceName', 'WEBHCAT'),
  1490. hcatUser = this.get('globals').someProperty('name', 'hcat_user') ? this.get('globals').findProperty('name', 'hcat_user').value : null,
  1491. isGLUSTERFSSelected = this.get('selectedServices').someProperty('serviceName', 'GLUSTERFS');
  1492. // screen out the GLUSTERFS-specific core-site.xml entries when they are not needed
  1493. if (!isGLUSTERFSSelected) {
  1494. coreSiteObj = coreSiteObj.filter(function (_config) {
  1495. return !_config.name.contains("fs.glusterfs");
  1496. });
  1497. }
  1498. coreSiteObj.forEach(function (_coreSiteObj) {
  1499. // exclude some configs if service wasn't selected
  1500. if (
  1501. (isOozieSelected || (_coreSiteObj.name != 'hadoop.proxyuser.' + oozieUser + '.hosts' && _coreSiteObj.name != 'hadoop.proxyuser.' + oozieUser + '.groups')) &&
  1502. (isHiveSelected || (_coreSiteObj.name != 'hadoop.proxyuser.' + hiveUser + '.hosts' && _coreSiteObj.name != 'hadoop.proxyuser.' + hiveUser + '.groups')) &&
  1503. (isHcatSelected || (_coreSiteObj.name != 'hadoop.proxyuser.' + hcatUser + '.hosts' && _coreSiteObj.name != 'hadoop.proxyuser.' + hcatUser + '.groups'))) {
  1504. coreSiteProperties[_coreSiteObj.name] = App.config.escapeXMLCharacters(_coreSiteObj.value);
  1505. }
  1506. if (isGLUSTERFSSelected && _coreSiteObj.name == "fs.default.name") {
  1507. coreSiteProperties[_coreSiteObj.name] =
  1508. this.get('globals').someProperty('name', 'fs_glusterfs_default_name') ?
  1509. App.config.escapeXMLCharacters(this.get('globals').findProperty('name', 'fs_glusterfs_default_name').value) : null;
  1510. }
  1511. if (isGLUSTERFSSelected && _coreSiteObj.name == "fs.defaultFS") {
  1512. coreSiteProperties[_coreSiteObj.name] =
  1513. this.get('globals').someProperty('name', 'glusterfs_defaultFS_name') ?
  1514. App.config.escapeXMLCharacters(this.get('globals').findProperty('name', 'glusterfs_defaultFS_name').value) : null;
  1515. }
  1516. }, this);
  1517. return {"type": "core-site", "tag": "version1", "properties": coreSiteProperties};
  1518. },
  1519. /**
  1520. * Create siteObj for custom service with it own configs
  1521. * @param {string} site
  1522. * @param {bool} isNonXmlFile
  1523. * @param tag
  1524. * @returns {{type: string, tag: string, properties: {}}}
  1525. * @method createSiteObj
  1526. */
  1527. createSiteObj: function (site, isNonXmlFile, tag) {
  1528. var properties = {};
  1529. if (!!isNonXmlFile) {
  1530. this.get('configs').filterProperty('filename', site + '.xml').forEach(function (_configProperty) {
  1531. properties[_configProperty.name] = _configProperty.value;
  1532. }, this);
  1533. } else {
  1534. this.get('configs').filterProperty('filename', site + '.xml').forEach(function (_configProperty) {
  1535. properties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1536. }, this);
  1537. }
  1538. return {"type": site, "tag": tag, "properties": properties };
  1539. },
  1540. /**
  1541. * Create log4j object for custom service with it own configs
  1542. * @param {string} site
  1543. * @param {string} tag
  1544. * @returns {{type: string, tag: string, properties: {}}}
  1545. * @method createLog4jObj
  1546. */
  1547. createLog4jObj: function (site, tag) {
  1548. return this.createSiteObj(site + '-log4j', true, tag);
  1549. },
  1550. /**
  1551. * Create ZooKeeper Cfg Object
  1552. * @param tag
  1553. * @returns {{type: string, tag: string, properties: {}}}
  1554. * @method createZooCfgObj
  1555. */
  1556. createZooCfgObj: function (tag) {
  1557. var configs = this.get('configs').filterProperty('filename', 'zoo.cfg');
  1558. var csProperties = {};
  1559. configs.forEach(function (_configProperty) {
  1560. csProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1561. }, this);
  1562. return {type: 'zoo.cfg', tag: tag, properties: csProperties};
  1563. },
  1564. /**
  1565. * Create site obj for Storm
  1566. * Some config-properties should be modified in custom way
  1567. * @param tag
  1568. * @returns {{type: string, tag: string, properties: {}}}
  1569. * @method createStormSiteObj
  1570. */
  1571. createStormSiteObj: function (tag) {
  1572. var configs = this.get('configs').filterProperty('filename', 'storm-site.xml');
  1573. var stormProperties = {};
  1574. var specialProperties = ["storm.zookeeper.servers", "nimbus.childopts", "supervisor.childopts", "worker.childopts"];
  1575. configs.forEach(function (_configProperty) {
  1576. if (specialProperties.contains(_configProperty.name)) {
  1577. if (_configProperty.name == "storm.zookeeper.servers") {
  1578. stormProperties[_configProperty.name] = JSON.stringify(_configProperty.value).replace(/"/g, "'");
  1579. } else {
  1580. stormProperties[_configProperty.name] = JSON.stringify(_configProperty.value).replace(/"/g, "");
  1581. }
  1582. } else {
  1583. stormProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1584. }
  1585. }, this);
  1586. return {type: 'storm-site', tag: tag, properties: stormProperties};
  1587. },
  1588. /**
  1589. * Navigate to next step after all requests are sent
  1590. * @method ajaxQueueFinished
  1591. */
  1592. ajaxQueueFinished: function () {
  1593. console.log('everything is loaded');
  1594. App.router.send('next');
  1595. },
  1596. /**
  1597. * We need to do a lot of ajax calls async in special order. To do this,
  1598. * generate array of ajax objects and then send requests step by step. All
  1599. * ajax objects are stored in <code>ajaxRequestsQueue</code>
  1600. *
  1601. * @param {Object} params object with ajax-request parameters like url, type, data etc
  1602. * @method addRequestToAjaxQueue
  1603. */
  1604. addRequestToAjaxQueue: function (params) {
  1605. if (App.get('testMode')) return;
  1606. params = jQuery.extend({
  1607. sender: this,
  1608. error: 'ajaxQueueRequestErrorCallback'
  1609. }, params);
  1610. params.data['cluster'] = this.get('clusterName');
  1611. this.get('ajaxRequestsQueue').addRequest(params);
  1612. },
  1613. /**
  1614. * Error callback for each queued ajax-request
  1615. * @param {object} xhr
  1616. * @param {string} status
  1617. * @param {string} error
  1618. * @method ajaxQueueRequestErrorCallback
  1619. */
  1620. ajaxQueueRequestErrorCallback: function (xhr, status, error) {
  1621. var responseText = JSON.parse(xhr.responseText);
  1622. var controller = App.router.get(App.clusterStatus.wizardControllerName);
  1623. controller.registerErrPopup(Em.I18n.t('common.error'), responseText.message);
  1624. this.set('hasErrorOccurred', true);
  1625. // an error will break the ajax call chain and allow submission again
  1626. this.set('isSubmitDisabled', false);
  1627. this.set('isBackBtnDisabled', false);
  1628. App.router.get(this.get('content.controllerName')).setStepsEnable();
  1629. }
  1630. });