step8_controller.js 66 KB

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