step8_controller.js 66 KB

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