step8_controller.js 67 KB

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