step8_controller.js 64 KB

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