step8_controller.js 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563
  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. rawContent: require('data/review_configs'),
  23. totalHosts: [],
  24. clusterInfo: [],
  25. services: [],
  26. configs: [],
  27. globals: [],
  28. ajaxQueue: [],
  29. configMapping: function(){
  30. return App.config.get('configMapping').all(true);
  31. }.property('App.config.configMapping'),
  32. slaveComponentConfig: null,
  33. isSubmitDisabled: false,
  34. isBackBtnDisabled: false,
  35. hasErrorOccurred: false,
  36. servicesInstalled: false,
  37. serviceConfigTags: [],
  38. securityEnabled: function() {
  39. return App.router.get('mainAdminSecurityController.securityEnabled');
  40. }.property('App.router.mainAdminSecurityController.securityEnabled'),
  41. /**
  42. * During page save time, we set the host overrides to the server.
  43. * The new host -> site:tag map is stored below. This will be
  44. * useful during save, to update the host's host components. Also,
  45. * it will be useful in deletion of overrides.
  46. *
  47. * Example:
  48. * {
  49. * 'hostname1': {
  50. * 'global': {
  51. * 'tagName': 'tag3187261938_hostname1',
  52. * 'map': {
  53. * 'hadoop_heapsize': '2048m'
  54. * }
  55. * }
  56. * }
  57. * }
  58. *
  59. * @see loadedHostToOverrideSiteToTagMap
  60. */
  61. savedHostToOverrideSiteToTagMap: {},
  62. selectedConfigGroup: null,
  63. configGroups: [],
  64. selectedServices: function () {
  65. return this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false);
  66. }.property('content.services').cacheable(),
  67. clearStep: function () {
  68. this.get('services').clear();
  69. this.get('configs').clear();
  70. this.get('globals').clear();
  71. this.get('clusterInfo').clear();
  72. this.get('serviceConfigTags').clear();
  73. this.set('servicesInstalled', false);
  74. },
  75. loadStep: function () {
  76. console.log("TRACE: Loading step8: Review Page");
  77. if (this.get('content.controllerName') != 'installerController') {
  78. App.router.get('mainAdminSecurityController').setSecurityStatus();
  79. }
  80. this.clearStep();
  81. if (this.get('content.serviceConfigProperties')) {
  82. this.formatProperties();
  83. this.loadGlobals();
  84. this.loadConfigs();
  85. }
  86. this.loadClusterInfo();
  87. this.loadServices();
  88. this.set('isSubmitDisabled', false);
  89. this.set('isBackBtnDisabled', false);
  90. },
  91. /**
  92. * replace whitespace character with coma between directories
  93. */
  94. formatProperties: function(){
  95. this.get('content.serviceConfigProperties').forEach(function(_configProperty){
  96. _configProperty.value = App.config.trimProperty(_configProperty,false);
  97. });
  98. },
  99. loadGlobals: function () {
  100. var globals = this.get('content.serviceConfigProperties').filterProperty('id', 'puppet var');
  101. if (globals.someProperty('name', 'hive_database')) {
  102. var hiveDb = globals.findProperty('name', 'hive_database');
  103. var hiveDbType = {name: 'hive_database_type', value: 'mysql'};
  104. var hiveJdbcDriver = {name: 'hive_jdbc_driver'};
  105. if (hiveDb.value === 'New MySQL Database') {
  106. if (globals.someProperty('name', 'hive_ambari_host')) {
  107. globals.findProperty('name', 'hive_hostname').value = globals.findProperty('name', 'hive_ambari_host').value;
  108. hiveDbType.value = 'mysql';
  109. hiveJdbcDriver.value = 'com.mysql.jdbc.Driver';
  110. }
  111. globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_host'));
  112. globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_database'));
  113. globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_host'));
  114. globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_database'));
  115. } else if (hiveDb.value === 'Existing MySQL Database'){
  116. globals.findProperty('name', 'hive_hostname').value = globals.findProperty('name', 'hive_existing_mysql_host').value;
  117. hiveDbType.value = 'mysql';
  118. hiveJdbcDriver.value = 'com.mysql.jdbc.Driver';
  119. globals = globals.without(globals.findProperty('name', 'hive_ambari_host'));
  120. globals = globals.without(globals.findProperty('name', 'hive_ambari_database'));
  121. globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_host'));
  122. globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_database'));
  123. } else { //existing oracle database
  124. globals.findProperty('name', 'hive_hostname').value = globals.findProperty('name', 'hive_existing_oracle_host').value;
  125. hiveDbType.value = 'oracle';
  126. hiveJdbcDriver.value = 'oracle.jdbc.driver.OracleDriver';
  127. globals = globals.without(globals.findProperty('name', 'hive_ambari_host'));
  128. globals = globals.without(globals.findProperty('name', 'hive_ambari_database'));
  129. globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_host'));
  130. globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_database'));
  131. }
  132. globals.push(hiveDbType);
  133. globals.push(hiveJdbcDriver);
  134. }
  135. if (globals.someProperty('name', 'oozie_database')) {
  136. var oozieDb = globals.findProperty('name', 'oozie_database');
  137. var oozieDbType = {name:'oozie_database_type'};
  138. var oozieJdbcDriver = {name: 'oozie_jdbc_driver'};
  139. if (oozieDb.value === 'New Derby Database') {
  140. globals.findProperty('name', 'oozie_hostname').value = globals.findProperty('name', 'oozie_ambari_host').value;
  141. oozieDbType.value = 'derby';
  142. oozieJdbcDriver.value = 'org.apache.derby.jdbc.EmbeddedDriver';
  143. globals = globals.without(globals.findProperty('name', 'oozie_ambari_host'));
  144. globals = globals.without(globals.findProperty('name', 'oozie_ambari_database'));
  145. globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_host'));
  146. globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_database'));
  147. globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_host'));
  148. globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_database'));
  149. } else if (oozieDb.value === 'Existing MySQL Database') {
  150. globals.findProperty('name', 'oozie_hostname').value = globals.findProperty('name', 'oozie_existing_mysql_host').value;
  151. oozieDbType.value = 'mysql';
  152. oozieJdbcDriver.value = 'com.mysql.jdbc.Driver';
  153. globals = globals.without(globals.findProperty('name', 'oozie_ambari_host'));
  154. globals = globals.without(globals.findProperty('name', 'oozie_ambari_database'));
  155. globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_host'));
  156. globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_database'));
  157. globals = globals.without(globals.findProperty('name', 'oozie_derby_database'));
  158. } else { // existing oracle database
  159. globals.findProperty('name', 'oozie_hostname').value = globals.findProperty('name', 'oozie_existing_oracle_host').value;
  160. oozieDbType.value = 'oracle';
  161. oozieJdbcDriver.value = 'oracle.jdbc.driver.OracleDriver';
  162. globals = globals.without(globals.findProperty('name', 'oozie_ambari_host'));
  163. globals = globals.without(globals.findProperty('name', 'oozie_ambari_database'));
  164. globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_host'));
  165. globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_database'));
  166. globals = globals.without(globals.findProperty('name', 'oozie_derby_database'));
  167. }
  168. globals.push(oozieDbType);
  169. globals.push(oozieJdbcDriver);
  170. }
  171. this.set('globals', globals);
  172. },
  173. loadConfigs: function () {
  174. //storedConfigs contains custom configs as well
  175. var serviceConfigProperties = this.get('content.serviceConfigProperties').filterProperty('id', 'site property');
  176. serviceConfigProperties.forEach(function(_config){
  177. _config.value = (typeof _config.value === "boolean") ? _config.value.toString() : _config.value;
  178. });
  179. var storedConfigs = serviceConfigProperties.filterProperty('value');
  180. var uiConfigs = this.loadUiSideConfigs();
  181. this.set('configs', storedConfigs.concat(uiConfigs));
  182. },
  183. loadUiSideConfigs: function () {
  184. var uiConfig = [];
  185. var configs = this.get('configMapping').filterProperty('foreignKey', null);
  186. this.addDynamicProperties(configs);
  187. configs.forEach(function (_config) {
  188. var valueWithOverrides = this.getGlobConfigValueWithOverrides(_config.templateName, _config.value, _config.name);
  189. uiConfig.pushObject({
  190. "id": "site property",
  191. "name": _config.name,
  192. "value": valueWithOverrides.value,
  193. "filename": _config.filename,
  194. "overrides": valueWithOverrides.overrides
  195. });
  196. }, this);
  197. var dependentConfig = $.extend(true, [], this.get('configMapping').filterProperty('foreignKey'));
  198. dependentConfig.forEach(function (_config) {
  199. App.config.setConfigValue(uiConfig, this.get('content.serviceConfigProperties'), _config, this.get('globals'));
  200. uiConfig.pushObject({
  201. "id": "site property",
  202. "name": _config._name || _config.name,
  203. "value": _config.value,
  204. "filename": _config.filename
  205. });
  206. }, this);
  207. return uiConfig;
  208. },
  209. addDynamicProperties: function(configs) {
  210. var templetonHiveProperty = this.get('content.serviceConfigProperties').someProperty('name', 'templeton.hive.properties');
  211. if (!templetonHiveProperty) {
  212. configs.pushObject({
  213. "name": "templeton.hive.properties",
  214. "templateName": ["hivemetastore_host"],
  215. "foreignKey": null,
  216. "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",
  217. "filename": "webhcat-site.xml"
  218. });
  219. }
  220. },
  221. getRegisteredHosts: function () {
  222. var allHosts = this.get('content.hosts');
  223. var hosts = [];
  224. for (var hostName in allHosts) {
  225. if (allHosts[hostName].bootStatus == 'REGISTERED') {
  226. allHosts[hostName].hostName = allHosts[hostName].name;
  227. hosts.pushObject(allHosts[hostName]);
  228. }
  229. }
  230. return hosts;
  231. },
  232. /**
  233. * Set all site property that are derived from other puppet-variable
  234. * @param {String} templateName
  235. * @param {String} expression
  236. * @param {String} name
  237. * @return {Object}
  238. * example: <code>{
  239. * value: '...',
  240. * overrides: {
  241. * 'value1': [h1, h2],
  242. * 'value2': [h3]
  243. * }
  244. * }</code>
  245. */
  246. getGlobConfigValueWithOverrides: function (templateName, expression, name) {
  247. var express = expression.match(/<(.*?)>/g);
  248. var value = expression;
  249. if (express == null) {
  250. return { value : expression, overrides: []}; // if site property do not map any global property then return the value
  251. }
  252. var overrideHostToValue = {};
  253. express.forEach(function (_express) {
  254. //console.log("The value of template is: " + _express);
  255. var index = parseInt(_express.match(/\[([\d]*)(?=\])/)[1]);
  256. if (this.get('globals').someProperty('name', templateName[index])) {
  257. //console.log("The name of the variable is: " + this.get('content.serviceConfigProperties').findProperty('name', templateName[index]).name);
  258. var globalObj = this.get('globals').findProperty('name', templateName[index]);
  259. var globValue = globalObj.value;
  260. // Hack for templeton.zookeeper.hosts
  261. var preReplaceValue = null;
  262. 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
  263. preReplaceValue = value;
  264. value = this._replaceConfigValues(name, _express, value, globValue);
  265. }
  266. if(globalObj.overrides!=null){
  267. globalObj.overrides.forEach(function(override){
  268. var ov = override.value;
  269. var hostsArray = override.hosts;
  270. hostsArray.forEach(function(host){
  271. if(!(host in overrideHostToValue)){
  272. overrideHostToValue[host] = this._replaceConfigValues(name, _express, preReplaceValue, ov);
  273. }else{
  274. overrideHostToValue[host] = this._replaceConfigValues(name, _express, overrideHostToValue[host], ov);
  275. }
  276. }, this);
  277. }, this);
  278. }
  279. } else {
  280. /*
  281. console.log("ERROR: The variable name is: " + templateName[index]);
  282. console.log("ERROR: mapped config from configMapping file has no corresponding variable in " +
  283. "content.serviceConfigProperties. Two possible reasons for the error could be: 1) The service is not selected. " +
  284. "and/OR 2) The service_config metadata file has no corresponding global var for the site property variable");
  285. */
  286. value = null;
  287. }
  288. }, this);
  289. var valueWithOverrides = {
  290. value: value,
  291. overrides: []
  292. };
  293. var overrideValueToHostMap = {};
  294. if(!jQuery.isEmptyObject(overrideHostToValue)){
  295. for(var host in overrideHostToValue){
  296. var hostVal = overrideHostToValue[host];
  297. if(!(hostVal in overrideValueToHostMap)){
  298. overrideValueToHostMap[hostVal] = [];
  299. }
  300. overrideValueToHostMap[hostVal].push(host);
  301. }
  302. }
  303. for(var val in overrideValueToHostMap){
  304. valueWithOverrides.overrides.push({
  305. value: val,
  306. hosts: overrideValueToHostMap[val]
  307. });
  308. }
  309. return valueWithOverrides;
  310. },
  311. _replaceConfigValues: function (name, express, value, globValue) {
  312. return value.replace(express, globValue);
  313. },
  314. /**
  315. * Load all info about cluster to <code>clusterInfo</code> variable
  316. */
  317. loadClusterInfo: function () {
  318. //Admin name
  319. var admin = this.rawContent.findProperty('config_name', 'Admin');
  320. admin.config_value = App.db.getLoginName();
  321. console.log("STEP8: the value of content cluster name: " + App.db.getLoginName());
  322. if (admin.config_value) {
  323. this.get('clusterInfo').pushObject(Ember.Object.create(admin));
  324. }
  325. // cluster name
  326. var cluster = this.rawContent.findProperty('config_name', 'cluster');
  327. cluster.config_value = this.get('content.cluster.name');
  328. console.log("STEP8: the value of content cluster name: " + this.get('content.cluster.name'));
  329. this.get('clusterInfo').pushObject(Ember.Object.create(cluster));
  330. //hosts
  331. var masterHosts = this.get('content.masterComponentHosts').mapProperty('hostName').uniq();
  332. var slaveHosts = this.get('content.slaveComponentHosts');
  333. var hostObj = [];
  334. slaveHosts.forEach(function (_hosts) {
  335. hostObj = hostObj.concat(_hosts.hosts);
  336. }, this);
  337. slaveHosts = hostObj.mapProperty('hostName').uniq();
  338. var componentHosts = masterHosts.concat(slaveHosts).uniq();
  339. var totalHosts = App.Host.find().mapProperty('hostName').concat(componentHosts).uniq();
  340. var newHostsCount = totalHosts.length - App.Host.find().content.length;
  341. this.set('totalHosts', totalHosts);
  342. var totalHostsObj = this.rawContent.findProperty('config_name', 'hosts');
  343. totalHostsObj.config_value = totalHosts.length + ' (' + newHostsCount + ' new)';
  344. this.get('clusterInfo').pushObject(Ember.Object.create(totalHostsObj));
  345. //repo
  346. if (['addHostController', 'addServiceController'].contains(this.get('content.controllerName'))) {
  347. this.loadRepoInfo();
  348. } else { // from install wizard
  349. var selectedStack = this.get('content.stacks').findProperty('isSelected', true);
  350. var allRepos = [];
  351. var supportedOs = ['redhat5', 'redhat6', 'sles11'];
  352. if (selectedStack && selectedStack.operatingSystems) {
  353. selectedStack.operatingSystems.forEach(function (os) {
  354. if (os.selected && supportedOs.contains(os.osType)) {
  355. allRepos.push(Em.Object.create({
  356. base_url: os.baseUrl,
  357. os_type: Em.I18n.t("installer.step8.repoInfo.osType." + os.osType)
  358. }));
  359. }
  360. }, this);
  361. }
  362. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  363. this.get('clusterInfo').set('repoInfo', allRepos);
  364. }
  365. },
  366. /**
  367. * get the repositories info of HDP from server. Used only in addHost controller.
  368. */
  369. loadRepoInfo: function(){
  370. var nameVersionCombo = App.get('currentStackVersion');
  371. var stackName = nameVersionCombo.split('-')[0];
  372. var stackVersion = nameVersionCombo.split('-')[1];
  373. App.ajax.send({
  374. name: 'cluster.load_repositories',
  375. sender: this,
  376. data: {
  377. stackName: stackName,
  378. stackVersion: stackVersion
  379. },
  380. success: 'loadRepoInfoSuccessCallback',
  381. error: 'loadRepositoriesErrorCallback'
  382. });
  383. },
  384. loadRepoInfoSuccessCallback: function (data) {
  385. var allRepos = [];
  386. var supportedOs = ['redhat5', 'redhat6', 'sles11'];
  387. data.items.forEach(function (item) {
  388. var os = item.repositories[0].Repositories;
  389. if (supportedOs.contains(os.osType)) {
  390. allRepos.push(Em.Object.create({
  391. base_url: os.base_url,
  392. os_type: Em.I18n.t("installer.step8.repoInfo.osType." + os.os_type)
  393. }));
  394. }
  395. }, this);
  396. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  397. this.get('clusterInfo').set('repoInfo', allRepos);
  398. },
  399. loadRepoInfoErrorCallback: function(request, ajaxOptions, error) {
  400. console.log('Error message is: ' + request.responseText);
  401. var allRepos = [];
  402. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  403. this.get('clusterInfo').set('repoInfo', allRepos);
  404. },
  405. /**
  406. * Load all info about services to <code>services</code> variable
  407. */
  408. loadServices: function () {
  409. var reviewService = this.rawContent.findProperty('config_name', 'services');
  410. this.get('selectedServices').forEach(function (_service) {
  411. console.log('INFO: step8: Name of the service from getService function: ' + _service.serviceName);
  412. var serviceObj = reviewService.config_value.findProperty('service_name', _service.serviceName);
  413. if (serviceObj) {
  414. serviceObj.get('service_components').forEach(function (_component) {
  415. this.assignComponentHosts(_component);
  416. }, this);
  417. this.get('services').pushObject(serviceObj);
  418. }
  419. }, this);
  420. },
  421. assignComponentHosts: function (component) {
  422. var componentValue;
  423. if (component.get('customHandler')) {
  424. this[component.get('customHandler')].call(this, component);
  425. } else {
  426. if (component.get('isMaster')) {
  427. componentValue = this.get('content.masterComponentHosts')
  428. .findProperty('component', component.component_name).hostName;
  429. } else {
  430. var hostsLength = this.get('content.slaveComponentHosts')
  431. .findProperty('componentName', component.component_name)
  432. .hosts.length;
  433. componentValue = hostsLength + Em.I18n.t('installer.step8.host' + ((hostsLength > 1) ? 's' : ''));
  434. }
  435. component.set('component_value', componentValue);
  436. }
  437. },
  438. loadHiveDbValue: function (dbComponent) {
  439. var hiveDb = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'hive_database');
  440. if (hiveDb.value === 'New MySQL Database') {
  441. dbComponent.set('component_value', 'MySQL (New Database)');
  442. } else if(hiveDb.value === 'Existing MySQL Database'){
  443. var db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'hive_existing_mysql_database');
  444. dbComponent.set('component_value', db.value + ' (' + hiveDb.value + ')');
  445. } else { // existing oracle database
  446. var db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'hive_existing_oracle_database');
  447. dbComponent.set('component_value', db.value + ' (' + hiveDb.value + ')');
  448. }
  449. },
  450. loadHbaseMasterValue: function (hbaseMaster) {
  451. var hbaseHostName = this.get('content.masterComponentHosts').filterProperty('component', hbaseMaster.component_name);
  452. if (hbaseHostName.length == 1) {
  453. hbaseMaster.set('component_value', hbaseHostName[0].hostName);
  454. } else {
  455. hbaseMaster.set('component_value', hbaseHostName[0].hostName + Em.I18n.t('installer.step8.other').format(hbaseHostName.length - 1));
  456. }
  457. },
  458. loadZkServerValue: function (serverComponent) {
  459. var zkHostNames = this.get('content.masterComponentHosts').filterProperty('component', serverComponent.component_name).length;
  460. var hostSuffix;
  461. if (zkHostNames === 1) {
  462. hostSuffix = Em.I18n.t('installer.step8.host');
  463. } else {
  464. hostSuffix = Em.I18n.t('installer.step8.hosts');
  465. }
  466. serverComponent.set('component_value', zkHostNames + ' ' + hostSuffix);
  467. },
  468. loadOozieDbValue: function (dbComponent) {
  469. var oozieDb = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_database');
  470. if (oozieDb.value === 'New Derby Database'){
  471. var db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_derby_database');
  472. dbComponent.set('component_value', db.value + ' (' + oozieDb.value + ')');
  473. }/* else if (oozieDb.value === 'New MySQL Database') {
  474. dbComponent.set('component_value', 'MySQL (New Database)');
  475. } */else if(oozieDb.value === 'Existing MySQL Database'){
  476. var db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_mysql_database');
  477. dbComponent.set('component_value', db.value + ' (' + oozieDb.value + ')');
  478. } else { // existing oracle database
  479. var db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_oracle_database');
  480. dbComponent.set('component_value', db.value + ' (' + oozieDb.value + ')');
  481. }
  482. },
  483. loadNagiosAdminValue: function (nagiosAdmin) {
  484. var config = this.get('content.serviceConfigProperties');
  485. var adminLoginName = config.findProperty('name', 'nagios_web_login');
  486. var adminEmail = config.findProperty('name', 'nagios_contact');
  487. nagiosAdmin.set('component_value', adminLoginName.value + ' / (' + adminEmail.value + ')');
  488. },
  489. /**
  490. * Onclick handler for <code>next</code> button
  491. */
  492. submit: function () {
  493. if (this.get('isSubmitDisabled')) {
  494. return;
  495. }
  496. if ((this.get('content.controllerName') == 'addHostController') && this.get('securityEnabled')) {
  497. var self = this;
  498. App.showConfirmationPopup(function() {
  499. self.submitProceed();
  500. }, Em.I18n.t('installer.step8.securityConfirmationPopupBody'));
  501. }
  502. else {
  503. this.submitProceed();
  504. }
  505. },
  506. submitProceed: function() {
  507. this.set('isSubmitDisabled', true);
  508. this.set('isBackBtnDisabled', true);
  509. if (this.get('content.controllerName') == 'addHostController') {
  510. App.router.get('addHostController').setLowerStepsDisable(4);
  511. }
  512. // checkpoint the cluster status on the server so that the user can resume from where they left off
  513. switch (this.get('content.controllerName')) {
  514. case 'installerController':
  515. App.clusterStatus.setClusterStatus({
  516. clusterName: this.get('clusterName'),
  517. clusterState: 'CLUSTER_DEPLOY_PREP_2',
  518. wizardControllerName: this.get('content.controllerName'),
  519. localdb: App.db.data
  520. });
  521. break;
  522. case 'addHostController':
  523. App.clusterStatus.setClusterStatus({
  524. clusterName: this.get('clusterName'),
  525. clusterState: 'ADD_HOSTS_DEPLOY_PREP_2',
  526. wizardControllerName: this.get('content.controllerName'),
  527. localdb: App.db.data
  528. });
  529. break;
  530. case 'addServiceController':
  531. App.clusterStatus.setClusterStatus({
  532. clusterName: this.get('clusterName'),
  533. clusterState: 'ADD_SERVICES_DEPLOY_PREP_2',
  534. wizardControllerName: this.get('content.controllerName'),
  535. localdb: App.db.data
  536. });
  537. break;
  538. default:
  539. break;
  540. }
  541. // delete any existing clusters to start from a clean slate
  542. // before creating a new cluster in install wizard
  543. // TODO: modify for multi-cluster support
  544. if (this.get('content.controllerName') == 'installerController' && (!App.testMode)) {
  545. var clusterNames = this.getExistingClusterNames();
  546. this.deleteClusters(clusterNames);
  547. }
  548. this.setLocalRepositories();
  549. this.createCluster();
  550. this.createSelectedServices();
  551. this.createConfigurations();
  552. this.createComponents();
  553. this.registerHostsToCluster();
  554. if (App.supports.hostOverridesInstaller) {
  555. this.createConfigurationGroups();
  556. }
  557. this.createAllHostComponents();
  558. this.createHostOverrideConfigurations();
  559. this.ajaxQueueFinished = function () {
  560. console.log('everything is loaded');
  561. App.router.send('next');
  562. };
  563. this.doNextAjaxCall();
  564. },
  565. /**
  566. * Used in progress bar
  567. */
  568. ajaxQueueLength: function () {
  569. return this.get('ajaxQueue').length;
  570. }.property('ajaxQueue.length'),
  571. /**
  572. * Used in progress bar
  573. */
  574. ajaxQueueLeft: 0,
  575. setAmbariUIDb: function () {
  576. var dbContent = this.get('content.slaveGroupProperties');
  577. var slaveComponentConfig = this.get("slaveComponentConfig");
  578. this.persistKeyValues(slaveComponentConfig.version, dbContent);
  579. this.persistKeyValues('current_version', slaveComponentConfig.version);
  580. },
  581. persistKeyValues: function (key, value) {
  582. var str = "{ '" + key + "' : '" + JSON.stringify(value) + "'}";
  583. var obj = eval("(" + str + ")");
  584. this.ajax({
  585. type: "POST",
  586. url: App.apiPrefix + '/persist',
  587. data: JSON.stringify(obj),
  588. beforeSend: function () {
  589. console.log('BeforeSend: persistKeyValues', obj);
  590. }
  591. });
  592. },
  593. clusterName: function () {
  594. return this.get('content.cluster.name');
  595. }.property('content.cluster.name'),
  596. clusterNames: [],
  597. // returns an array of existing cluster names.
  598. // returns an empty array if there are no existing clusters.
  599. getExistingClusterNames: function () {
  600. var url = App.apiPrefix + '/clusters';
  601. App.ajax.send({
  602. name: 'wizard.step8.existing_cluster_names',
  603. sender: this,
  604. success: 'getExistingClusterNamesSuccessCallBack',
  605. error: 'getExistingClusterNamesErrorCallback'
  606. });
  607. return this.get('clusterNames');
  608. },
  609. getExistingClusterNamesSuccessCallBack: function (data) {
  610. var clusterNames = data.items.mapProperty('Clusters.cluster_name');
  611. console.log("Got existing cluster names: " + clusterNames);
  612. this.set('clusterNames', clusterNames);
  613. },
  614. getExistingClusterNamesErrorCallback: function () {
  615. console.log("Failed to get existing cluster names");
  616. this.set('clusterNames', []);
  617. },
  618. deleteClusters: function (clusterNames) {
  619. clusterNames.forEach(function (clusterName) {
  620. App.ajax.send({
  621. name: 'wizard.step8.delete_cluster',
  622. sender: this,
  623. data: {
  624. name: clusterName
  625. },
  626. success: 'deleteClustersSuccessCallback',
  627. error: 'deleteClustersErrorCallback'
  628. });
  629. }, this);
  630. },
  631. deleteClustersSuccessCallback: function(data, opt, params) {
  632. console.log('DELETE cluster ' + params.name + ' succeeded');
  633. },
  634. deleteClustersErrorCallback: function(request, ajaxOptions, error, opt) {
  635. console.log('DELETE cluster failed');
  636. },
  637. /**
  638. * Updates local repositories for the Ambari server.
  639. */
  640. setLocalRepositories: function () {
  641. if (this.get('content.controllerName') !== 'installerController' || !App.supports.localRepositories) {
  642. return false;
  643. }
  644. var self = this;
  645. var apiUrl = App.get('stack2VersionURL');
  646. var stacks = this.get('content.stacks');
  647. stacks.forEach(function (stack) {
  648. stack.operatingSystems.forEach(function (os) {
  649. if (os.baseUrl !== os.originalBaseUrl) {
  650. console.log("Updating local repository URL from " + os.originalBaseUrl + " -> " + os.baseUrl + ". ", os);
  651. var url = App.apiPrefix + apiUrl + "/operatingSystems/" + os.osType + "/repositories/" + stack.name;
  652. self.ajax({
  653. type: 'PUT',
  654. url: url,
  655. data: JSON.stringify({
  656. "Repositories": {
  657. "base_url": os.baseUrl
  658. }
  659. }),
  660. beforeSend: function () {
  661. console.log("BeforeSend: setLocalRepositories PUT to ", url);
  662. }
  663. });
  664. }
  665. });
  666. });
  667. },
  668. /**
  669. * The following create* functions are called upon submitting Step 8.
  670. */
  671. createCluster: function () {
  672. if (this.get('content.controllerName') !== 'installerController') {
  673. return false;
  674. }
  675. var clusterName = this.get('clusterName');
  676. var url = App.apiPrefix + '/clusters/' + clusterName;
  677. var stackVersion = (this.get('content.installOptions.localRepo')) ? App.currentStackVersion.replace(/(-\d+(\.\d)*)/ig, "Local$&") : App.currentStackVersion;
  678. this.ajax({
  679. type: 'POST',
  680. url: url,
  681. data: JSON.stringify({ "Clusters": {"version": stackVersion }}),
  682. beforeSend: function () {
  683. console.log("BeforeSend: createCluster for " + clusterName);
  684. }
  685. });
  686. },
  687. createSelectedServices: function () {
  688. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/services';
  689. var data = this.createServiceData();
  690. var httpMethod = 'POST';
  691. if (!data.length) {
  692. return;
  693. }
  694. this.ajax({
  695. type: httpMethod,
  696. url: url,
  697. data: JSON.stringify(data),
  698. beforeSend: function () {
  699. console.log('BeforeSend: createSelectedServices ', data);
  700. }
  701. });
  702. },
  703. createServiceData: function () {
  704. var services = this.get('selectedServices').mapProperty('serviceName');
  705. var data = [];
  706. services.forEach(function (_service) {
  707. data.pushObject({"ServiceInfo": { "service_name": _service }});
  708. }, this);
  709. return data;
  710. },
  711. createComponents: function () {
  712. var serviceComponents = require('data/service_components');
  713. var services = this.get('selectedServices').mapProperty('serviceName');
  714. services.forEach(function (_service) {
  715. var components = serviceComponents.filterProperty('service_name', _service);
  716. var componentsData = components.map(function (_component) {
  717. return { "ServiceComponentInfo": { "component_name": _component.component_name } };
  718. });
  719. // Service must be specified in terms of a query for creating multiple components at the same time.
  720. // See AMBARI-1018.
  721. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/services?ServiceInfo/service_name=' + _service;
  722. var data = {
  723. "components": componentsData
  724. };
  725. this.ajax({
  726. type: 'POST',
  727. url: url,
  728. data: JSON.stringify(data),
  729. beforeSend: function () {
  730. console.log('BeforeSend: createComponents for ' + _service, componentsData);
  731. }
  732. });
  733. }, this);
  734. },
  735. registerHostsToCluster: function () {
  736. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts';
  737. var data = this.createRegisterHostData();
  738. if (data.length == 0) {
  739. return;
  740. }
  741. this.ajax({
  742. type: 'POST',
  743. url: url,
  744. data: JSON.stringify(data),
  745. beforeSend: function () {
  746. console.log('BeforeSend: registerHostsToCluster', data);
  747. }
  748. });
  749. },
  750. createRegisterHostData: function () {
  751. var hosts = this.getRegisteredHosts().filterProperty('isInstalled', false);
  752. if (!hosts.length) {
  753. return [];
  754. }
  755. return hosts.map(function (host) {
  756. return {"Hosts": { "host_name": host.hostName}};
  757. });
  758. },
  759. // TODO: review the code for add hosts / add services scenarios...
  760. createAllHostComponents: function () {
  761. var masterHosts = this.get('content.masterComponentHosts');
  762. var slaveHosts = this.get('content.slaveComponentHosts');
  763. var clients = this.get('content.clients');
  764. // note: masterHosts has 'component' vs slaveHosts has 'componentName'
  765. var masterComponents = masterHosts.mapProperty('component').uniq();
  766. masterComponents.forEach(function (component) {
  767. var hostNames = masterHosts.filterProperty('component', component).filterProperty('isInstalled', false).mapProperty('hostName');
  768. this.registerHostsToComponent(hostNames, component);
  769. }, this);
  770. slaveHosts.forEach(function (_slave) {
  771. if (_slave.componentName !== 'CLIENT') {
  772. var hostNames = _slave.hosts.filterProperty('isInstalled', false).mapProperty('hostName');
  773. this.registerHostsToComponent(hostNames, _slave.componentName);
  774. } else {
  775. clients.forEach(function (_client) {
  776. var hostNames = _slave.hosts.mapProperty('hostName');
  777. switch (_client.component_name) {
  778. case 'HDFS_CLIENT':
  779. // install HDFS_CLIENT on HBASE_MASTER, HBASE_REGIONSERVER, WEBHCAT_SERVER, HISTORYSERVER and OOZIE_SERVER hosts
  780. masterHosts.filterProperty('component', 'HBASE_MASTER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  781. hostNames.pushObject(_masterHost.hostName);
  782. }, this);
  783. masterHosts.filterProperty('component', 'HBASE_REGIONSERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  784. hostNames.pushObject(_masterHost.hostName);
  785. }, this);
  786. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  787. hostNames.pushObject(_masterHost.hostName);
  788. }, this);
  789. masterHosts.filterProperty('component', 'HISTORYSERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  790. hostNames.pushObject(_masterHost.hostName);
  791. }, this);
  792. masterHosts.filterProperty('component', 'OOZIE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  793. hostNames.pushObject(_masterHost.hostName);
  794. }, this);
  795. break;
  796. case 'MAPREDUCE_CLIENT':
  797. // install MAPREDUCE_CLIENT on HIVE_SERVER, OOZIE_SERVER, NAGIOS_SERVER, and WEBHCAT_SERVER hosts
  798. masterHosts.filterProperty('component', 'HIVE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  799. hostNames.pushObject(_masterHost.hostName);
  800. }, this);
  801. masterHosts.filterProperty('component', 'OOZIE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  802. hostNames.pushObject(_masterHost.hostName);
  803. }, this);
  804. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  805. hostNames.pushObject(_masterHost.hostName);
  806. }, this);
  807. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  808. hostNames.pushObject(_masterHost.hostName);
  809. }, this);
  810. break;
  811. case 'OOZIE_CLIENT':
  812. // install OOZIE_CLIENT on NAGIOS_SERVER host
  813. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  814. hostNames.pushObject(_masterHost.hostName);
  815. }, this);
  816. break;
  817. case 'ZOOKEEPER_CLIENT':
  818. // install ZOOKEEPER_CLIENT on WEBHCAT_SERVER host
  819. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  820. hostNames.pushObject(_masterHost.hostName);
  821. }, this);
  822. break;
  823. case 'HIVE_CLIENT':
  824. //install HIVE client on NAGIOS_SERVER host
  825. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  826. hostNames.pushObject(_masterHost.hostName);
  827. }, this);
  828. masterHosts.filterProperty('component', 'HIVE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  829. hostNames.pushObject(_masterHost.hostName);
  830. }, this);
  831. break;
  832. case 'HCAT':
  833. // install HCAT (client) on NAGIOS_SERVER host
  834. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  835. hostNames.pushObject(_masterHost.hostName);
  836. }, this);
  837. break;
  838. case 'YARN_CLIENT':
  839. // install YARN_CLIENT on NAGIOS_SERVER,HIVE_SERVER,OOZIE_SERVER,WEBHCAT_SERVER host
  840. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  841. hostNames.pushObject(_masterHost.hostName);
  842. }, this);
  843. masterHosts.filterProperty('component', 'HIVE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  844. hostNames.pushObject(_masterHost.hostName);
  845. }, this);
  846. masterHosts.filterProperty('component', 'OOZIE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  847. hostNames.pushObject(_masterHost.hostName);
  848. }, this);
  849. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  850. hostNames.pushObject(_masterHost.hostName);
  851. }, this);
  852. break;
  853. }
  854. hostNames = hostNames.uniq();
  855. if (_client.isInstalled) {
  856. //check whether clients are already installed on selected master hosts!!!
  857. var installedHosts = _slave.hosts.filterProperty('isInstalled', true).mapProperty('hostName');
  858. installedHosts.forEach(function (host) {
  859. if (hostNames.contains(host)) {
  860. hostNames.splice(hostNames.indexOf(host), 1);
  861. }
  862. }, this);
  863. }
  864. this.registerHostsToComponent(hostNames, _client.component_name);
  865. }, this);
  866. }
  867. }, this);
  868. // add Ganglia Monitor (Slave) to all hosts if Ganglia service is selected
  869. var gangliaService = this.get('content.services').filterProperty('isSelected', true).findProperty('serviceName', 'GANGLIA');
  870. if (gangliaService) {
  871. var hosts = this.getRegisteredHosts();
  872. if (gangliaService.get('isInstalled')) {
  873. hosts = hosts.filterProperty('isInstalled', false);
  874. }
  875. if (hosts.length) {
  876. this.registerHostsToComponent(hosts.mapProperty('hostName'), 'GANGLIA_MONITOR');
  877. }
  878. }
  879. // add MySQL Server if Hive is selected
  880. var hiveService = this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).findProperty('serviceName', 'HIVE');
  881. if (hiveService) {
  882. var hiveDb = this.get('content.serviceConfigProperties').findProperty('name', 'hive_database');
  883. if(hiveDb.value == "New MySQL Database") {
  884. this.registerHostsToComponent(masterHosts.filterProperty('component', 'HIVE_SERVER').mapProperty('hostName'), 'MYSQL_SERVER');
  885. }
  886. }
  887. },
  888. registerHostsToComponent: function (hostNames, componentName) {
  889. if (hostNames.length == 0) {
  890. return;
  891. }
  892. // currently we are specifying the predicate as a query string.
  893. // this can hit a ~4000-character limit in Jetty server.
  894. // chunk to multiple calls if needed
  895. // var hostsPredicate = hostNames.map(function (hostName) {
  896. // return 'Hosts/host_name=' + hostName;
  897. // }).join('|');
  898. var queryStrArr = [];
  899. var queryStr = '';
  900. hostNames.forEach(function (hostName) {
  901. queryStr += 'Hosts/host_name=' + hostName + '|';
  902. if (queryStr.length > 3500) {
  903. queryStrArr.push(queryStr.slice(0, -1));
  904. queryStr = '';
  905. }
  906. });
  907. if (queryStr.length > 0) {
  908. queryStrArr.push(queryStr.slice(0, -1));
  909. }
  910. queryStrArr.forEach(function (queryStr) {
  911. // console.log('creating host components for ' + queryStr);
  912. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts?' + queryStr;
  913. var data = {
  914. "host_components": [
  915. {
  916. "HostRoles": {
  917. "component_name": componentName
  918. }
  919. }
  920. ]
  921. };
  922. this.ajax({
  923. type: 'POST',
  924. url: url,
  925. data: JSON.stringify(data)
  926. });
  927. }, this);
  928. },
  929. createConfigurations: function () {
  930. var selectedServices = this.get('selectedServices');
  931. if (this.get('content.controllerName') == 'installerController') {
  932. this.get('serviceConfigTags').pushObject(this.createCoreSiteObj());
  933. this.get('serviceConfigTags').pushObject(this.createHdfsSiteObj());
  934. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HDFS'));
  935. }
  936. var globalSiteObj = this.createGlobalSiteObj();
  937. if (this.get('content.controllerName') == 'addServiceController') {
  938. globalSiteObj.tag = 'version' + (new Date).getTime();
  939. }
  940. this.get('serviceConfigTags').pushObject(globalSiteObj);
  941. if (selectedServices.someProperty('serviceName', 'MAPREDUCE')) {
  942. this.get('serviceConfigTags').pushObject(this.createMrSiteObj());
  943. if (App.supports.capacitySchedulerUi) {
  944. this.get('serviceConfigTags').pushObject(this.createCapacityScheduler());
  945. this.get('serviceConfigTags').pushObject(this.createMapredQueueAcls());
  946. }
  947. this.get('serviceConfigTags').pushObject(this.createLog4jObj('MAPREDUCE'));
  948. }
  949. if (selectedServices.someProperty('serviceName', 'MAPREDUCE2')) {
  950. this.get('serviceConfigTags').pushObject(this.createMrSiteObj());
  951. this.get('serviceConfigTags').pushObject(this.createLog4jObj('MAPREDUCE2'));
  952. }
  953. if (selectedServices.someProperty('serviceName', 'YARN')) {
  954. this.get('serviceConfigTags').pushObject(this.createYarnSiteObj());
  955. this.get('serviceConfigTags').pushObject(this.createCapacityScheduler());
  956. this.get('serviceConfigTags').pushObject(this.createLog4jObj('YARN'));
  957. }
  958. if (selectedServices.someProperty('serviceName', 'HBASE')) {
  959. this.get('serviceConfigTags').pushObject(this.createHbaseSiteObj());
  960. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HBASE'));
  961. }
  962. if (selectedServices.someProperty('serviceName', 'OOZIE')) {
  963. this.get('serviceConfigTags').pushObject(this.createOozieSiteObj('OOZIE'));
  964. this.get('serviceConfigTags').pushObject(this.createLog4jObj('OOZIE'));
  965. }
  966. if (selectedServices.someProperty('serviceName', 'HIVE')) {
  967. this.get('serviceConfigTags').pushObject(this.createHiveSiteObj('HIVE'));
  968. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HIVE'));
  969. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HIVE-EXEC'));
  970. }
  971. if (selectedServices.someProperty('serviceName', 'WEBHCAT')) {
  972. this.get('serviceConfigTags').pushObject(this.createWebHCatSiteObj('WEBHCAT'));
  973. }
  974. if (selectedServices.someProperty('serviceName', 'HUE')) {
  975. this.get('serviceConfigTags').pushObject(this.createHueSiteObj('HUE'));
  976. }
  977. if (selectedServices.someProperty('serviceName', 'PIG')) {
  978. this.get('serviceConfigTags').pushObject(this.createLog4jObj('PIG'));
  979. }
  980. if (selectedServices.someProperty('serviceName', 'STORM')) {
  981. this.get('serviceConfigTags').pushObject(this.createStormSiteObj());
  982. }
  983. if (selectedServices.someProperty('serviceName', 'TEZ')) {
  984. this.get('serviceConfigTags').pushObject(this.createTezSiteObj());
  985. }
  986. if (selectedServices.someProperty('serviceName', 'ZOOKEEPER')) {
  987. this.get('serviceConfigTags').pushObject(this.createZooCfgObj());
  988. this.get('serviceConfigTags').pushObject(this.createLog4jObj('ZOOKEEPER'));
  989. }
  990. this.applyConfigurationsToCluster();
  991. },
  992. applyConfigurationsToCluster: function() {
  993. var clusterUrl = App.apiPrefix + '/clusters/' + this.get('clusterName');
  994. var configData = [];
  995. this.get('serviceConfigTags').forEach(function (_serviceConfig) {
  996. var Clusters = {
  997. Clusters: {
  998. desired_config: {
  999. type: _serviceConfig.type,
  1000. tag: _serviceConfig.tag,
  1001. properties: _serviceConfig.properties
  1002. }
  1003. }
  1004. };
  1005. configData.pushObject(JSON.stringify(Clusters));
  1006. }, this);
  1007. var data = {
  1008. configData: '[' + configData.toString() + ']'
  1009. };
  1010. console.debug("applyConfigurationsToCluster(Step8): Applying to URL", clusterUrl, " Data:", data.configData);
  1011. this.ajax({
  1012. type: 'PUT',
  1013. url: clusterUrl,
  1014. data: data.configData,
  1015. beforeSend: function () {
  1016. console.log("BeforeSend: Updating cluster config");
  1017. }
  1018. });
  1019. },
  1020. createConfigurationGroups: function () {
  1021. var configGroups = this.get('content.configGroups').filterProperty('isDefault', false);
  1022. var clusterName = this.get('clusterName');
  1023. var sendData = [];
  1024. var updateData = [];
  1025. var serviceConfigController = App.router.get('mainServiceInfoConfigsController');
  1026. var timeTag = (new Date).getTime();
  1027. var groupsToDelete = App.router.get(this.get('content.controllerName')).getDBProperty('groupsToDelete');
  1028. if (groupsToDelete && groupsToDelete.length > 0) {
  1029. this.removeInstalledServicesConfigurationGroups(groupsToDelete);
  1030. }
  1031. configGroups.forEach(function (configGroup) {
  1032. var groupConfigs = [];
  1033. var groupData = {
  1034. "cluster_name": clusterName,
  1035. "group_name": configGroup.name,
  1036. "tag": configGroup.service.id,
  1037. "description": configGroup.description,
  1038. "hosts": [],
  1039. "desired_configs": []
  1040. };
  1041. configGroup.hosts.forEach(function (hostName) {
  1042. groupData.hosts.push({"host_name": hostName});
  1043. });
  1044. //wrap properties into Em.Object to make them compatible with buildGroupDesiredConfigs method
  1045. configGroup.properties.forEach(function (property) {
  1046. groupConfigs.push(Em.Object.create(property));
  1047. });
  1048. groupData.desired_configs = serviceConfigController.buildGroupDesiredConfigs.call(serviceConfigController, groupConfigs, timeTag);
  1049. // check for group from installed service
  1050. if (configGroup.isForUpdate === true) {
  1051. // if group is a new one, create it
  1052. if (!configGroup.id) {
  1053. sendData.push({"ConfigGroup": groupData});
  1054. } else {
  1055. // update an existing group
  1056. groupData.id = configGroup.id;
  1057. updateData.push({"ConfigGroup": groupData});
  1058. }
  1059. } else {
  1060. sendData.push({"ConfigGroup": groupData});
  1061. }
  1062. //each group should have unique tag to prevent overriding configs from common sites
  1063. timeTag++;
  1064. }, this);
  1065. if (sendData.length > 0) {
  1066. this.applyConfigurationGroups(sendData);
  1067. }
  1068. if (updateData.length > 0) {
  1069. this.applyInstalledServicesConfigurationGroup(updateData);
  1070. }
  1071. },
  1072. applyConfigurationGroups: function (sendData) {
  1073. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/config_groups';
  1074. this.ajax({
  1075. type: 'POST',
  1076. url: url,
  1077. data: JSON.stringify(sendData)
  1078. });
  1079. },
  1080. applyInstalledServicesConfigurationGroup: function (updateData) {
  1081. updateData.forEach(function(item) {
  1082. App.router.get('mainServiceInfoConfigsController').putConfigGroupChanges(item);
  1083. });
  1084. },
  1085. removeInstalledServicesConfigurationGroups: function(groupsToDelete) {
  1086. groupsToDelete.forEach(function(item) {
  1087. App.config.deleteConfigGroup(Em.Object.create(item));
  1088. });
  1089. },
  1090. createGlobalSiteObj: function () {
  1091. var globalSiteProperties = {};
  1092. var globalSiteObj = this.get('globals');
  1093. var isGLUSTERFSSelected = this.get('selectedServices').someProperty('serviceName', 'GLUSTERFS');
  1094. // screen out the GLUSTERFS-specific global config entries when they are not required
  1095. if (!isGLUSTERFSSelected) {
  1096. globalSiteObj = globalSiteObj.filter(function(_config) {
  1097. return _config.name.indexOf("fs_glusterfs") < 0;
  1098. });
  1099. }
  1100. globalSiteObj.forEach(function (_globalSiteObj) {
  1101. var heapsizeException = ['hadoop_heapsize','yarn_heapsize','nodemanager_heapsize','resourcemanager_heapsize'];
  1102. // do not pass any globals whose name ends with _host or _hosts
  1103. if (_globalSiteObj.isRequiredByAgent !== false) {
  1104. // append "m" to JVM memory options except for hadoop_heapsize
  1105. if (/_heapsize|_newsize|_maxnewsize$/.test(_globalSiteObj.name) && !heapsizeException.contains(_globalSiteObj.name)) {
  1106. globalSiteProperties[_globalSiteObj.name] = _globalSiteObj.value + "m";
  1107. } else {
  1108. globalSiteProperties[_globalSiteObj.name] = App.config.escapeXMLCharacters(_globalSiteObj.value);
  1109. }
  1110. }
  1111. this._recordHostOverrideFromObj(_globalSiteObj, 'global', 'version1', this);
  1112. }, this);
  1113. // we don't expose gmond_user to the user; it needs to be the same as gmetad_user
  1114. globalSiteProperties['gmond_user'] = globalSiteProperties['gmetad_user'];
  1115. return {"type": "global", "tag": "version1", "properties": globalSiteProperties};
  1116. },
  1117. createCoreSiteObj: function () {
  1118. var coreSiteObj = this.get('configs').filterProperty('filename', 'core-site.xml');
  1119. var coreSiteProperties = {};
  1120. // hadoop.proxyuser.oozie.hosts needs to be skipped if oozie is not selected
  1121. var isOozieSelected = this.get('selectedServices').someProperty('serviceName', 'OOZIE');
  1122. var oozieUser = this.get('globals').someProperty('name', 'oozie_user') ? this.get('globals').findProperty('name', 'oozie_user').value : null;
  1123. var isHiveSelected = this.get('selectedServices').someProperty('serviceName', 'HIVE');
  1124. var hiveUser = this.get('globals').someProperty('name', 'hive_user') ? this.get('globals').findProperty('name', 'hive_user').value : null;
  1125. var isHcatSelected = this.get('selectedServices').someProperty('serviceName', 'WEBHCAT');
  1126. var hcatUser = this.get('globals').someProperty('name', 'hcat_user') ? this.get('globals').findProperty('name', 'hcat_user').value : null;
  1127. var isGLUSTERFSSelected = this.get('selectedServices').someProperty('serviceName', 'GLUSTERFS');
  1128. // screen out the GLUSTERFS-specific core-site.xml entries when they are not needed
  1129. if (!isGLUSTERFSSelected) {
  1130. coreSiteObj = coreSiteObj.filter(function(_config) {
  1131. return _config.name.indexOf("fs.glusterfs") < 0;
  1132. });
  1133. }
  1134. coreSiteObj.forEach(function (_coreSiteObj) {
  1135. if ((isOozieSelected || (_coreSiteObj.name != 'hadoop.proxyuser.' + oozieUser + '.hosts' && _coreSiteObj.name != 'hadoop.proxyuser.' + oozieUser + '.groups')) && (isHiveSelected || (_coreSiteObj.name != 'hadoop.proxyuser.' + hiveUser + '.hosts' && _coreSiteObj.name != 'hadoop.proxyuser.' + hiveUser + '.groups')) && (isHcatSelected || (_coreSiteObj.name != 'hadoop.proxyuser.' + hcatUser + '.hosts' && _coreSiteObj.name != 'hadoop.proxyuser.' + hcatUser + '.groups'))) {
  1136. coreSiteProperties[_coreSiteObj.name] = App.config.escapeXMLCharacters(_coreSiteObj.value);
  1137. this._recordHostOverrideFromObj(_coreSiteObj, 'core-site', 'version1', this);
  1138. }
  1139. if (isGLUSTERFSSelected && _coreSiteObj.name == "fs.default.name") {
  1140. coreSiteProperties[_coreSiteObj.name] = this.get('globals').someProperty('name', 'fs_glusterfs_default_name') ? App.config.escapeXMLCharacters(this.get('globals').findProperty('name', 'fs_glusterfs_default_name').value) : null;
  1141. }
  1142. if (isGLUSTERFSSelected && _coreSiteObj.name == "fs.defaultFS") {
  1143. coreSiteProperties[_coreSiteObj.name] = this.get('globals').someProperty('name', 'glusterfs_defaultFS_name') ? App.config.escapeXMLCharacters(this.get('globals').findProperty('name', 'glusterfs_defaultFS_name').value) : null;
  1144. }
  1145. console.log("STEP*: name of the property is: " + _coreSiteObj.name);
  1146. console.log("STEP8: value of the property is: " + _coreSiteObj.value);
  1147. }, this);
  1148. return {"type": "core-site", "tag": "version1", "properties": coreSiteProperties};
  1149. },
  1150. createHdfsSiteObj: function () {
  1151. var hdfsSiteObj = this.get('configs').filterProperty('filename', 'hdfs-site.xml');
  1152. var hdfsProperties = {};
  1153. hdfsSiteObj.forEach(function (_configProperty) {
  1154. hdfsProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1155. this._recordHostOverrideFromObj(_configProperty, 'hdfs-site', 'version1', this);
  1156. console.log("STEP*: name of the property is: " + _configProperty.name);
  1157. console.log("STEP8: value of the property is: " + _configProperty.value);
  1158. }, this);
  1159. return {"type": "hdfs-site", "tag": "version1", "properties": hdfsProperties };
  1160. },
  1161. createLog4jObj: function (fileName) {
  1162. fileName = fileName.toLowerCase();
  1163. var Log4jObj = this.get('configs').filterProperty('filename', fileName + '-log4j.xml');
  1164. var Log4jProperties = {};
  1165. Log4jObj.forEach(function (_configProperty) {
  1166. Log4jProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1167. this._recordHostOverrideFromObj(_configProperty, fileName + '-log4j', 'version1', this);
  1168. console.log("STEP*: name of the property is: " + _configProperty.name);
  1169. console.log("STEP8: value of the property is: " + _configProperty.value);
  1170. }, this);
  1171. return {"type": fileName + "-log4j", "tag": "version1", "properties": Log4jProperties };
  1172. },
  1173. createHueSiteObj: function () {
  1174. var hueSiteObj = this.get('configs').filterProperty('filename', 'hue-site.xml');
  1175. var hueProperties = {};
  1176. hueSiteObj.forEach(function (_configProperty) {
  1177. hueProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1178. this._recordHostOverrideFromObj(_configProperty, 'hue-site', 'version1', this);
  1179. console.log("STEP*: name of the property is: " + _configProperty.name);
  1180. console.log("STEP8: value of the property is: " + _configProperty.value);
  1181. }, this);
  1182. return {"type": "hue-site", "tag": "version1", "properties": hueProperties };
  1183. },
  1184. createMrSiteObj: function () {
  1185. var configs = this.get('configs').filterProperty('filename', 'mapred-site.xml');
  1186. var mrProperties = {};
  1187. configs.forEach(function (_configProperty) {
  1188. mrProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1189. this._recordHostOverrideFromObj(_configProperty, 'mapred-site', 'version1', this);
  1190. console.log("STEP*: name of the property is: " + _configProperty.name);
  1191. console.log("STEP8: value of the property is: " + _configProperty.value);
  1192. }, this);
  1193. return {type: 'mapred-site', tag: 'version1', properties: mrProperties};
  1194. },
  1195. createYarnSiteObj: function () {
  1196. var configs = this.get('configs').filterProperty('filename', 'yarn-site.xml');
  1197. var mrProperties = {};
  1198. configs.forEach(function (_configProperty) {
  1199. mrProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1200. this._recordHostOverrideFromObj(_configProperty, 'yarn-site', 'version1', this);
  1201. console.log("STEP*: name of the property is: " + _configProperty.name);
  1202. console.log("STEP8: value of the property is: " + _configProperty.value);
  1203. }, this);
  1204. return {type: 'yarn-site', tag: 'version1', properties: mrProperties};
  1205. },
  1206. createCapacityScheduler: function () {
  1207. var configs = this.get('configs').filterProperty('filename', 'capacity-scheduler.xml');
  1208. var csProperties = {};
  1209. configs.forEach(function (_configProperty) {
  1210. csProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1211. this._recordHostOverrideFromObj(_configProperty, 'capacity-scheduler', 'version1', this);
  1212. console.log("STEP*: name of the property is: " + _configProperty.name);
  1213. console.log("STEP8: value of the property is: " + _configProperty.value);
  1214. }, this);
  1215. return {type: 'capacity-scheduler', tag: 'version1', properties: csProperties};
  1216. },
  1217. createMapredQueueAcls: function () {
  1218. var configs = this.get('configs').filterProperty('filename', 'mapred-queue-acls.xml');
  1219. var mqProperties = {};
  1220. configs.forEach(function (_configProperty) {
  1221. mqProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1222. this._recordHostOverrideFromObj(_configProperty, 'mapred-queue-acls', 'version1', this);
  1223. console.log("STEP*: name of the property is: " + _configProperty.name);
  1224. console.log("STEP8: value of the property is: " + _configProperty.value);
  1225. }, this);
  1226. return {type: 'mapred-queue-acls', tag: 'version1', properties: mqProperties};
  1227. },
  1228. createHbaseSiteObj: function () {
  1229. var configs = this.get('configs').filterProperty('filename', 'hbase-site.xml');
  1230. var hbaseProperties = {};
  1231. configs.forEach(function (_configProperty) {
  1232. hbaseProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1233. this._recordHostOverrideFromObj(_configProperty, 'hbase-site', 'version1', this);
  1234. }, this);
  1235. return {type: 'hbase-site', tag: 'version1', properties: hbaseProperties};
  1236. },
  1237. createOozieSiteObj: function (serviceName) {
  1238. var configs = this.get('configs').filterProperty('filename', 'oozie-site.xml');
  1239. var oozieProperties = {};
  1240. configs.forEach(function (_configProperty) {
  1241. oozieProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1242. this._recordHostOverrideFromObj(_configProperty, 'oozie-site', 'version1', this);
  1243. }, this);
  1244. return {type: 'oozie-site', tag: 'version1', properties: oozieProperties};
  1245. },
  1246. createHiveSiteObj: function (serviceName) {
  1247. var configs = this.get('configs').filterProperty('filename', 'hive-site.xml');
  1248. var hiveProperties = {};
  1249. configs.forEach(function (_configProperty) {
  1250. hiveProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1251. this._recordHostOverrideFromObj(_configProperty, 'hive-site', 'version1', this);
  1252. }, this);
  1253. return {type: 'hive-site', tag: 'version1', properties: hiveProperties};
  1254. },
  1255. createWebHCatSiteObj: function (serviceName) {
  1256. var configs = this.get('configs').filterProperty('filename', 'webhcat-site.xml');
  1257. var webHCatProperties = {};
  1258. configs.forEach(function (_configProperty) {
  1259. webHCatProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1260. this._recordHostOverrideFromObj(_configProperty, 'webhcat-site', 'version1', this);
  1261. }, this);
  1262. return {type: 'webhcat-site', tag: 'version1', properties: webHCatProperties};
  1263. },
  1264. createZooCfgObj: function () {
  1265. var configs = this.get('configs').filterProperty('filename', 'zoo.cfg');
  1266. var csProperties = {};
  1267. configs.forEach(function (_configProperty) {
  1268. csProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1269. this._recordHostOverrideFromObj(_configProperty, 'zoo.cfg', 'version1', this);
  1270. }, this);
  1271. return {type: 'zoo.cfg', tag: 'version1', properties: csProperties};
  1272. },
  1273. createStormSiteObj: function () {
  1274. var configs = this.get('configs').filterProperty('filename', 'storm-site.xml');
  1275. var stormProperties = {};
  1276. configs.forEach(function (_configProperty) {
  1277. if (_configProperty.name == "storm.zookeeper.servers") {
  1278. stormProperties[_configProperty.name] = JSON.stringify(_configProperty.value).replace(/"/g, "'");
  1279. } else {
  1280. stormProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1281. }
  1282. this._recordHostOverrideFromObj(_configProperty, 'storm-site', 'version1', this);
  1283. }, this);
  1284. return {type: 'storm-site', tag: 'version1', properties: stormProperties};
  1285. },
  1286. createTezSiteObj: function () {
  1287. var configs = this.get('configs').filterProperty('filename', 'tez-site.xml');
  1288. var tezProperty = {};
  1289. configs.forEach(function (_configProperty) {
  1290. tezProperty[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1291. this._recordHostOverrideFromObj(_configProperty, 'tez-site', 'version1', this);
  1292. }, this);
  1293. return {type: 'tez-site', tag: 'version1', properties: tezProperty};
  1294. },
  1295. ajaxQueueFinished: function () {
  1296. //do something
  1297. },
  1298. doNextAjaxCall: function () {
  1299. if (this.get('ajaxBusy')) {
  1300. return;
  1301. }
  1302. var queue = this.get('ajaxQueue');
  1303. if (!queue.length) {
  1304. this.ajaxQueueFinished();
  1305. return;
  1306. }
  1307. var first = queue[0];
  1308. this.set('ajaxQueue', queue.slice(1));
  1309. this.set('ajaxQueueLeft', this.get('ajaxQueue').length);
  1310. this.set('ajaxBusy', true);
  1311. $.ajax(first);
  1312. },
  1313. /**
  1314. * Records all the host overrides per site/tag
  1315. */
  1316. _recordHostOverrideFromObj: function(serviceConfigObj, siteName, tagName, self){
  1317. var overrides = serviceConfigObj.overrides;
  1318. if(overrides && overrides.length>0){
  1319. overrides.forEach(function(override){
  1320. override.hosts.forEach(function(host){
  1321. if(!(host in self.savedHostToOverrideSiteToTagMap)){
  1322. self.savedHostToOverrideSiteToTagMap[host] = {};
  1323. }
  1324. if(!(siteName in self.savedHostToOverrideSiteToTagMap[host])){
  1325. self.savedHostToOverrideSiteToTagMap[host][siteName] = {};
  1326. self.savedHostToOverrideSiteToTagMap[host][siteName].map = {};
  1327. }
  1328. var finalTag = tagName + '_' + host;
  1329. console.log("recordHostOverride(): Saving host override for host="+host+", site="+siteName+", tag="+finalTag+", (key,value)=("+serviceConfigObj.name+","+override.value+")");
  1330. self.savedHostToOverrideSiteToTagMap[host][siteName].tagName = finalTag;
  1331. self.savedHostToOverrideSiteToTagMap[host][siteName].map[serviceConfigObj.name] = override.value;
  1332. });
  1333. });
  1334. }
  1335. },
  1336. /**
  1337. * Creates host level overrides for service configuration.
  1338. *
  1339. */
  1340. createHostOverrideConfigurations: function () {
  1341. var singlePUTHostData = [];
  1342. var savedHostSiteArray = [];
  1343. for ( var host in this.savedHostToOverrideSiteToTagMap) {
  1344. for ( var siteName in this.savedHostToOverrideSiteToTagMap[host]) {
  1345. var tagName = this.savedHostToOverrideSiteToTagMap[host][siteName].tagName;
  1346. var map = this.savedHostToOverrideSiteToTagMap[host][siteName].map;
  1347. savedHostSiteArray.push(host + "///" + siteName);
  1348. singlePUTHostData.push({
  1349. RequestInfo: {
  1350. query: 'Hosts/host_name='+host
  1351. },
  1352. Body: {
  1353. Hosts: {
  1354. desired_config: {
  1355. type: siteName,
  1356. tag: tagName,
  1357. properties: map
  1358. }
  1359. }
  1360. }
  1361. });
  1362. }
  1363. }
  1364. console.log("createHostOverrideConfigSites(): PUTting host-overrides. Data=", singlePUTHostData);
  1365. if(singlePUTHostData.length>0){
  1366. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts';
  1367. this.ajax({
  1368. type: 'PUT',
  1369. url: url,
  1370. data: JSON.stringify(singlePUTHostData),
  1371. dataType: 'text',
  1372. beforeSend: function () {
  1373. console.log("createHostOverrideConfigSites() PUT override=", singlePUTHostData);
  1374. }
  1375. });
  1376. }
  1377. },
  1378. /**
  1379. * We need to do a lot of ajax calls async in special order. To do this,
  1380. * generate array of ajax objects and then send requests step by step. All
  1381. * ajax objects are stored in <code>ajaxQueue</code>
  1382. *
  1383. * @param params
  1384. */
  1385. ajax: function (params) {
  1386. if (App.testMode) return;
  1387. var self = this;
  1388. params = jQuery.extend({
  1389. async: true,
  1390. dataType: 'text',
  1391. statusCode: require('data/statusCodes'),
  1392. timeout: App.timeout,
  1393. error: function (request, ajaxOptions, error) {
  1394. console.log('Step8: In Error ');
  1395. // console.log('Step8: Error message is: ' + request.responseText);
  1396. },
  1397. success: function (data) {
  1398. console.log("TRACE: STep8 -> In success function");
  1399. }
  1400. }, params);
  1401. var success = params.success;
  1402. var error = params.error;
  1403. params.success = function () {
  1404. if (success) {
  1405. success();
  1406. }
  1407. self.set('ajaxBusy', false);
  1408. self.doNextAjaxCall();
  1409. };
  1410. params.error = function (xhr, status, error) {
  1411. var responseText = JSON.parse(xhr.responseText);
  1412. var controller = App.router.get(App.clusterStatus.wizardControllerName);
  1413. controller.registerErrPopup(Em.I18n.t('common.error'), responseText.message);
  1414. self.set('hasErrorOccurred', true);
  1415. // an error will break the ajax call chain and allow submission again
  1416. self.set('isSubmitDisabled', false);
  1417. self.set('isBackBtnDisabled', false);
  1418. App.router.get(self.get('content.controllerName')).setStepsEnable();
  1419. self.get('ajaxQueue').clear();
  1420. self.set('ajaxBusy', false);
  1421. };
  1422. this.get('ajaxQueue').pushObject(params);
  1423. }
  1424. });