step8_controller.js 65 KB

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