step8_controller.js 66 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593
  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.os_type)) {
  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. /**
  507. * Update configurations for installed services.
  508. *
  509. * @param {Array} configsToUpdate - configs need to update
  510. * @return {*}
  511. */
  512. updateConfigurations: function (configsToUpdate) {
  513. var configurationController = App.router.get('mainServiceInfoConfigsController');
  514. var serviceNames = configsToUpdate.mapProperty('serviceName').uniq();
  515. serviceNames.forEach(function(serviceName) {
  516. var configs = configsToUpdate.filterProperty('serviceName', serviceName);
  517. configurationController.setNewTagNames(configs);
  518. var tagName = configs.objectAt(0).newTagName;
  519. var siteConfigs = configs.filterProperty('id', 'site property');
  520. siteConfigs.mapProperty('filename').uniq().forEach(function(siteName) {
  521. var formattedConfigs = configurationController.createSiteObj(siteName.replace(".xml", ""), tagName, configs.filterProperty('filename', siteName));
  522. configurationController.doPUTClusterConfigurationSite(formattedConfigs);
  523. });
  524. });
  525. },
  526. submitProceed: function() {
  527. this.set('isSubmitDisabled', true);
  528. this.set('isBackBtnDisabled', true);
  529. if (this.get('content.controllerName') == 'addHostController') {
  530. App.router.get('addHostController').setLowerStepsDisable(4);
  531. }
  532. // checkpoint the cluster status on the server so that the user can resume from where they left off
  533. switch (this.get('content.controllerName')) {
  534. case 'installerController':
  535. App.clusterStatus.setClusterStatus({
  536. clusterName: this.get('clusterName'),
  537. clusterState: 'CLUSTER_DEPLOY_PREP_2',
  538. wizardControllerName: this.get('content.controllerName'),
  539. localdb: App.db.data
  540. });
  541. break;
  542. case 'addHostController':
  543. App.clusterStatus.setClusterStatus({
  544. clusterName: this.get('clusterName'),
  545. clusterState: 'ADD_HOSTS_DEPLOY_PREP_2',
  546. wizardControllerName: this.get('content.controllerName'),
  547. localdb: App.db.data
  548. });
  549. break;
  550. case 'addServiceController':
  551. App.clusterStatus.setClusterStatus({
  552. clusterName: this.get('clusterName'),
  553. clusterState: 'ADD_SERVICES_DEPLOY_PREP_2',
  554. wizardControllerName: this.get('content.controllerName'),
  555. localdb: App.db.data
  556. });
  557. break;
  558. default:
  559. break;
  560. }
  561. // delete any existing clusters to start from a clean slate
  562. // before creating a new cluster in install wizard
  563. // TODO: modify for multi-cluster support
  564. if (this.get('content.controllerName') == 'installerController' && (!App.testMode)) {
  565. var clusterNames = this.getExistingClusterNames();
  566. this.deleteClusters(clusterNames);
  567. }
  568. if (this.get('wizardController').getDBProperty('configsToUpdate')) {
  569. this.updateConfigurations(this.get('wizardController').getDBProperty('configsToUpdate'));
  570. }
  571. this.setLocalRepositories();
  572. this.createCluster();
  573. this.createSelectedServices();
  574. this.createConfigurations();
  575. this.createComponents();
  576. this.registerHostsToCluster();
  577. if (App.supports.hostOverridesInstaller) {
  578. this.createConfigurationGroups();
  579. }
  580. this.createAllHostComponents();
  581. this.createHostOverrideConfigurations();
  582. this.ajaxQueueFinished = function () {
  583. console.log('everything is loaded');
  584. App.router.send('next');
  585. };
  586. this.doNextAjaxCall();
  587. },
  588. /**
  589. * Used in progress bar
  590. */
  591. ajaxQueueLength: function () {
  592. return this.get('ajaxQueue').length;
  593. }.property('ajaxQueue.length'),
  594. /**
  595. * Used in progress bar
  596. */
  597. ajaxQueueLeft: 0,
  598. setAmbariUIDb: function () {
  599. var dbContent = this.get('content.slaveGroupProperties');
  600. var slaveComponentConfig = this.get("slaveComponentConfig");
  601. this.persistKeyValues(slaveComponentConfig.version, dbContent);
  602. this.persistKeyValues('current_version', slaveComponentConfig.version);
  603. },
  604. persistKeyValues: function (key, value) {
  605. var str = "{ '" + key + "' : '" + JSON.stringify(value) + "'}";
  606. var obj = eval("(" + str + ")");
  607. this.ajax({
  608. type: "POST",
  609. url: App.apiPrefix + '/persist',
  610. data: JSON.stringify(obj),
  611. beforeSend: function () {
  612. console.log('BeforeSend: persistKeyValues', obj);
  613. }
  614. });
  615. },
  616. clusterName: function () {
  617. return this.get('content.cluster.name');
  618. }.property('content.cluster.name'),
  619. clusterNames: [],
  620. // returns an array of existing cluster names.
  621. // returns an empty array if there are no existing clusters.
  622. getExistingClusterNames: function () {
  623. var url = App.apiPrefix + '/clusters';
  624. App.ajax.send({
  625. name: 'wizard.step8.existing_cluster_names',
  626. sender: this,
  627. success: 'getExistingClusterNamesSuccessCallBack',
  628. error: 'getExistingClusterNamesErrorCallback'
  629. });
  630. return this.get('clusterNames');
  631. },
  632. getExistingClusterNamesSuccessCallBack: function (data) {
  633. var clusterNames = data.items.mapProperty('Clusters.cluster_name');
  634. console.log("Got existing cluster names: " + clusterNames);
  635. this.set('clusterNames', clusterNames);
  636. },
  637. getExistingClusterNamesErrorCallback: function () {
  638. console.log("Failed to get existing cluster names");
  639. this.set('clusterNames', []);
  640. },
  641. deleteClusters: function (clusterNames) {
  642. clusterNames.forEach(function (clusterName) {
  643. App.ajax.send({
  644. name: 'wizard.step8.delete_cluster',
  645. sender: this,
  646. data: {
  647. name: clusterName
  648. },
  649. success: 'deleteClustersSuccessCallback',
  650. error: 'deleteClustersErrorCallback'
  651. });
  652. }, this);
  653. },
  654. deleteClustersSuccessCallback: function(data, opt, params) {
  655. console.log('DELETE cluster ' + params.name + ' succeeded');
  656. },
  657. deleteClustersErrorCallback: function(request, ajaxOptions, error, opt) {
  658. console.log('DELETE cluster failed');
  659. },
  660. /**
  661. * Updates local repositories for the Ambari server.
  662. */
  663. setLocalRepositories: function () {
  664. if (this.get('content.controllerName') !== 'installerController' || !App.supports.localRepositories) {
  665. return false;
  666. }
  667. var self = this;
  668. var apiUrl = App.get('stack2VersionURL');
  669. var stacks = this.get('content.stacks');
  670. stacks.forEach(function (stack) {
  671. stack.operatingSystems.forEach(function (os) {
  672. if (os.baseUrl !== os.originalBaseUrl) {
  673. console.log("Updating local repository URL from " + os.originalBaseUrl + " -> " + os.baseUrl + ". ", os);
  674. var url = App.apiPrefix + apiUrl + "/operatingSystems/" + os.osType + "/repositories/" + stack.name;
  675. self.ajax({
  676. type: 'PUT',
  677. url: url,
  678. data: JSON.stringify({
  679. "Repositories": {
  680. "base_url": os.baseUrl
  681. }
  682. }),
  683. beforeSend: function () {
  684. console.log("BeforeSend: setLocalRepositories PUT to ", url);
  685. }
  686. });
  687. }
  688. });
  689. });
  690. },
  691. /**
  692. * The following create* functions are called upon submitting Step 8.
  693. */
  694. createCluster: function () {
  695. if (this.get('content.controllerName') !== 'installerController') {
  696. return false;
  697. }
  698. var clusterName = this.get('clusterName');
  699. var url = App.apiPrefix + '/clusters/' + clusterName;
  700. var stackVersion = (this.get('content.installOptions.localRepo')) ? App.currentStackVersion.replace(/(-\d+(\.\d)*)/ig, "Local$&") : App.currentStackVersion;
  701. this.ajax({
  702. type: 'POST',
  703. url: url,
  704. data: JSON.stringify({ "Clusters": {"version": stackVersion }}),
  705. beforeSend: function () {
  706. console.log("BeforeSend: createCluster for " + clusterName);
  707. }
  708. });
  709. },
  710. createSelectedServices: function () {
  711. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/services';
  712. var data = this.createServiceData();
  713. var httpMethod = 'POST';
  714. if (!data.length) {
  715. return;
  716. }
  717. this.ajax({
  718. type: httpMethod,
  719. url: url,
  720. data: JSON.stringify(data),
  721. beforeSend: function () {
  722. console.log('BeforeSend: createSelectedServices ', data);
  723. }
  724. });
  725. },
  726. createServiceData: function () {
  727. var services = this.get('selectedServices').mapProperty('serviceName');
  728. var data = [];
  729. services.forEach(function (_service) {
  730. data.pushObject({"ServiceInfo": { "service_name": _service }});
  731. }, this);
  732. return data;
  733. },
  734. createComponents: function () {
  735. var serviceComponents = require('data/service_components');
  736. var services = this.get('selectedServices').mapProperty('serviceName');
  737. services.forEach(function (_service) {
  738. var components = serviceComponents.filterProperty('service_name', _service);
  739. var componentsData = components.map(function (_component) {
  740. return { "ServiceComponentInfo": { "component_name": _component.component_name } };
  741. });
  742. // Service must be specified in terms of a query for creating multiple components at the same time.
  743. // See AMBARI-1018.
  744. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/services?ServiceInfo/service_name=' + _service;
  745. var data = {
  746. "components": componentsData
  747. };
  748. this.ajax({
  749. type: 'POST',
  750. url: url,
  751. data: JSON.stringify(data),
  752. beforeSend: function () {
  753. console.log('BeforeSend: createComponents for ' + _service, componentsData);
  754. }
  755. });
  756. }, this);
  757. },
  758. registerHostsToCluster: function () {
  759. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts';
  760. var data = this.createRegisterHostData();
  761. if (data.length == 0) {
  762. return;
  763. }
  764. this.ajax({
  765. type: 'POST',
  766. url: url,
  767. data: JSON.stringify(data),
  768. beforeSend: function () {
  769. console.log('BeforeSend: registerHostsToCluster', data);
  770. }
  771. });
  772. },
  773. createRegisterHostData: function () {
  774. var hosts = this.getRegisteredHosts().filterProperty('isInstalled', false);
  775. if (!hosts.length) {
  776. return [];
  777. }
  778. return hosts.map(function (host) {
  779. return {"Hosts": { "host_name": host.hostName}};
  780. });
  781. },
  782. // TODO: review the code for add hosts / add services scenarios...
  783. createAllHostComponents: function () {
  784. var masterHosts = this.get('content.masterComponentHosts');
  785. var slaveHosts = this.get('content.slaveComponentHosts');
  786. var clients = this.get('content.clients');
  787. // note: masterHosts has 'component' vs slaveHosts has 'componentName'
  788. var masterComponents = masterHosts.mapProperty('component').uniq();
  789. masterComponents.forEach(function (component) {
  790. var hostNames = masterHosts.filterProperty('component', component).filterProperty('isInstalled', false).mapProperty('hostName');
  791. this.registerHostsToComponent(hostNames, component);
  792. }, this);
  793. slaveHosts.forEach(function (_slave) {
  794. if (_slave.componentName !== 'CLIENT') {
  795. var hostNames = _slave.hosts.filterProperty('isInstalled', false).mapProperty('hostName');
  796. this.registerHostsToComponent(hostNames, _slave.componentName);
  797. } else {
  798. clients.forEach(function (_client) {
  799. var hostNames = _slave.hosts.mapProperty('hostName');
  800. switch (_client.component_name) {
  801. case 'HDFS_CLIENT':
  802. // install HDFS_CLIENT on HBASE_MASTER, HBASE_REGIONSERVER, WEBHCAT_SERVER, HISTORYSERVER and OOZIE_SERVER hosts
  803. masterHosts.filterProperty('component', 'HBASE_MASTER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  804. hostNames.pushObject(_masterHost.hostName);
  805. }, this);
  806. masterHosts.filterProperty('component', 'HBASE_REGIONSERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  807. hostNames.pushObject(_masterHost.hostName);
  808. }, this);
  809. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  810. hostNames.pushObject(_masterHost.hostName);
  811. }, this);
  812. masterHosts.filterProperty('component', 'HISTORYSERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  813. hostNames.pushObject(_masterHost.hostName);
  814. }, this);
  815. masterHosts.filterProperty('component', 'OOZIE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  816. hostNames.pushObject(_masterHost.hostName);
  817. }, this);
  818. break;
  819. case 'MAPREDUCE_CLIENT':
  820. // install MAPREDUCE_CLIENT on HIVE_SERVER, OOZIE_SERVER, NAGIOS_SERVER, and WEBHCAT_SERVER hosts
  821. masterHosts.filterProperty('component', 'HIVE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  822. hostNames.pushObject(_masterHost.hostName);
  823. }, this);
  824. masterHosts.filterProperty('component', 'OOZIE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  825. hostNames.pushObject(_masterHost.hostName);
  826. }, this);
  827. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  828. hostNames.pushObject(_masterHost.hostName);
  829. }, this);
  830. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  831. hostNames.pushObject(_masterHost.hostName);
  832. }, this);
  833. break;
  834. case 'OOZIE_CLIENT':
  835. // install OOZIE_CLIENT on NAGIOS_SERVER host
  836. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  837. hostNames.pushObject(_masterHost.hostName);
  838. }, this);
  839. break;
  840. case 'ZOOKEEPER_CLIENT':
  841. // install ZOOKEEPER_CLIENT on WEBHCAT_SERVER host
  842. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  843. hostNames.pushObject(_masterHost.hostName);
  844. }, this);
  845. break;
  846. case 'HIVE_CLIENT':
  847. //install HIVE client on NAGIOS_SERVER host
  848. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  849. hostNames.pushObject(_masterHost.hostName);
  850. }, this);
  851. masterHosts.filterProperty('component', 'HIVE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  852. hostNames.pushObject(_masterHost.hostName);
  853. }, this);
  854. break;
  855. case 'HCAT':
  856. // install HCAT (client) on NAGIOS_SERVER host
  857. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  858. hostNames.pushObject(_masterHost.hostName);
  859. }, this);
  860. break;
  861. case 'YARN_CLIENT':
  862. // install YARN_CLIENT on NAGIOS_SERVER,HIVE_SERVER,OOZIE_SERVER,WEBHCAT_SERVER host
  863. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  864. hostNames.pushObject(_masterHost.hostName);
  865. }, this);
  866. masterHosts.filterProperty('component', 'HIVE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  867. hostNames.pushObject(_masterHost.hostName);
  868. }, this);
  869. masterHosts.filterProperty('component', 'OOZIE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  870. hostNames.pushObject(_masterHost.hostName);
  871. }, this);
  872. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  873. hostNames.pushObject(_masterHost.hostName);
  874. }, this);
  875. break;
  876. }
  877. hostNames = hostNames.uniq();
  878. if (_client.isInstalled) {
  879. //check whether clients are already installed on selected master hosts!!!
  880. var installedHosts = _slave.hosts.filterProperty('isInstalled', true).mapProperty('hostName');
  881. installedHosts.forEach(function (host) {
  882. if (hostNames.contains(host)) {
  883. hostNames.splice(hostNames.indexOf(host), 1);
  884. }
  885. }, this);
  886. }
  887. this.registerHostsToComponent(hostNames, _client.component_name);
  888. }, this);
  889. }
  890. }, this);
  891. // add Ganglia Monitor (Slave) to all hosts if Ganglia service is selected
  892. var gangliaService = this.get('content.services').filterProperty('isSelected', true).findProperty('serviceName', 'GANGLIA');
  893. if (gangliaService) {
  894. var hosts = this.getRegisteredHosts();
  895. if (gangliaService.get('isInstalled')) {
  896. hosts = hosts.filterProperty('isInstalled', false);
  897. }
  898. if (hosts.length) {
  899. this.registerHostsToComponent(hosts.mapProperty('hostName'), 'GANGLIA_MONITOR');
  900. }
  901. }
  902. // add MySQL Server if Hive is selected
  903. var hiveService = this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).findProperty('serviceName', 'HIVE');
  904. if (hiveService) {
  905. var hiveDb = this.get('content.serviceConfigProperties').findProperty('name', 'hive_database');
  906. if(hiveDb.value == "New MySQL Database") {
  907. this.registerHostsToComponent(masterHosts.filterProperty('component', 'HIVE_SERVER').mapProperty('hostName'), 'MYSQL_SERVER');
  908. }
  909. }
  910. },
  911. registerHostsToComponent: function (hostNames, componentName) {
  912. if (hostNames.length == 0) {
  913. return;
  914. }
  915. var queryStr = '';
  916. hostNames.forEach(function (hostName) {
  917. queryStr += 'Hosts/host_name=' + hostName + '|';
  918. });
  919. //slice off last symbol '|'
  920. queryStr = queryStr.slice(0, -1);
  921. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts';
  922. var data = {
  923. "RequestInfo": {
  924. "query": queryStr
  925. },
  926. "Body": {
  927. "host_components": [
  928. {
  929. "HostRoles": {
  930. "component_name": componentName
  931. }
  932. }
  933. ]
  934. }
  935. };
  936. this.ajax({
  937. type: 'POST',
  938. url: url,
  939. data: JSON.stringify(data)
  940. });
  941. },
  942. createConfigurations: function () {
  943. var selectedServices = this.get('selectedServices');
  944. if (this.get('content.controllerName') == 'installerController') {
  945. this.get('serviceConfigTags').pushObject(this.createCoreSiteObj());
  946. this.get('serviceConfigTags').pushObject(this.createHdfsSiteObj());
  947. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HDFS'));
  948. }
  949. var globalSiteObj = this.createGlobalSiteObj();
  950. if (this.get('content.controllerName') == 'addServiceController') {
  951. globalSiteObj.tag = 'version' + (new Date).getTime();
  952. }
  953. this.get('serviceConfigTags').pushObject(globalSiteObj);
  954. if (selectedServices.someProperty('serviceName', 'MAPREDUCE')) {
  955. this.get('serviceConfigTags').pushObject(this.createMrSiteObj());
  956. if (App.supports.capacitySchedulerUi) {
  957. this.get('serviceConfigTags').pushObject(this.createCapacityScheduler());
  958. this.get('serviceConfigTags').pushObject(this.createMapredQueueAcls());
  959. }
  960. this.get('serviceConfigTags').pushObject(this.createLog4jObj('MAPREDUCE'));
  961. }
  962. if (selectedServices.someProperty('serviceName', 'MAPREDUCE2')) {
  963. this.get('serviceConfigTags').pushObject(this.createMrSiteObj());
  964. this.get('serviceConfigTags').pushObject(this.createLog4jObj('MAPREDUCE2'));
  965. }
  966. if (selectedServices.someProperty('serviceName', 'YARN')) {
  967. this.get('serviceConfigTags').pushObject(this.createYarnSiteObj());
  968. this.get('serviceConfigTags').pushObject(this.createCapacityScheduler());
  969. this.get('serviceConfigTags').pushObject(this.createLog4jObj('YARN'));
  970. }
  971. if (selectedServices.someProperty('serviceName', 'HBASE')) {
  972. this.get('serviceConfigTags').pushObject(this.createHbaseSiteObj());
  973. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HBASE'));
  974. }
  975. if (selectedServices.someProperty('serviceName', 'OOZIE')) {
  976. this.get('serviceConfigTags').pushObject(this.createOozieSiteObj('OOZIE'));
  977. this.get('serviceConfigTags').pushObject(this.createLog4jObj('OOZIE'));
  978. }
  979. if (selectedServices.someProperty('serviceName', 'HIVE')) {
  980. this.get('serviceConfigTags').pushObject(this.createHiveSiteObj('HIVE'));
  981. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HIVE'));
  982. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HIVE-EXEC'));
  983. }
  984. if (selectedServices.someProperty('serviceName', 'WEBHCAT')) {
  985. this.get('serviceConfigTags').pushObject(this.createWebHCatSiteObj('WEBHCAT'));
  986. }
  987. if (selectedServices.someProperty('serviceName', 'HUE')) {
  988. this.get('serviceConfigTags').pushObject(this.createHueSiteObj('HUE'));
  989. }
  990. if (selectedServices.someProperty('serviceName', 'PIG')) {
  991. this.get('serviceConfigTags').pushObject(this.createLog4jObj('PIG'));
  992. }
  993. if (selectedServices.someProperty('serviceName', 'FALCON')) {
  994. this.get('serviceConfigTags').pushObject(this.createFalconSiteObj('FALCON'));
  995. }
  996. if (selectedServices.someProperty('serviceName', 'STORM')) {
  997. this.get('serviceConfigTags').pushObject(this.createStormSiteObj());
  998. }
  999. if (selectedServices.someProperty('serviceName', 'TEZ')) {
  1000. this.get('serviceConfigTags').pushObject(this.createTezSiteObj());
  1001. }
  1002. if (selectedServices.someProperty('serviceName', 'ZOOKEEPER')) {
  1003. this.get('serviceConfigTags').pushObject(this.createZooCfgObj());
  1004. this.get('serviceConfigTags').pushObject(this.createLog4jObj('ZOOKEEPER'));
  1005. }
  1006. this.applyConfigurationsToCluster();
  1007. },
  1008. applyConfigurationsToCluster: function() {
  1009. var clusterUrl = App.apiPrefix + '/clusters/' + this.get('clusterName');
  1010. var configData = [];
  1011. this.get('serviceConfigTags').forEach(function (_serviceConfig) {
  1012. var Clusters = {
  1013. Clusters: {
  1014. desired_config: {
  1015. type: _serviceConfig.type,
  1016. tag: _serviceConfig.tag,
  1017. properties: _serviceConfig.properties
  1018. }
  1019. }
  1020. };
  1021. configData.pushObject(JSON.stringify(Clusters));
  1022. }, this);
  1023. var data = {
  1024. configData: '[' + configData.toString() + ']'
  1025. };
  1026. console.debug("applyConfigurationsToCluster(Step8): Applying to URL", clusterUrl, " Data:", data.configData);
  1027. this.ajax({
  1028. type: 'PUT',
  1029. url: clusterUrl,
  1030. data: data.configData,
  1031. beforeSend: function () {
  1032. console.log("BeforeSend: Updating cluster config");
  1033. }
  1034. });
  1035. },
  1036. createConfigurationGroups: function () {
  1037. var configGroups = this.get('content.configGroups').filterProperty('isDefault', false);
  1038. var clusterName = this.get('clusterName');
  1039. var sendData = [];
  1040. var updateData = [];
  1041. var serviceConfigController = App.router.get('mainServiceInfoConfigsController');
  1042. var timeTag = (new Date).getTime();
  1043. var groupsToDelete = App.router.get(this.get('content.controllerName')).getDBProperty('groupsToDelete');
  1044. if (groupsToDelete && groupsToDelete.length > 0) {
  1045. this.removeInstalledServicesConfigurationGroups(groupsToDelete);
  1046. }
  1047. configGroups.forEach(function (configGroup) {
  1048. var groupConfigs = [];
  1049. var groupData = {
  1050. "cluster_name": clusterName,
  1051. "group_name": configGroup.name,
  1052. "tag": configGroup.service.id,
  1053. "description": configGroup.description,
  1054. "hosts": [],
  1055. "desired_configs": []
  1056. };
  1057. configGroup.hosts.forEach(function (hostName) {
  1058. groupData.hosts.push({"host_name": hostName});
  1059. });
  1060. //wrap properties into Em.Object to make them compatible with buildGroupDesiredConfigs method
  1061. configGroup.properties.forEach(function (property) {
  1062. groupConfigs.push(Em.Object.create(property));
  1063. });
  1064. groupData.desired_configs = serviceConfigController.buildGroupDesiredConfigs.call(serviceConfigController, groupConfigs, timeTag);
  1065. // check for group from installed service
  1066. if (configGroup.isForUpdate === true) {
  1067. // if group is a new one, create it
  1068. if (!configGroup.id) {
  1069. sendData.push({"ConfigGroup": groupData});
  1070. } else {
  1071. // update an existing group
  1072. groupData.id = configGroup.id;
  1073. updateData.push({"ConfigGroup": groupData});
  1074. }
  1075. } else {
  1076. sendData.push({"ConfigGroup": groupData});
  1077. }
  1078. //each group should have unique tag to prevent overriding configs from common sites
  1079. timeTag++;
  1080. }, this);
  1081. if (sendData.length > 0) {
  1082. this.applyConfigurationGroups(sendData);
  1083. }
  1084. if (updateData.length > 0) {
  1085. this.applyInstalledServicesConfigurationGroup(updateData);
  1086. }
  1087. },
  1088. applyConfigurationGroups: function (sendData) {
  1089. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/config_groups';
  1090. this.ajax({
  1091. type: 'POST',
  1092. url: url,
  1093. data: JSON.stringify(sendData)
  1094. });
  1095. },
  1096. applyInstalledServicesConfigurationGroup: function (updateData) {
  1097. updateData.forEach(function(item) {
  1098. App.router.get('mainServiceInfoConfigsController').putConfigGroupChanges(item);
  1099. });
  1100. },
  1101. removeInstalledServicesConfigurationGroups: function(groupsToDelete) {
  1102. groupsToDelete.forEach(function(item) {
  1103. App.config.deleteConfigGroup(Em.Object.create(item));
  1104. });
  1105. },
  1106. createGlobalSiteObj: function () {
  1107. var globalSiteProperties = {};
  1108. var globalSiteObj = this.get('globals');
  1109. var isGLUSTERFSSelected = this.get('selectedServices').someProperty('serviceName', 'GLUSTERFS');
  1110. // screen out the GLUSTERFS-specific global config entries when they are not required
  1111. if (!isGLUSTERFSSelected) {
  1112. globalSiteObj = globalSiteObj.filter(function(_config) {
  1113. return _config.name.indexOf("fs_glusterfs") < 0;
  1114. });
  1115. }
  1116. globalSiteObj.forEach(function (_globalSiteObj) {
  1117. var heapsizeException = ['hadoop_heapsize','yarn_heapsize','nodemanager_heapsize','resourcemanager_heapsize'];
  1118. // do not pass any globals whose name ends with _host or _hosts
  1119. if (_globalSiteObj.isRequiredByAgent !== false) {
  1120. // append "m" to JVM memory options except for hadoop_heapsize
  1121. if (/_heapsize|_newsize|_maxnewsize$/.test(_globalSiteObj.name) && !heapsizeException.contains(_globalSiteObj.name)) {
  1122. globalSiteProperties[_globalSiteObj.name] = _globalSiteObj.value + "m";
  1123. } else {
  1124. globalSiteProperties[_globalSiteObj.name] = App.config.escapeXMLCharacters(_globalSiteObj.value);
  1125. }
  1126. }
  1127. this._recordHostOverrideFromObj(_globalSiteObj, 'global', 'version1', this);
  1128. }, this);
  1129. // we don't expose gmond_user to the user; it needs to be the same as gmetad_user
  1130. globalSiteProperties['gmond_user'] = globalSiteProperties['gmetad_user'];
  1131. return {"type": "global", "tag": "version1", "properties": globalSiteProperties};
  1132. },
  1133. createCoreSiteObj: function () {
  1134. var coreSiteObj = this.get('configs').filterProperty('filename', 'core-site.xml');
  1135. var coreSiteProperties = {};
  1136. // hadoop.proxyuser.oozie.hosts needs to be skipped if oozie is not selected
  1137. var isOozieSelected = this.get('selectedServices').someProperty('serviceName', 'OOZIE');
  1138. var oozieUser = this.get('globals').someProperty('name', 'oozie_user') ? this.get('globals').findProperty('name', 'oozie_user').value : null;
  1139. var isHiveSelected = this.get('selectedServices').someProperty('serviceName', 'HIVE');
  1140. var hiveUser = this.get('globals').someProperty('name', 'hive_user') ? this.get('globals').findProperty('name', 'hive_user').value : null;
  1141. var isHcatSelected = this.get('selectedServices').someProperty('serviceName', 'WEBHCAT');
  1142. var hcatUser = this.get('globals').someProperty('name', 'hcat_user') ? this.get('globals').findProperty('name', 'hcat_user').value : null;
  1143. var isGLUSTERFSSelected = this.get('selectedServices').someProperty('serviceName', 'GLUSTERFS');
  1144. // screen out the GLUSTERFS-specific core-site.xml entries when they are not needed
  1145. if (!isGLUSTERFSSelected) {
  1146. coreSiteObj = coreSiteObj.filter(function(_config) {
  1147. return _config.name.indexOf("fs.glusterfs") < 0;
  1148. });
  1149. }
  1150. coreSiteObj.forEach(function (_coreSiteObj) {
  1151. 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'))) {
  1152. coreSiteProperties[_coreSiteObj.name] = App.config.escapeXMLCharacters(_coreSiteObj.value);
  1153. this._recordHostOverrideFromObj(_coreSiteObj, 'core-site', 'version1', this);
  1154. }
  1155. if (isGLUSTERFSSelected && _coreSiteObj.name == "fs.default.name") {
  1156. 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;
  1157. }
  1158. if (isGLUSTERFSSelected && _coreSiteObj.name == "fs.defaultFS") {
  1159. coreSiteProperties[_coreSiteObj.name] = this.get('globals').someProperty('name', 'glusterfs_defaultFS_name') ? App.config.escapeXMLCharacters(this.get('globals').findProperty('name', 'glusterfs_defaultFS_name').value) : null;
  1160. }
  1161. console.log("STEP*: name of the property is: " + _coreSiteObj.name);
  1162. console.log("STEP8: value of the property is: " + _coreSiteObj.value);
  1163. }, this);
  1164. return {"type": "core-site", "tag": "version1", "properties": coreSiteProperties};
  1165. },
  1166. createHdfsSiteObj: function () {
  1167. var hdfsSiteObj = this.get('configs').filterProperty('filename', 'hdfs-site.xml');
  1168. var hdfsProperties = {};
  1169. hdfsSiteObj.forEach(function (_configProperty) {
  1170. hdfsProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1171. this._recordHostOverrideFromObj(_configProperty, 'hdfs-site', 'version1', this);
  1172. console.log("STEP*: name of the property is: " + _configProperty.name);
  1173. console.log("STEP8: value of the property is: " + _configProperty.value);
  1174. }, this);
  1175. return {"type": "hdfs-site", "tag": "version1", "properties": hdfsProperties };
  1176. },
  1177. createLog4jObj: function (fileName) {
  1178. fileName = fileName.toLowerCase();
  1179. var Log4jObj = this.get('configs').filterProperty('filename', fileName + '-log4j.xml');
  1180. var Log4jProperties = {};
  1181. Log4jObj.forEach(function (_configProperty) {
  1182. Log4jProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1183. this._recordHostOverrideFromObj(_configProperty, fileName + '-log4j', 'version1', this);
  1184. console.log("STEP*: name of the property is: " + _configProperty.name);
  1185. console.log("STEP8: value of the property is: " + _configProperty.value);
  1186. }, this);
  1187. return {"type": fileName + "-log4j", "tag": "version1", "properties": Log4jProperties };
  1188. },
  1189. createHueSiteObj: function () {
  1190. var hueSiteObj = this.get('configs').filterProperty('filename', 'hue-site.xml');
  1191. var hueProperties = {};
  1192. hueSiteObj.forEach(function (_configProperty) {
  1193. hueProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1194. this._recordHostOverrideFromObj(_configProperty, 'hue-site', 'version1', this);
  1195. console.log("STEP*: name of the property is: " + _configProperty.name);
  1196. console.log("STEP8: value of the property is: " + _configProperty.value);
  1197. }, this);
  1198. return {"type": "hue-site", "tag": "version1", "properties": hueProperties };
  1199. },
  1200. createMrSiteObj: function () {
  1201. var configs = this.get('configs').filterProperty('filename', 'mapred-site.xml');
  1202. var mrProperties = {};
  1203. configs.forEach(function (_configProperty) {
  1204. mrProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1205. this._recordHostOverrideFromObj(_configProperty, 'mapred-site', 'version1', this);
  1206. console.log("STEP*: name of the property is: " + _configProperty.name);
  1207. console.log("STEP8: value of the property is: " + _configProperty.value);
  1208. }, this);
  1209. return {type: 'mapred-site', tag: 'version1', properties: mrProperties};
  1210. },
  1211. createYarnSiteObj: function () {
  1212. var configs = this.get('configs').filterProperty('filename', 'yarn-site.xml');
  1213. var mrProperties = {};
  1214. configs.forEach(function (_configProperty) {
  1215. mrProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1216. this._recordHostOverrideFromObj(_configProperty, 'yarn-site', 'version1', this);
  1217. console.log("STEP*: name of the property is: " + _configProperty.name);
  1218. console.log("STEP8: value of the property is: " + _configProperty.value);
  1219. }, this);
  1220. return {type: 'yarn-site', tag: 'version1', properties: mrProperties};
  1221. },
  1222. createCapacityScheduler: function () {
  1223. var configs = this.get('configs').filterProperty('filename', 'capacity-scheduler.xml');
  1224. var csProperties = {};
  1225. configs.forEach(function (_configProperty) {
  1226. csProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1227. this._recordHostOverrideFromObj(_configProperty, 'capacity-scheduler', 'version1', this);
  1228. console.log("STEP*: name of the property is: " + _configProperty.name);
  1229. console.log("STEP8: value of the property is: " + _configProperty.value);
  1230. }, this);
  1231. return {type: 'capacity-scheduler', tag: 'version1', properties: csProperties};
  1232. },
  1233. createMapredQueueAcls: function () {
  1234. var configs = this.get('configs').filterProperty('filename', 'mapred-queue-acls.xml');
  1235. var mqProperties = {};
  1236. configs.forEach(function (_configProperty) {
  1237. mqProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1238. this._recordHostOverrideFromObj(_configProperty, 'mapred-queue-acls', 'version1', this);
  1239. console.log("STEP*: name of the property is: " + _configProperty.name);
  1240. console.log("STEP8: value of the property is: " + _configProperty.value);
  1241. }, this);
  1242. return {type: 'mapred-queue-acls', tag: 'version1', properties: mqProperties};
  1243. },
  1244. createHbaseSiteObj: function () {
  1245. var configs = this.get('configs').filterProperty('filename', 'hbase-site.xml');
  1246. var hbaseProperties = {};
  1247. configs.forEach(function (_configProperty) {
  1248. hbaseProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1249. this._recordHostOverrideFromObj(_configProperty, 'hbase-site', 'version1', this);
  1250. }, this);
  1251. return {type: 'hbase-site', tag: 'version1', properties: hbaseProperties};
  1252. },
  1253. createOozieSiteObj: function (serviceName) {
  1254. var configs = this.get('configs').filterProperty('filename', 'oozie-site.xml');
  1255. var oozieProperties = {};
  1256. configs.forEach(function (_configProperty) {
  1257. oozieProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1258. this._recordHostOverrideFromObj(_configProperty, 'oozie-site', 'version1', this);
  1259. }, this);
  1260. return {type: 'oozie-site', tag: 'version1', properties: oozieProperties};
  1261. },
  1262. createHiveSiteObj: function (serviceName) {
  1263. var configs = this.get('configs').filterProperty('filename', 'hive-site.xml');
  1264. var hiveProperties = {};
  1265. configs.forEach(function (_configProperty) {
  1266. hiveProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1267. this._recordHostOverrideFromObj(_configProperty, 'hive-site', 'version1', this);
  1268. }, this);
  1269. return {type: 'hive-site', tag: 'version1', properties: hiveProperties};
  1270. },
  1271. createWebHCatSiteObj: function (serviceName) {
  1272. var configs = this.get('configs').filterProperty('filename', 'webhcat-site.xml');
  1273. var webHCatProperties = {};
  1274. configs.forEach(function (_configProperty) {
  1275. webHCatProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1276. this._recordHostOverrideFromObj(_configProperty, 'webhcat-site', 'version1', this);
  1277. }, this);
  1278. return {type: 'webhcat-site', tag: 'version1', properties: webHCatProperties};
  1279. },
  1280. createZooCfgObj: function () {
  1281. var configs = this.get('configs').filterProperty('filename', 'zoo.cfg');
  1282. var csProperties = {};
  1283. configs.forEach(function (_configProperty) {
  1284. csProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1285. this._recordHostOverrideFromObj(_configProperty, 'zoo.cfg', 'version1', this);
  1286. }, this);
  1287. return {type: 'zoo.cfg', tag: 'version1', properties: csProperties};
  1288. },
  1289. createStormSiteObj: function () {
  1290. var configs = this.get('configs').filterProperty('filename', 'storm-site.xml');
  1291. var stormProperties = {};
  1292. var specialProperties = ["storm.zookeeper.servers", "nimbus.childopts", "supervisor.childopts", "worker.childopts"];
  1293. configs.forEach(function (_configProperty) {
  1294. if (specialProperties.contains(_configProperty.name)) {
  1295. if (_configProperty.name == "storm.zookeeper.servers") {
  1296. stormProperties[_configProperty.name] = JSON.stringify(_configProperty.value).replace(/"/g, "'");
  1297. } else {
  1298. stormProperties[_configProperty.name] = JSON.stringify(_configProperty.value).replace(/"/g,"");
  1299. }
  1300. } else {
  1301. stormProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1302. }
  1303. this._recordHostOverrideFromObj(_configProperty, 'storm-site', 'version1', this);
  1304. }, this);
  1305. return {type: 'storm-site', tag: 'version1', properties: stormProperties};
  1306. },
  1307. createTezSiteObj: function () {
  1308. var configs = this.get('configs').filterProperty('filename', 'tez-site.xml');
  1309. var tezProperty = {};
  1310. configs.forEach(function (_configProperty) {
  1311. tezProperty[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1312. this._recordHostOverrideFromObj(_configProperty, 'tez-site', 'version1', this);
  1313. }, this);
  1314. return {type: 'tez-site', tag: 'version1', properties: tezProperty};
  1315. },
  1316. createFalconSiteObj: function (s) {
  1317. var configs = this.get('configs').filterProperty('filename', 'oozie-site.xml');
  1318. var falconProperties = {};
  1319. configs.forEach(function (_configProperty) {
  1320. falconProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1321. this._recordHostOverrideFromObj(_configProperty, 'oozie-site', 'version1', this);
  1322. }, this);
  1323. return {type: 'oozie-site', tag: 'version1', properties: falconProperties};
  1324. },
  1325. ajaxQueueFinished: function () {
  1326. //do something
  1327. },
  1328. doNextAjaxCall: function () {
  1329. if (this.get('ajaxBusy')) {
  1330. return;
  1331. }
  1332. var queue = this.get('ajaxQueue');
  1333. if (!queue.length) {
  1334. this.ajaxQueueFinished();
  1335. return;
  1336. }
  1337. var first = queue[0];
  1338. this.set('ajaxQueue', queue.slice(1));
  1339. this.set('ajaxQueueLeft', this.get('ajaxQueue').length);
  1340. this.set('ajaxBusy', true);
  1341. $.ajax(first);
  1342. },
  1343. /**
  1344. * Records all the host overrides per site/tag
  1345. */
  1346. _recordHostOverrideFromObj: function(serviceConfigObj, siteName, tagName, self){
  1347. var overrides = serviceConfigObj.overrides;
  1348. if(overrides && overrides.length>0){
  1349. overrides.forEach(function(override){
  1350. override.hosts.forEach(function(host){
  1351. if(!(host in self.savedHostToOverrideSiteToTagMap)){
  1352. self.savedHostToOverrideSiteToTagMap[host] = {};
  1353. }
  1354. if(!(siteName in self.savedHostToOverrideSiteToTagMap[host])){
  1355. self.savedHostToOverrideSiteToTagMap[host][siteName] = {};
  1356. self.savedHostToOverrideSiteToTagMap[host][siteName].map = {};
  1357. }
  1358. var finalTag = tagName + '_' + host;
  1359. console.log("recordHostOverride(): Saving host override for host="+host+", site="+siteName+", tag="+finalTag+", (key,value)=("+serviceConfigObj.name+","+override.value+")");
  1360. self.savedHostToOverrideSiteToTagMap[host][siteName].tagName = finalTag;
  1361. self.savedHostToOverrideSiteToTagMap[host][siteName].map[serviceConfigObj.name] = override.value;
  1362. });
  1363. });
  1364. }
  1365. },
  1366. /**
  1367. * Creates host level overrides for service configuration.
  1368. *
  1369. */
  1370. createHostOverrideConfigurations: function () {
  1371. var singlePUTHostData = [];
  1372. var savedHostSiteArray = [];
  1373. for ( var host in this.savedHostToOverrideSiteToTagMap) {
  1374. for ( var siteName in this.savedHostToOverrideSiteToTagMap[host]) {
  1375. var tagName = this.savedHostToOverrideSiteToTagMap[host][siteName].tagName;
  1376. var map = this.savedHostToOverrideSiteToTagMap[host][siteName].map;
  1377. savedHostSiteArray.push(host + "///" + siteName);
  1378. singlePUTHostData.push({
  1379. RequestInfo: {
  1380. query: 'Hosts/host_name='+host
  1381. },
  1382. Body: {
  1383. Hosts: {
  1384. desired_config: {
  1385. type: siteName,
  1386. tag: tagName,
  1387. properties: map
  1388. }
  1389. }
  1390. }
  1391. });
  1392. }
  1393. }
  1394. console.log("createHostOverrideConfigSites(): PUTting host-overrides. Data=", singlePUTHostData);
  1395. if(singlePUTHostData.length>0){
  1396. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts';
  1397. this.ajax({
  1398. type: 'PUT',
  1399. url: url,
  1400. data: JSON.stringify(singlePUTHostData),
  1401. dataType: 'text',
  1402. beforeSend: function () {
  1403. console.log("createHostOverrideConfigSites() PUT override=", singlePUTHostData);
  1404. }
  1405. });
  1406. }
  1407. },
  1408. /**
  1409. * We need to do a lot of ajax calls async in special order. To do this,
  1410. * generate array of ajax objects and then send requests step by step. All
  1411. * ajax objects are stored in <code>ajaxQueue</code>
  1412. *
  1413. * @param params
  1414. */
  1415. ajax: function (params) {
  1416. if (App.testMode) return;
  1417. var self = this;
  1418. params = jQuery.extend({
  1419. async: true,
  1420. dataType: 'text',
  1421. statusCode: require('data/statusCodes'),
  1422. timeout: App.timeout,
  1423. error: function (request, ajaxOptions, error) {
  1424. console.log('Step8: In Error ');
  1425. // console.log('Step8: Error message is: ' + request.responseText);
  1426. },
  1427. success: function (data) {
  1428. console.log("TRACE: STep8 -> In success function");
  1429. }
  1430. }, params);
  1431. var success = params.success;
  1432. var error = params.error;
  1433. params.success = function () {
  1434. if (success) {
  1435. success();
  1436. }
  1437. self.set('ajaxBusy', false);
  1438. self.doNextAjaxCall();
  1439. };
  1440. params.error = function (xhr, status, error) {
  1441. var responseText = JSON.parse(xhr.responseText);
  1442. var controller = App.router.get(App.clusterStatus.wizardControllerName);
  1443. controller.registerErrPopup(Em.I18n.t('common.error'), responseText.message);
  1444. self.set('hasErrorOccurred', true);
  1445. // an error will break the ajax call chain and allow submission again
  1446. self.set('isSubmitDisabled', false);
  1447. self.set('isBackBtnDisabled', false);
  1448. App.router.get(self.get('content.controllerName')).setStepsEnable();
  1449. self.get('ajaxQueue').clear();
  1450. self.set('ajaxBusy', false);
  1451. };
  1452. this.get('ajaxQueue').pushObject(params);
  1453. }
  1454. });