step8_controller.js 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603
  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. case 'TEZ_CLIENT':
  877. //install TEZ client on HIVE_SERVER, HIVE_CLIENT hosts.
  878. //HIVE_CLIENT always installed on NAGIOS_SERVER host, so it is the same host with NAGIOS_SERVER and HIVE_CLIENT
  879. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  880. hostNames.pushObject(_masterHost.hostName);
  881. }, this);
  882. masterHosts.filterProperty('component', 'HIVE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  883. hostNames.pushObject(_masterHost.hostName);
  884. }, this);
  885. break;
  886. }
  887. hostNames = hostNames.uniq();
  888. if (_client.isInstalled) {
  889. //check whether clients are already installed on selected master hosts!!!
  890. var installedHosts = _slave.hosts.filterProperty('isInstalled', true).mapProperty('hostName');
  891. installedHosts.forEach(function (host) {
  892. if (hostNames.contains(host)) {
  893. hostNames.splice(hostNames.indexOf(host), 1);
  894. }
  895. }, this);
  896. }
  897. this.registerHostsToComponent(hostNames, _client.component_name);
  898. }, this);
  899. }
  900. }, this);
  901. // add Ganglia Monitor (Slave) to all hosts if Ganglia service is selected
  902. var gangliaService = this.get('content.services').filterProperty('isSelected', true).findProperty('serviceName', 'GANGLIA');
  903. if (gangliaService) {
  904. var hosts = this.getRegisteredHosts();
  905. if (gangliaService.get('isInstalled')) {
  906. hosts = hosts.filterProperty('isInstalled', false);
  907. }
  908. if (hosts.length) {
  909. this.registerHostsToComponent(hosts.mapProperty('hostName'), 'GANGLIA_MONITOR');
  910. }
  911. }
  912. // add MySQL Server if Hive is selected
  913. var hiveService = this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).findProperty('serviceName', 'HIVE');
  914. if (hiveService) {
  915. var hiveDb = this.get('content.serviceConfigProperties').findProperty('name', 'hive_database');
  916. if(hiveDb.value == "New MySQL Database") {
  917. this.registerHostsToComponent(masterHosts.filterProperty('component', 'HIVE_SERVER').mapProperty('hostName'), 'MYSQL_SERVER');
  918. }
  919. }
  920. },
  921. registerHostsToComponent: function (hostNames, componentName) {
  922. if (hostNames.length == 0) {
  923. return;
  924. }
  925. var queryStr = '';
  926. hostNames.forEach(function (hostName) {
  927. queryStr += 'Hosts/host_name=' + hostName + '|';
  928. });
  929. //slice off last symbol '|'
  930. queryStr = queryStr.slice(0, -1);
  931. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts';
  932. var data = {
  933. "RequestInfo": {
  934. "query": queryStr
  935. },
  936. "Body": {
  937. "host_components": [
  938. {
  939. "HostRoles": {
  940. "component_name": componentName
  941. }
  942. }
  943. ]
  944. }
  945. };
  946. this.ajax({
  947. type: 'POST',
  948. url: url,
  949. data: JSON.stringify(data)
  950. });
  951. },
  952. createConfigurations: function () {
  953. var selectedServices = this.get('selectedServices');
  954. if (this.get('content.controllerName') == 'installerController') {
  955. this.get('serviceConfigTags').pushObject(this.createCoreSiteObj());
  956. this.get('serviceConfigTags').pushObject(this.createHdfsSiteObj());
  957. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HDFS'));
  958. }
  959. var globalSiteObj = this.createGlobalSiteObj();
  960. if (this.get('content.controllerName') == 'addServiceController') {
  961. globalSiteObj.tag = 'version' + (new Date).getTime();
  962. }
  963. this.get('serviceConfigTags').pushObject(globalSiteObj);
  964. if (selectedServices.someProperty('serviceName', 'MAPREDUCE')) {
  965. this.get('serviceConfigTags').pushObject(this.createMrSiteObj());
  966. if (App.supports.capacitySchedulerUi) {
  967. this.get('serviceConfigTags').pushObject(this.createCapacityScheduler());
  968. this.get('serviceConfigTags').pushObject(this.createMapredQueueAcls());
  969. }
  970. this.get('serviceConfigTags').pushObject(this.createLog4jObj('MAPREDUCE'));
  971. }
  972. if (selectedServices.someProperty('serviceName', 'MAPREDUCE2')) {
  973. this.get('serviceConfigTags').pushObject(this.createMrSiteObj());
  974. this.get('serviceConfigTags').pushObject(this.createLog4jObj('MAPREDUCE2'));
  975. }
  976. if (selectedServices.someProperty('serviceName', 'YARN')) {
  977. this.get('serviceConfigTags').pushObject(this.createYarnSiteObj());
  978. this.get('serviceConfigTags').pushObject(this.createCapacityScheduler());
  979. this.get('serviceConfigTags').pushObject(this.createLog4jObj('YARN'));
  980. }
  981. if (selectedServices.someProperty('serviceName', 'HBASE')) {
  982. this.get('serviceConfigTags').pushObject(this.createHbaseSiteObj());
  983. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HBASE'));
  984. }
  985. if (selectedServices.someProperty('serviceName', 'OOZIE')) {
  986. this.get('serviceConfigTags').pushObject(this.createOozieSiteObj('OOZIE'));
  987. this.get('serviceConfigTags').pushObject(this.createLog4jObj('OOZIE'));
  988. }
  989. if (selectedServices.someProperty('serviceName', 'HIVE')) {
  990. this.get('serviceConfigTags').pushObject(this.createHiveSiteObj('HIVE'));
  991. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HIVE'));
  992. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HIVE-EXEC'));
  993. }
  994. if (selectedServices.someProperty('serviceName', 'WEBHCAT')) {
  995. this.get('serviceConfigTags').pushObject(this.createWebHCatSiteObj('WEBHCAT'));
  996. }
  997. if (selectedServices.someProperty('serviceName', 'HUE')) {
  998. this.get('serviceConfigTags').pushObject(this.createHueSiteObj('HUE'));
  999. }
  1000. if (selectedServices.someProperty('serviceName', 'PIG')) {
  1001. this.get('serviceConfigTags').pushObject(this.createLog4jObj('PIG'));
  1002. }
  1003. if (selectedServices.someProperty('serviceName', 'FALCON')) {
  1004. this.get('serviceConfigTags').pushObject(this.createFalconSiteObj('FALCON'));
  1005. }
  1006. if (selectedServices.someProperty('serviceName', 'STORM')) {
  1007. this.get('serviceConfigTags').pushObject(this.createStormSiteObj());
  1008. }
  1009. if (selectedServices.someProperty('serviceName', 'TEZ')) {
  1010. this.get('serviceConfigTags').pushObject(this.createTezSiteObj());
  1011. }
  1012. if (selectedServices.someProperty('serviceName', 'ZOOKEEPER')) {
  1013. this.get('serviceConfigTags').pushObject(this.createZooCfgObj());
  1014. this.get('serviceConfigTags').pushObject(this.createLog4jObj('ZOOKEEPER'));
  1015. }
  1016. this.applyConfigurationsToCluster();
  1017. },
  1018. applyConfigurationsToCluster: function() {
  1019. var clusterUrl = App.apiPrefix + '/clusters/' + this.get('clusterName');
  1020. var configData = [];
  1021. this.get('serviceConfigTags').forEach(function (_serviceConfig) {
  1022. var Clusters = {
  1023. Clusters: {
  1024. desired_config: {
  1025. type: _serviceConfig.type,
  1026. tag: _serviceConfig.tag,
  1027. properties: _serviceConfig.properties
  1028. }
  1029. }
  1030. };
  1031. configData.pushObject(JSON.stringify(Clusters));
  1032. }, this);
  1033. var data = {
  1034. configData: '[' + configData.toString() + ']'
  1035. };
  1036. console.debug("applyConfigurationsToCluster(Step8): Applying to URL", clusterUrl, " Data:", data.configData);
  1037. this.ajax({
  1038. type: 'PUT',
  1039. url: clusterUrl,
  1040. data: data.configData,
  1041. beforeSend: function () {
  1042. console.log("BeforeSend: Updating cluster config");
  1043. }
  1044. });
  1045. },
  1046. createConfigurationGroups: function () {
  1047. var configGroups = this.get('content.configGroups').filterProperty('isDefault', false);
  1048. var clusterName = this.get('clusterName');
  1049. var sendData = [];
  1050. var updateData = [];
  1051. var serviceConfigController = App.router.get('mainServiceInfoConfigsController');
  1052. var timeTag = (new Date).getTime();
  1053. var groupsToDelete = App.router.get(this.get('content.controllerName')).getDBProperty('groupsToDelete');
  1054. if (groupsToDelete && groupsToDelete.length > 0) {
  1055. this.removeInstalledServicesConfigurationGroups(groupsToDelete);
  1056. }
  1057. configGroups.forEach(function (configGroup) {
  1058. var groupConfigs = [];
  1059. var groupData = {
  1060. "cluster_name": clusterName,
  1061. "group_name": configGroup.name,
  1062. "tag": configGroup.service.id,
  1063. "description": configGroup.description,
  1064. "hosts": [],
  1065. "desired_configs": []
  1066. };
  1067. configGroup.hosts.forEach(function (hostName) {
  1068. groupData.hosts.push({"host_name": hostName});
  1069. });
  1070. //wrap properties into Em.Object to make them compatible with buildGroupDesiredConfigs method
  1071. configGroup.properties.forEach(function (property) {
  1072. groupConfigs.push(Em.Object.create(property));
  1073. });
  1074. groupData.desired_configs = serviceConfigController.buildGroupDesiredConfigs.call(serviceConfigController, groupConfigs, timeTag);
  1075. // check for group from installed service
  1076. if (configGroup.isForUpdate === true) {
  1077. // if group is a new one, create it
  1078. if (!configGroup.id) {
  1079. sendData.push({"ConfigGroup": groupData});
  1080. } else {
  1081. // update an existing group
  1082. groupData.id = configGroup.id;
  1083. updateData.push({"ConfigGroup": groupData});
  1084. }
  1085. } else {
  1086. sendData.push({"ConfigGroup": groupData});
  1087. }
  1088. //each group should have unique tag to prevent overriding configs from common sites
  1089. timeTag++;
  1090. }, this);
  1091. if (sendData.length > 0) {
  1092. this.applyConfigurationGroups(sendData);
  1093. }
  1094. if (updateData.length > 0) {
  1095. this.applyInstalledServicesConfigurationGroup(updateData);
  1096. }
  1097. },
  1098. applyConfigurationGroups: function (sendData) {
  1099. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/config_groups';
  1100. this.ajax({
  1101. type: 'POST',
  1102. url: url,
  1103. data: JSON.stringify(sendData)
  1104. });
  1105. },
  1106. applyInstalledServicesConfigurationGroup: function (updateData) {
  1107. updateData.forEach(function(item) {
  1108. App.router.get('mainServiceInfoConfigsController').putConfigGroupChanges(item);
  1109. });
  1110. },
  1111. removeInstalledServicesConfigurationGroups: function(groupsToDelete) {
  1112. groupsToDelete.forEach(function(item) {
  1113. App.config.deleteConfigGroup(Em.Object.create(item));
  1114. });
  1115. },
  1116. createGlobalSiteObj: function () {
  1117. var globalSiteProperties = {};
  1118. var globalSiteObj = this.get('globals');
  1119. var isGLUSTERFSSelected = this.get('selectedServices').someProperty('serviceName', 'GLUSTERFS');
  1120. // screen out the GLUSTERFS-specific global config entries when they are not required
  1121. if (!isGLUSTERFSSelected) {
  1122. globalSiteObj = globalSiteObj.filter(function(_config) {
  1123. return _config.name.indexOf("fs_glusterfs") < 0;
  1124. });
  1125. }
  1126. globalSiteObj.forEach(function (_globalSiteObj) {
  1127. var heapsizeException = ['hadoop_heapsize','yarn_heapsize','nodemanager_heapsize','resourcemanager_heapsize', 'apptimelineserver_heapsize'];
  1128. // do not pass any globals whose name ends with _host or _hosts
  1129. if (_globalSiteObj.isRequiredByAgent !== false) {
  1130. // append "m" to JVM memory options except for hadoop_heapsize
  1131. if (/_heapsize|_newsize|_maxnewsize$/.test(_globalSiteObj.name) && !heapsizeException.contains(_globalSiteObj.name)) {
  1132. globalSiteProperties[_globalSiteObj.name] = _globalSiteObj.value + "m";
  1133. } else {
  1134. globalSiteProperties[_globalSiteObj.name] = App.config.escapeXMLCharacters(_globalSiteObj.value);
  1135. }
  1136. }
  1137. this._recordHostOverrideFromObj(_globalSiteObj, 'global', 'version1', this);
  1138. }, this);
  1139. // we don't expose gmond_user to the user; it needs to be the same as gmetad_user
  1140. globalSiteProperties['gmond_user'] = globalSiteProperties['gmetad_user'];
  1141. return {"type": "global", "tag": "version1", "properties": globalSiteProperties};
  1142. },
  1143. createCoreSiteObj: function () {
  1144. var coreSiteObj = this.get('configs').filterProperty('filename', 'core-site.xml');
  1145. var coreSiteProperties = {};
  1146. // hadoop.proxyuser.oozie.hosts needs to be skipped if oozie is not selected
  1147. var isOozieSelected = this.get('selectedServices').someProperty('serviceName', 'OOZIE');
  1148. var oozieUser = this.get('globals').someProperty('name', 'oozie_user') ? this.get('globals').findProperty('name', 'oozie_user').value : null;
  1149. var isHiveSelected = this.get('selectedServices').someProperty('serviceName', 'HIVE');
  1150. var hiveUser = this.get('globals').someProperty('name', 'hive_user') ? this.get('globals').findProperty('name', 'hive_user').value : null;
  1151. var isHcatSelected = this.get('selectedServices').someProperty('serviceName', 'WEBHCAT');
  1152. var hcatUser = this.get('globals').someProperty('name', 'hcat_user') ? this.get('globals').findProperty('name', 'hcat_user').value : null;
  1153. var isGLUSTERFSSelected = this.get('selectedServices').someProperty('serviceName', 'GLUSTERFS');
  1154. // screen out the GLUSTERFS-specific core-site.xml entries when they are not needed
  1155. if (!isGLUSTERFSSelected) {
  1156. coreSiteObj = coreSiteObj.filter(function(_config) {
  1157. return _config.name.indexOf("fs.glusterfs") < 0;
  1158. });
  1159. }
  1160. coreSiteObj.forEach(function (_coreSiteObj) {
  1161. 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'))) {
  1162. coreSiteProperties[_coreSiteObj.name] = App.config.escapeXMLCharacters(_coreSiteObj.value);
  1163. this._recordHostOverrideFromObj(_coreSiteObj, 'core-site', 'version1', this);
  1164. }
  1165. if (isGLUSTERFSSelected && _coreSiteObj.name == "fs.default.name") {
  1166. 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;
  1167. }
  1168. if (isGLUSTERFSSelected && _coreSiteObj.name == "fs.defaultFS") {
  1169. coreSiteProperties[_coreSiteObj.name] = this.get('globals').someProperty('name', 'glusterfs_defaultFS_name') ? App.config.escapeXMLCharacters(this.get('globals').findProperty('name', 'glusterfs_defaultFS_name').value) : null;
  1170. }
  1171. console.log("STEP*: name of the property is: " + _coreSiteObj.name);
  1172. console.log("STEP8: value of the property is: " + _coreSiteObj.value);
  1173. }, this);
  1174. return {"type": "core-site", "tag": "version1", "properties": coreSiteProperties};
  1175. },
  1176. createHdfsSiteObj: function () {
  1177. var hdfsSiteObj = this.get('configs').filterProperty('filename', 'hdfs-site.xml');
  1178. var hdfsProperties = {};
  1179. hdfsSiteObj.forEach(function (_configProperty) {
  1180. hdfsProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1181. this._recordHostOverrideFromObj(_configProperty, 'hdfs-site', 'version1', this);
  1182. console.log("STEP*: name of the property is: " + _configProperty.name);
  1183. console.log("STEP8: value of the property is: " + _configProperty.value);
  1184. }, this);
  1185. return {"type": "hdfs-site", "tag": "version1", "properties": hdfsProperties };
  1186. },
  1187. createLog4jObj: function (fileName) {
  1188. fileName = fileName.toLowerCase();
  1189. var Log4jObj = this.get('configs').filterProperty('filename', fileName + '-log4j.xml');
  1190. var Log4jProperties = {};
  1191. Log4jObj.forEach(function (_configProperty) {
  1192. Log4jProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1193. this._recordHostOverrideFromObj(_configProperty, fileName + '-log4j', 'version1', this);
  1194. console.log("STEP*: name of the property is: " + _configProperty.name);
  1195. console.log("STEP8: value of the property is: " + _configProperty.value);
  1196. }, this);
  1197. return {"type": fileName + "-log4j", "tag": "version1", "properties": Log4jProperties };
  1198. },
  1199. createHueSiteObj: function () {
  1200. var hueSiteObj = this.get('configs').filterProperty('filename', 'hue-site.xml');
  1201. var hueProperties = {};
  1202. hueSiteObj.forEach(function (_configProperty) {
  1203. hueProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1204. this._recordHostOverrideFromObj(_configProperty, 'hue-site', 'version1', this);
  1205. console.log("STEP*: name of the property is: " + _configProperty.name);
  1206. console.log("STEP8: value of the property is: " + _configProperty.value);
  1207. }, this);
  1208. return {"type": "hue-site", "tag": "version1", "properties": hueProperties };
  1209. },
  1210. createMrSiteObj: function () {
  1211. var configs = this.get('configs').filterProperty('filename', 'mapred-site.xml');
  1212. var mrProperties = {};
  1213. configs.forEach(function (_configProperty) {
  1214. mrProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1215. this._recordHostOverrideFromObj(_configProperty, 'mapred-site', 'version1', this);
  1216. console.log("STEP*: name of the property is: " + _configProperty.name);
  1217. console.log("STEP8: value of the property is: " + _configProperty.value);
  1218. }, this);
  1219. return {type: 'mapred-site', tag: 'version1', properties: mrProperties};
  1220. },
  1221. createYarnSiteObj: function () {
  1222. var configs = this.get('configs').filterProperty('filename', 'yarn-site.xml');
  1223. var mrProperties = {};
  1224. configs.forEach(function (_configProperty) {
  1225. mrProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1226. this._recordHostOverrideFromObj(_configProperty, 'yarn-site', 'version1', this);
  1227. console.log("STEP*: name of the property is: " + _configProperty.name);
  1228. console.log("STEP8: value of the property is: " + _configProperty.value);
  1229. }, this);
  1230. return {type: 'yarn-site', tag: 'version1', properties: mrProperties};
  1231. },
  1232. createCapacityScheduler: function () {
  1233. var configs = this.get('configs').filterProperty('filename', 'capacity-scheduler.xml');
  1234. var csProperties = {};
  1235. configs.forEach(function (_configProperty) {
  1236. csProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1237. this._recordHostOverrideFromObj(_configProperty, 'capacity-scheduler', 'version1', this);
  1238. console.log("STEP*: name of the property is: " + _configProperty.name);
  1239. console.log("STEP8: value of the property is: " + _configProperty.value);
  1240. }, this);
  1241. return {type: 'capacity-scheduler', tag: 'version1', properties: csProperties};
  1242. },
  1243. createMapredQueueAcls: function () {
  1244. var configs = this.get('configs').filterProperty('filename', 'mapred-queue-acls.xml');
  1245. var mqProperties = {};
  1246. configs.forEach(function (_configProperty) {
  1247. mqProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1248. this._recordHostOverrideFromObj(_configProperty, 'mapred-queue-acls', 'version1', this);
  1249. console.log("STEP*: name of the property is: " + _configProperty.name);
  1250. console.log("STEP8: value of the property is: " + _configProperty.value);
  1251. }, this);
  1252. return {type: 'mapred-queue-acls', tag: 'version1', properties: mqProperties};
  1253. },
  1254. createHbaseSiteObj: function () {
  1255. var configs = this.get('configs').filterProperty('filename', 'hbase-site.xml');
  1256. var hbaseProperties = {};
  1257. configs.forEach(function (_configProperty) {
  1258. hbaseProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1259. this._recordHostOverrideFromObj(_configProperty, 'hbase-site', 'version1', this);
  1260. }, this);
  1261. return {type: 'hbase-site', tag: 'version1', properties: hbaseProperties};
  1262. },
  1263. createOozieSiteObj: function (serviceName) {
  1264. var configs = this.get('configs').filterProperty('filename', 'oozie-site.xml');
  1265. var oozieProperties = {};
  1266. configs.forEach(function (_configProperty) {
  1267. oozieProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1268. this._recordHostOverrideFromObj(_configProperty, 'oozie-site', 'version1', this);
  1269. }, this);
  1270. return {type: 'oozie-site', tag: 'version1', properties: oozieProperties};
  1271. },
  1272. createHiveSiteObj: function (serviceName) {
  1273. var configs = this.get('configs').filterProperty('filename', 'hive-site.xml');
  1274. var hiveProperties = {};
  1275. configs.forEach(function (_configProperty) {
  1276. hiveProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1277. this._recordHostOverrideFromObj(_configProperty, 'hive-site', 'version1', this);
  1278. }, this);
  1279. return {type: 'hive-site', tag: 'version1', properties: hiveProperties};
  1280. },
  1281. createWebHCatSiteObj: function (serviceName) {
  1282. var configs = this.get('configs').filterProperty('filename', 'webhcat-site.xml');
  1283. var webHCatProperties = {};
  1284. configs.forEach(function (_configProperty) {
  1285. webHCatProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1286. this._recordHostOverrideFromObj(_configProperty, 'webhcat-site', 'version1', this);
  1287. }, this);
  1288. return {type: 'webhcat-site', tag: 'version1', properties: webHCatProperties};
  1289. },
  1290. createZooCfgObj: function () {
  1291. var configs = this.get('configs').filterProperty('filename', 'zoo.cfg');
  1292. var csProperties = {};
  1293. configs.forEach(function (_configProperty) {
  1294. csProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1295. this._recordHostOverrideFromObj(_configProperty, 'zoo.cfg', 'version1', this);
  1296. }, this);
  1297. return {type: 'zoo.cfg', tag: 'version1', properties: csProperties};
  1298. },
  1299. createStormSiteObj: function () {
  1300. var configs = this.get('configs').filterProperty('filename', 'storm-site.xml');
  1301. var stormProperties = {};
  1302. var specialProperties = ["storm.zookeeper.servers", "nimbus.childopts", "supervisor.childopts", "worker.childopts"];
  1303. configs.forEach(function (_configProperty) {
  1304. if (specialProperties.contains(_configProperty.name)) {
  1305. if (_configProperty.name == "storm.zookeeper.servers") {
  1306. stormProperties[_configProperty.name] = JSON.stringify(_configProperty.value).replace(/"/g, "'");
  1307. } else {
  1308. stormProperties[_configProperty.name] = JSON.stringify(_configProperty.value).replace(/"/g,"");
  1309. }
  1310. } else {
  1311. stormProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1312. }
  1313. this._recordHostOverrideFromObj(_configProperty, 'storm-site', 'version1', this);
  1314. }, this);
  1315. return {type: 'storm-site', tag: 'version1', properties: stormProperties};
  1316. },
  1317. createTezSiteObj: function () {
  1318. var configs = this.get('configs').filterProperty('filename', 'tez-site.xml');
  1319. var tezProperty = {};
  1320. configs.forEach(function (_configProperty) {
  1321. tezProperty[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1322. this._recordHostOverrideFromObj(_configProperty, 'tez-site', 'version1', this);
  1323. }, this);
  1324. return {type: 'tez-site', tag: 'version1', properties: tezProperty};
  1325. },
  1326. createFalconSiteObj: function (s) {
  1327. var configs = this.get('configs').filterProperty('filename', 'oozie-site.xml');
  1328. var falconProperties = {};
  1329. configs.forEach(function (_configProperty) {
  1330. falconProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1331. this._recordHostOverrideFromObj(_configProperty, 'oozie-site', 'version1', this);
  1332. }, this);
  1333. return {type: 'oozie-site', tag: 'version1', properties: falconProperties};
  1334. },
  1335. ajaxQueueFinished: function () {
  1336. //do something
  1337. },
  1338. doNextAjaxCall: function () {
  1339. if (this.get('ajaxBusy')) {
  1340. return;
  1341. }
  1342. var queue = this.get('ajaxQueue');
  1343. if (!queue.length) {
  1344. this.ajaxQueueFinished();
  1345. return;
  1346. }
  1347. var first = queue[0];
  1348. this.set('ajaxQueue', queue.slice(1));
  1349. this.set('ajaxQueueLeft', this.get('ajaxQueue').length);
  1350. this.set('ajaxBusy', true);
  1351. $.ajax(first);
  1352. },
  1353. /**
  1354. * Records all the host overrides per site/tag
  1355. */
  1356. _recordHostOverrideFromObj: function(serviceConfigObj, siteName, tagName, self){
  1357. var overrides = serviceConfigObj.overrides;
  1358. if(overrides && overrides.length>0){
  1359. overrides.forEach(function(override){
  1360. override.hosts.forEach(function(host){
  1361. if(!(host in self.savedHostToOverrideSiteToTagMap)){
  1362. self.savedHostToOverrideSiteToTagMap[host] = {};
  1363. }
  1364. if(!(siteName in self.savedHostToOverrideSiteToTagMap[host])){
  1365. self.savedHostToOverrideSiteToTagMap[host][siteName] = {};
  1366. self.savedHostToOverrideSiteToTagMap[host][siteName].map = {};
  1367. }
  1368. var finalTag = tagName + '_' + host;
  1369. console.log("recordHostOverride(): Saving host override for host="+host+", site="+siteName+", tag="+finalTag+", (key,value)=("+serviceConfigObj.name+","+override.value+")");
  1370. self.savedHostToOverrideSiteToTagMap[host][siteName].tagName = finalTag;
  1371. self.savedHostToOverrideSiteToTagMap[host][siteName].map[serviceConfigObj.name] = override.value;
  1372. });
  1373. });
  1374. }
  1375. },
  1376. /**
  1377. * Creates host level overrides for service configuration.
  1378. *
  1379. */
  1380. createHostOverrideConfigurations: function () {
  1381. var singlePUTHostData = [];
  1382. var savedHostSiteArray = [];
  1383. for ( var host in this.savedHostToOverrideSiteToTagMap) {
  1384. for ( var siteName in this.savedHostToOverrideSiteToTagMap[host]) {
  1385. var tagName = this.savedHostToOverrideSiteToTagMap[host][siteName].tagName;
  1386. var map = this.savedHostToOverrideSiteToTagMap[host][siteName].map;
  1387. savedHostSiteArray.push(host + "///" + siteName);
  1388. singlePUTHostData.push({
  1389. RequestInfo: {
  1390. query: 'Hosts/host_name='+host
  1391. },
  1392. Body: {
  1393. Hosts: {
  1394. desired_config: {
  1395. type: siteName,
  1396. tag: tagName,
  1397. properties: map
  1398. }
  1399. }
  1400. }
  1401. });
  1402. }
  1403. }
  1404. console.log("createHostOverrideConfigSites(): PUTting host-overrides. Data=", singlePUTHostData);
  1405. if(singlePUTHostData.length>0){
  1406. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts';
  1407. this.ajax({
  1408. type: 'PUT',
  1409. url: url,
  1410. data: JSON.stringify(singlePUTHostData),
  1411. dataType: 'text',
  1412. beforeSend: function () {
  1413. console.log("createHostOverrideConfigSites() PUT override=", singlePUTHostData);
  1414. }
  1415. });
  1416. }
  1417. },
  1418. /**
  1419. * We need to do a lot of ajax calls async in special order. To do this,
  1420. * generate array of ajax objects and then send requests step by step. All
  1421. * ajax objects are stored in <code>ajaxQueue</code>
  1422. *
  1423. * @param params
  1424. */
  1425. ajax: function (params) {
  1426. if (App.testMode) return;
  1427. var self = this;
  1428. params = jQuery.extend({
  1429. async: true,
  1430. dataType: 'text',
  1431. statusCode: require('data/statusCodes'),
  1432. timeout: App.timeout,
  1433. error: function (request, ajaxOptions, error) {
  1434. console.log('Step8: In Error ');
  1435. // console.log('Step8: Error message is: ' + request.responseText);
  1436. },
  1437. success: function (data) {
  1438. console.log("TRACE: STep8 -> In success function");
  1439. }
  1440. }, params);
  1441. var success = params.success;
  1442. var error = params.error;
  1443. params.success = function () {
  1444. if (success) {
  1445. success();
  1446. }
  1447. self.set('ajaxBusy', false);
  1448. self.doNextAjaxCall();
  1449. };
  1450. params.error = function (xhr, status, error) {
  1451. var responseText = JSON.parse(xhr.responseText);
  1452. var controller = App.router.get(App.clusterStatus.wizardControllerName);
  1453. controller.registerErrPopup(Em.I18n.t('common.error'), responseText.message);
  1454. self.set('hasErrorOccurred', true);
  1455. // an error will break the ajax call chain and allow submission again
  1456. self.set('isSubmitDisabled', false);
  1457. self.set('isBackBtnDisabled', false);
  1458. App.router.get(self.get('content.controllerName')).setStepsEnable();
  1459. self.get('ajaxQueue').clear();
  1460. self.set('ajaxBusy', false);
  1461. };
  1462. this.get('ajaxQueue').pushObject(params);
  1463. }
  1464. });