step8_controller.js 62 KB

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