step8_controller.js 78 KB

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