step8_controller.js 79 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993
  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. case 'Logviewer Server':
  850. case 'Storm UI Server':
  851. case 'DRPC Server':
  852. this.loadMasterComponentHostValue(component);
  853. break;
  854. case 'SuperVisor':
  855. this.loadSuperVisorValue(component);
  856. break;
  857. default:
  858. }
  859. }, this);
  860. this.get('services').pushObject(stormObj);
  861. },
  862. /**
  863. * Load master component host value
  864. * @method loadMasterComponentHostValue
  865. * @param {Object} component - component object which value should be set
  866. * @param {String} componentName - (optional) display_name of component
  867. */
  868. loadMasterComponentHostValue: function(component, componentName) {
  869. var component_name = componentName || component.get('display_name');
  870. var masterHost = this.get('content.masterComponentHosts').findProperty('display_name', component_name);
  871. component.set('component_value', masterHost.hostName);
  872. },
  873. loadSuperVisorValue: function(component) {
  874. var hostsCount = this.get('content.slaveComponentHosts').findProperty('componentName', 'CLIENT').hosts.length;
  875. var hostsText = hostsCount > 1 ? hostsCount + ' hosts' : hostsCount + ' host'
  876. component.set('component_value', hostsText);
  877. },
  878. /**
  879. * Onclick handler for <code>next</code> button
  880. */
  881. submit: function () {
  882. if (this.get('isSubmitDisabled')) {
  883. return;
  884. }
  885. if ((this.get('content.controllerName') == 'addHostController') && this.get('securityEnabled')) {
  886. var self = this;
  887. App.showConfirmationPopup(function() {
  888. self.submitProceed();
  889. }, Em.I18n.t('installer.step8.securityConfirmationPopupBody'));
  890. }
  891. else {
  892. this.submitProceed();
  893. }
  894. },
  895. submitProceed: function() {
  896. this.set('isSubmitDisabled', true);
  897. this.set('isBackBtnDisabled', true);
  898. if (this.get('content.controllerName') == 'addHostController') {
  899. App.router.get('addHostController').setLowerStepsDisable(4);
  900. }
  901. // checkpoint the cluster status on the server so that the user can resume from where they left off
  902. switch (this.get('content.controllerName')) {
  903. case 'installerController':
  904. App.clusterStatus.setClusterStatus({
  905. clusterName: this.get('clusterName'),
  906. clusterState: 'CLUSTER_DEPLOY_PREP_2',
  907. wizardControllerName: this.get('content.controllerName'),
  908. localdb: App.db.data
  909. });
  910. break;
  911. case 'addHostController':
  912. App.clusterStatus.setClusterStatus({
  913. clusterName: this.get('clusterName'),
  914. clusterState: 'ADD_HOSTS_DEPLOY_PREP_2',
  915. wizardControllerName: this.get('content.controllerName'),
  916. localdb: App.db.data
  917. });
  918. break;
  919. case 'addServiceController':
  920. App.clusterStatus.setClusterStatus({
  921. clusterName: this.get('clusterName'),
  922. clusterState: 'ADD_SERVICES_DEPLOY_PREP_2',
  923. wizardControllerName: this.get('content.controllerName'),
  924. localdb: App.db.data
  925. });
  926. break;
  927. default:
  928. break;
  929. }
  930. // delete any existing clusters to start from a clean slate
  931. // before creating a new cluster in install wizard
  932. // TODO: modify for multi-cluster support
  933. if (this.get('content.controllerName') == 'installerController' && (!App.testMode)) {
  934. var clusterNames = this.getExistingClusterNames();
  935. this.deleteClusters(clusterNames);
  936. }
  937. this.setLocalRepositories();
  938. this.createCluster();
  939. this.createSelectedServices();
  940. this.createConfigurations();
  941. this.createComponents();
  942. this.registerHostsToCluster();
  943. if (App.supports.hostOverridesInstaller) {
  944. this.createConfigurationGroups();
  945. }
  946. this.createAllHostComponents();
  947. this.createHostOverrideConfigurations();
  948. this.ajaxQueueFinished = function () {
  949. console.log('everything is loaded');
  950. App.router.send('next');
  951. };
  952. this.doNextAjaxCall();
  953. },
  954. /**
  955. * Used in progress bar
  956. */
  957. ajaxQueueLength: function () {
  958. return this.get('ajaxQueue').length;
  959. }.property('ajaxQueue.length'),
  960. /**
  961. * Used in progress bar
  962. */
  963. ajaxQueueLeft: 0,
  964. setAmbariUIDb: function () {
  965. var dbContent = this.get('content.slaveGroupProperties');
  966. var slaveComponentConfig = this.get("slaveComponentConfig");
  967. this.persistKeyValues(slaveComponentConfig.version, dbContent);
  968. this.persistKeyValues('current_version', slaveComponentConfig.version);
  969. },
  970. persistKeyValues: function (key, value) {
  971. var str = "{ '" + key + "' : '" + JSON.stringify(value) + "'}";
  972. var obj = eval("(" + str + ")");
  973. this.ajax({
  974. type: "POST",
  975. url: App.apiPrefix + '/persist',
  976. data: JSON.stringify(obj),
  977. beforeSend: function () {
  978. console.log('BeforeSend: persistKeyValues', obj);
  979. }
  980. });
  981. },
  982. clusterName: function () {
  983. return this.get('content.cluster.name');
  984. }.property('content.cluster.name'),
  985. clusterNames: [],
  986. // returns an array of existing cluster names.
  987. // returns an empty array if there are no existing clusters.
  988. getExistingClusterNames: function () {
  989. var url = App.apiPrefix + '/clusters';
  990. App.ajax.send({
  991. name: 'wizard.step8.existing_cluster_names',
  992. sender: this,
  993. success: 'getExistingClusterNamesSuccessCallBack',
  994. error: 'getExistingClusterNamesErrorCallback'
  995. });
  996. return this.get('clusterNames');
  997. },
  998. getExistingClusterNamesSuccessCallBack: function (data) {
  999. var clusterNames = data.items.mapProperty('Clusters.cluster_name');
  1000. console.log("Got existing cluster names: " + clusterNames);
  1001. this.set('clusterNames', clusterNames);
  1002. },
  1003. getExistingClusterNamesErrorCallback: function () {
  1004. console.log("Failed to get existing cluster names");
  1005. this.set('clusterNames', []);
  1006. },
  1007. deleteClusters: function (clusterNames) {
  1008. clusterNames.forEach(function (clusterName) {
  1009. App.ajax.send({
  1010. name: 'wizard.step8.delete_cluster',
  1011. sender: this,
  1012. data: {
  1013. name: clusterName
  1014. },
  1015. success: 'deleteClustersSuccessCallback',
  1016. error: 'deleteClustersErrorCallback'
  1017. });
  1018. }, this);
  1019. },
  1020. deleteClustersSuccessCallback: function(data, opt, params) {
  1021. console.log('DELETE cluster ' + params.name + ' succeeded');
  1022. },
  1023. deleteClustersErrorCallback: function(request, ajaxOptions, error, opt) {
  1024. console.log('DELETE cluster failed');
  1025. },
  1026. /**
  1027. * Updates local repositories for the Ambari server.
  1028. */
  1029. setLocalRepositories: function () {
  1030. if (this.get('content.controllerName') !== 'installerController' || !App.supports.localRepositories) {
  1031. return false;
  1032. }
  1033. var self = this;
  1034. var apiUrl = App.get('stack2VersionURL');
  1035. var stacks = this.get('content.stacks');
  1036. stacks.forEach(function (stack) {
  1037. stack.operatingSystems.forEach(function (os) {
  1038. if (os.baseUrl !== os.originalBaseUrl) {
  1039. console.log("Updating local repository URL from " + os.originalBaseUrl + " -> " + os.baseUrl + ". ", os);
  1040. var url = App.apiPrefix + apiUrl + "/operatingSystems/" + os.osType + "/repositories/" + stack.name;
  1041. self.ajax({
  1042. type: 'PUT',
  1043. url: url,
  1044. data: JSON.stringify({
  1045. "Repositories": {
  1046. "base_url": os.baseUrl
  1047. }
  1048. }),
  1049. beforeSend: function () {
  1050. console.log("BeforeSend: setLocalRepositories PUT to ", url);
  1051. }
  1052. });
  1053. }
  1054. });
  1055. });
  1056. },
  1057. /**
  1058. * The following create* functions are called upon submitting Step 8.
  1059. */
  1060. createCluster: function () {
  1061. if (this.get('content.controllerName') !== 'installerController') {
  1062. return false;
  1063. }
  1064. var clusterName = this.get('clusterName');
  1065. var url = App.apiPrefix + '/clusters/' + clusterName;
  1066. var stackVersion = (this.get('content.installOptions.localRepo')) ? App.currentStackVersion.replace(/(-\d+(\.\d)*)/ig, "Local$&") : App.currentStackVersion;
  1067. this.ajax({
  1068. type: 'POST',
  1069. url: url,
  1070. data: JSON.stringify({ "Clusters": {"version": stackVersion }}),
  1071. beforeSend: function () {
  1072. console.log("BeforeSend: createCluster for " + clusterName);
  1073. }
  1074. });
  1075. },
  1076. createSelectedServices: function () {
  1077. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/services';
  1078. var data = this.createServiceData();
  1079. var httpMethod = 'POST';
  1080. if (!data.length) {
  1081. return;
  1082. }
  1083. this.ajax({
  1084. type: httpMethod,
  1085. url: url,
  1086. data: JSON.stringify(data),
  1087. beforeSend: function () {
  1088. console.log('BeforeSend: createSelectedServices ', data);
  1089. }
  1090. });
  1091. },
  1092. createServiceData: function () {
  1093. var services = this.get('selectedServices').mapProperty('serviceName');
  1094. var data = [];
  1095. services.forEach(function (_service) {
  1096. data.pushObject({"ServiceInfo": { "service_name": _service }});
  1097. }, this);
  1098. return data;
  1099. },
  1100. createComponents: function () {
  1101. var serviceComponents = require('data/service_components');
  1102. var services = this.get('selectedServices').mapProperty('serviceName');
  1103. services.forEach(function (_service) {
  1104. var components = serviceComponents.filterProperty('service_name', _service);
  1105. var componentsData = components.map(function (_component) {
  1106. return { "ServiceComponentInfo": { "component_name": _component.component_name } };
  1107. });
  1108. // Service must be specified in terms of a query for creating multiple components at the same time.
  1109. // See AMBARI-1018.
  1110. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/services?ServiceInfo/service_name=' + _service;
  1111. var data = {
  1112. "components": componentsData
  1113. }
  1114. this.ajax({
  1115. type: 'POST',
  1116. url: url,
  1117. data: JSON.stringify(data),
  1118. beforeSend: function () {
  1119. console.log('BeforeSend: createComponents for ' + _service, componentsData);
  1120. }
  1121. });
  1122. }, this);
  1123. },
  1124. registerHostsToCluster: function () {
  1125. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts';
  1126. var data = this.createRegisterHostData();
  1127. if (data.length == 0) {
  1128. return;
  1129. }
  1130. this.ajax({
  1131. type: 'POST',
  1132. url: url,
  1133. data: JSON.stringify(data),
  1134. beforeSend: function () {
  1135. console.log('BeforeSend: registerHostsToCluster', data);
  1136. }
  1137. });
  1138. },
  1139. createRegisterHostData: function () {
  1140. var hosts = this.getRegisteredHosts().filterProperty('isInstalled', false);
  1141. if (!hosts.length) {
  1142. return [];
  1143. }
  1144. return hosts.map(function (host) {
  1145. return {"Hosts": { "host_name": host.hostName}};
  1146. });
  1147. },
  1148. // TODO: review the code for add hosts / add services scenarios...
  1149. createAllHostComponents: function () {
  1150. var masterHosts = this.get('content.masterComponentHosts');
  1151. var slaveHosts = this.get('content.slaveComponentHosts');
  1152. var clients = this.get('content.clients');
  1153. // note: masterHosts has 'component' vs slaveHosts has 'componentName'
  1154. var masterComponents = masterHosts.mapProperty('component').uniq();
  1155. masterComponents.forEach(function (component) {
  1156. var hostNames = masterHosts.filterProperty('component', component).filterProperty('isInstalled', false).mapProperty('hostName');
  1157. this.registerHostsToComponent(hostNames, component);
  1158. }, this);
  1159. slaveHosts.forEach(function (_slave) {
  1160. if (_slave.componentName !== 'CLIENT') {
  1161. var hostNames = _slave.hosts.filterProperty('isInstalled', false).mapProperty('hostName');
  1162. this.registerHostsToComponent(hostNames, _slave.componentName);
  1163. } else {
  1164. clients.forEach(function (_client) {
  1165. var hostNames = _slave.hosts.mapProperty('hostName');
  1166. switch (_client.component_name) {
  1167. case 'HDFS_CLIENT':
  1168. // install HDFS_CLIENT on HBASE_MASTER, HBASE_REGIONSERVER, WEBHCAT_SERVER, HISTORYSERVER and OOZIE_SERVER hosts
  1169. masterHosts.filterProperty('component', 'HBASE_MASTER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1170. hostNames.pushObject(_masterHost.hostName);
  1171. }, this);
  1172. masterHosts.filterProperty('component', 'HBASE_REGIONSERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1173. hostNames.pushObject(_masterHost.hostName);
  1174. }, this);
  1175. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1176. hostNames.pushObject(_masterHost.hostName);
  1177. }, this);
  1178. masterHosts.filterProperty('component', 'HISTORYSERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1179. hostNames.pushObject(_masterHost.hostName);
  1180. }, this);
  1181. masterHosts.filterProperty('component', 'OOZIE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1182. hostNames.pushObject(_masterHost.hostName);
  1183. }, this);
  1184. break;
  1185. case 'MAPREDUCE_CLIENT':
  1186. // install MAPREDUCE_CLIENT on HIVE_SERVER, OOZIE_SERVER, NAGIOS_SERVER, and WEBHCAT_SERVER hosts
  1187. masterHosts.filterProperty('component', 'HIVE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1188. hostNames.pushObject(_masterHost.hostName);
  1189. }, this);
  1190. masterHosts.filterProperty('component', 'OOZIE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1191. hostNames.pushObject(_masterHost.hostName);
  1192. }, this);
  1193. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1194. hostNames.pushObject(_masterHost.hostName);
  1195. }, this);
  1196. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1197. hostNames.pushObject(_masterHost.hostName);
  1198. }, this);
  1199. break;
  1200. case 'OOZIE_CLIENT':
  1201. // install OOZIE_CLIENT on NAGIOS_SERVER host
  1202. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1203. hostNames.pushObject(_masterHost.hostName);
  1204. }, this);
  1205. break;
  1206. case 'ZOOKEEPER_CLIENT':
  1207. // install ZOOKEEPER_CLIENT on WEBHCAT_SERVER host
  1208. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1209. hostNames.pushObject(_masterHost.hostName);
  1210. }, this);
  1211. break;
  1212. case 'HIVE_CLIENT':
  1213. //install HIVE client on NAGIOS_SERVER host
  1214. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1215. hostNames.pushObject(_masterHost.hostName);
  1216. }, this);
  1217. masterHosts.filterProperty('component', 'HIVE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1218. hostNames.pushObject(_masterHost.hostName);
  1219. }, this);
  1220. break;
  1221. case 'HCAT':
  1222. // install HCAT (client) on NAGIOS_SERVER host
  1223. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1224. hostNames.pushObject(_masterHost.hostName);
  1225. }, this);
  1226. break;
  1227. case 'YARN_CLIENT':
  1228. // install YARN_CLIENT on NAGIOS_SERVER,HIVE_SERVER,OOZIE_SERVER,WEBHCAT_SERVER host
  1229. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1230. hostNames.pushObject(_masterHost.hostName);
  1231. }, this);
  1232. masterHosts.filterProperty('component', 'HIVE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1233. hostNames.pushObject(_masterHost.hostName);
  1234. }, this);
  1235. masterHosts.filterProperty('component', 'OOZIE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1236. hostNames.pushObject(_masterHost.hostName);
  1237. }, this);
  1238. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1239. hostNames.pushObject(_masterHost.hostName);
  1240. }, this);
  1241. break;
  1242. }
  1243. hostNames = hostNames.uniq();
  1244. if (_client.isInstalled) {
  1245. //check whether clients are already installed on selected master hosts!!!
  1246. var installedHosts = _slave.hosts.filterProperty('isInstalled', true).mapProperty('hostName');
  1247. installedHosts.forEach(function (host) {
  1248. if (hostNames.contains(host)) {
  1249. hostNames.splice(hostNames.indexOf(host), 1);
  1250. }
  1251. }, this);
  1252. }
  1253. this.registerHostsToComponent(hostNames, _client.component_name);
  1254. }, this);
  1255. }
  1256. }, this);
  1257. // add Ganglia Monitor (Slave) to all hosts if Ganglia service is selected
  1258. var gangliaService = this.get('content.services').filterProperty('isSelected', true).findProperty('serviceName', 'GANGLIA');
  1259. if (gangliaService) {
  1260. var hosts = this.getRegisteredHosts();
  1261. if (gangliaService.get('isInstalled')) {
  1262. hosts = hosts.filterProperty('isInstalled', false);
  1263. }
  1264. if (hosts.length) {
  1265. this.registerHostsToComponent(hosts.mapProperty('hostName'), 'GANGLIA_MONITOR');
  1266. }
  1267. }
  1268. // add MySQL Server if Hive is selected
  1269. var hiveService = this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).findProperty('serviceName', 'HIVE');
  1270. if (hiveService) {
  1271. var hiveDb = this.get('content.serviceConfigProperties').findProperty('name', 'hive_database');
  1272. if(hiveDb.value == "New MySQL Database") {
  1273. this.registerHostsToComponent(masterHosts.filterProperty('component', 'HIVE_SERVER').mapProperty('hostName'), 'MYSQL_SERVER');
  1274. }
  1275. }
  1276. },
  1277. registerHostsToComponent: function (hostNames, componentName) {
  1278. if (hostNames.length == 0) {
  1279. return;
  1280. }
  1281. // currently we are specifying the predicate as a query string.
  1282. // this can hit a ~4000-character limit in Jetty server.
  1283. // chunk to multiple calls if needed
  1284. // var hostsPredicate = hostNames.map(function (hostName) {
  1285. // return 'Hosts/host_name=' + hostName;
  1286. // }).join('|');
  1287. var queryStrArr = [];
  1288. var queryStr = '';
  1289. hostNames.forEach(function (hostName) {
  1290. queryStr += 'Hosts/host_name=' + hostName + '|';
  1291. if (queryStr.length > 3500) {
  1292. queryStrArr.push(queryStr.slice(0, -1));
  1293. queryStr = '';
  1294. }
  1295. });
  1296. if (queryStr.length > 0) {
  1297. queryStrArr.push(queryStr.slice(0, -1));
  1298. }
  1299. queryStrArr.forEach(function (queryStr) {
  1300. // console.log('creating host components for ' + queryStr);
  1301. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts?' + queryStr;
  1302. var data = {
  1303. "host_components": [
  1304. {
  1305. "HostRoles": {
  1306. "component_name": componentName
  1307. }
  1308. }
  1309. ]
  1310. };
  1311. this.ajax({
  1312. type: 'POST',
  1313. url: url,
  1314. data: JSON.stringify(data)
  1315. });
  1316. }, this);
  1317. },
  1318. createConfigurations: function () {
  1319. var selectedServices = this.get('selectedServices');
  1320. if (this.get('content.controllerName') == 'installerController') {
  1321. this.get('serviceConfigTags').pushObject(this.createCoreSiteObj());
  1322. this.get('serviceConfigTags').pushObject(this.createHdfsSiteObj());
  1323. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HDFS'));
  1324. }
  1325. var globalSiteObj = this.createGlobalSiteObj();
  1326. if (this.get('content.controllerName') == 'addServiceController') {
  1327. globalSiteObj.tag = 'version' + (new Date).getTime();
  1328. }
  1329. this.get('serviceConfigTags').pushObject(globalSiteObj);
  1330. if (selectedServices.someProperty('serviceName', 'MAPREDUCE')) {
  1331. this.get('serviceConfigTags').pushObject(this.createMrSiteObj());
  1332. if (App.supports.capacitySchedulerUi) {
  1333. this.get('serviceConfigTags').pushObject(this.createCapacityScheduler());
  1334. this.get('serviceConfigTags').pushObject(this.createMapredQueueAcls());
  1335. }
  1336. this.get('serviceConfigTags').pushObject(this.createLog4jObj('MAPREDUCE'));
  1337. }
  1338. if (selectedServices.someProperty('serviceName', 'MAPREDUCE2')) {
  1339. this.get('serviceConfigTags').pushObject(this.createMrSiteObj());
  1340. this.get('serviceConfigTags').pushObject(this.createLog4jObj('MAPREDUCE2'));
  1341. }
  1342. if (selectedServices.someProperty('serviceName', 'YARN')) {
  1343. this.get('serviceConfigTags').pushObject(this.createYarnSiteObj());
  1344. this.get('serviceConfigTags').pushObject(this.createCapacityScheduler());
  1345. this.get('serviceConfigTags').pushObject(this.createLog4jObj('YARN'));
  1346. }
  1347. if (selectedServices.someProperty('serviceName', 'HBASE')) {
  1348. this.get('serviceConfigTags').pushObject(this.createHbaseSiteObj());
  1349. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HBASE'));
  1350. }
  1351. if (selectedServices.someProperty('serviceName', 'OOZIE')) {
  1352. this.get('serviceConfigTags').pushObject(this.createOozieSiteObj('OOZIE'));
  1353. this.get('serviceConfigTags').pushObject(this.createLog4jObj('OOZIE'));
  1354. }
  1355. if (selectedServices.someProperty('serviceName', 'HIVE')) {
  1356. this.get('serviceConfigTags').pushObject(this.createHiveSiteObj('HIVE'));
  1357. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HIVE'));
  1358. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HIVE-EXEC'));
  1359. }
  1360. if (selectedServices.someProperty('serviceName', 'WEBHCAT')) {
  1361. this.get('serviceConfigTags').pushObject(this.createWebHCatSiteObj('WEBHCAT'));
  1362. }
  1363. if (selectedServices.someProperty('serviceName', 'HUE')) {
  1364. this.get('serviceConfigTags').pushObject(this.createHueSiteObj('HUE'));
  1365. }
  1366. if (selectedServices.someProperty('serviceName', 'PIG')) {
  1367. this.get('serviceConfigTags').pushObject(this.createLog4jObj('PIG'));
  1368. }
  1369. if (selectedServices.someProperty('serviceName', 'STORM')) {
  1370. this.get('serviceConfigTags').pushObject(this.createStormSiteObj('STORM'));
  1371. }
  1372. if (selectedServices.someProperty('serviceName', 'ZOOKEEPER')) {
  1373. this.get('serviceConfigTags').pushObject(this.createLog4jObj('ZOOKEEPER'));
  1374. }
  1375. this.applyConfigurationsToCluster();
  1376. },
  1377. applyConfigurationsToCluster: function() {
  1378. var clusterUrl = App.apiPrefix + '/clusters/' + this.get('clusterName');
  1379. var configData = [];
  1380. this.get('serviceConfigTags').forEach(function (_serviceConfig) {
  1381. var Clusters = {
  1382. Clusters: {
  1383. desired_config: {
  1384. type: _serviceConfig.type,
  1385. tag: _serviceConfig.tag,
  1386. properties: _serviceConfig.properties
  1387. }
  1388. }
  1389. };
  1390. configData.pushObject(JSON.stringify(Clusters));
  1391. }, this);
  1392. var data = {
  1393. configData: '[' + configData.toString() + ']'
  1394. };
  1395. console.debug("applyConfigurationsToCluster(Step8): Applying to URL", clusterUrl, " Data:", data.configData);
  1396. this.ajax({
  1397. type: 'PUT',
  1398. url: clusterUrl,
  1399. data: data.configData,
  1400. beforeSend: function () {
  1401. console.log("BeforeSend: Updating cluster config");
  1402. }
  1403. });
  1404. },
  1405. createConfigurationGroups: function () {
  1406. var configGroups = this.get('content.configGroups').filterProperty('isDefault', false);
  1407. var clusterName = this.get('clusterName');
  1408. var sendData = [];
  1409. var updateData = [];
  1410. var serviceConfigController = App.router.get('mainServiceInfoConfigsController');
  1411. var timeTag = (new Date).getTime();
  1412. var groupsToDelete = App.router.get(this.get('content.controllerName')).getDBProperty('groupsToDelete');
  1413. if (groupsToDelete && groupsToDelete.length > 0) {
  1414. this.removeInstalledServicesConfigurationGroups(groupsToDelete);
  1415. }
  1416. configGroups.forEach(function (configGroup) {
  1417. var groupConfigs = [];
  1418. var groupData = {
  1419. "cluster_name": clusterName,
  1420. "group_name": configGroup.name,
  1421. "tag": configGroup.service.id,
  1422. "description": configGroup.description,
  1423. "hosts": [],
  1424. "desired_configs": []
  1425. };
  1426. configGroup.hosts.forEach(function (hostName) {
  1427. groupData.hosts.push({"host_name": hostName});
  1428. });
  1429. //wrap properties into Em.Object to make them compatible with buildGroupDesiredConfigs method
  1430. configGroup.properties.forEach(function (property) {
  1431. groupConfigs.push(Em.Object.create(property));
  1432. });
  1433. groupData.desired_configs = serviceConfigController.buildGroupDesiredConfigs.call(serviceConfigController, groupConfigs, timeTag);
  1434. // check for group from installed service
  1435. if (configGroup.isForUpdate === true) {
  1436. // if group is a new one, create it
  1437. if (!configGroup.id) {
  1438. sendData.push({"ConfigGroup": groupData});
  1439. } else {
  1440. // update an existing group
  1441. groupData.id = configGroup.id;
  1442. updateData.push({"ConfigGroup": groupData});
  1443. }
  1444. } else {
  1445. sendData.push({"ConfigGroup": groupData});
  1446. }
  1447. //each group should have unique tag to prevent overriding configs from common sites
  1448. timeTag++;
  1449. }, this);
  1450. if (sendData.length > 0) {
  1451. this.applyConfigurationGroups(sendData);
  1452. }
  1453. if (updateData.length > 0) {
  1454. this.applyInstalledServicesConfigurationGroup(updateData);
  1455. }
  1456. },
  1457. applyConfigurationGroups: function (sendData) {
  1458. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/config_groups';
  1459. this.ajax({
  1460. type: 'POST',
  1461. url: url,
  1462. data: JSON.stringify(sendData)
  1463. });
  1464. },
  1465. applyInstalledServicesConfigurationGroup: function (updateData) {
  1466. updateData.forEach(function(item) {
  1467. App.router.get('mainServiceInfoConfigsController').putConfigGroupChanges(item);
  1468. });
  1469. },
  1470. removeInstalledServicesConfigurationGroups: function(groupsToDelete) {
  1471. groupsToDelete.forEach(function(item) {
  1472. App.config.deleteConfigGroup(Em.Object.create(item));
  1473. });
  1474. },
  1475. createGlobalSiteObj: function () {
  1476. var globalSiteProperties = {};
  1477. var globalSiteObj = this.get('globals');
  1478. var isGLUSTERFSSelected = this.get('selectedServices').someProperty('serviceName', 'GLUSTERFS');
  1479. // screen out the GLUSTERFS-specific global config entries when they are not required
  1480. if (!isGLUSTERFSSelected) {
  1481. globalSiteObj = globalSiteObj.filter(function(_config) {
  1482. return _config.name.indexOf("fs_glusterfs") < 0;
  1483. });
  1484. }
  1485. globalSiteObj.forEach(function (_globalSiteObj) {
  1486. var heapsizeException = ['hadoop_heapsize','yarn_heapsize','nodemanager_heapsize','resourcemanager_heapsize'];
  1487. // do not pass any globals whose name ends with _host or _hosts
  1488. if (_globalSiteObj.isRequiredByAgent !== false) {
  1489. // append "m" to JVM memory options except for hadoop_heapsize
  1490. if (/_heapsize|_newsize|_maxnewsize$/.test(_globalSiteObj.name) && !heapsizeException.contains(_globalSiteObj.name)) {
  1491. globalSiteProperties[_globalSiteObj.name] = _globalSiteObj.value + "m";
  1492. } else {
  1493. globalSiteProperties[_globalSiteObj.name] = App.config.escapeXMLCharacters(_globalSiteObj.value);
  1494. }
  1495. }
  1496. this._recordHostOverrideFromObj(_globalSiteObj, 'global', 'version1', this);
  1497. }, this);
  1498. // we don't expose gmond_user to the user; it needs to be the same as gmetad_user
  1499. globalSiteProperties['gmond_user'] = globalSiteProperties['gmetad_user'];
  1500. return {"type": "global", "tag": "version1", "properties": globalSiteProperties};
  1501. },
  1502. createCoreSiteObj: function () {
  1503. var coreSiteObj = this.get('configs').filterProperty('filename', 'core-site.xml');
  1504. var coreSiteProperties = {};
  1505. // hadoop.proxyuser.oozie.hosts needs to be skipped if oozie is not selected
  1506. var isOozieSelected = this.get('selectedServices').someProperty('serviceName', 'OOZIE');
  1507. var oozieUser = this.get('globals').someProperty('name', 'oozie_user') ? this.get('globals').findProperty('name', 'oozie_user').value : null;
  1508. var isHiveSelected = this.get('selectedServices').someProperty('serviceName', 'HIVE');
  1509. var hiveUser = this.get('globals').someProperty('name', 'hive_user') ? this.get('globals').findProperty('name', 'hive_user').value : null;
  1510. var isHcatSelected = this.get('selectedServices').someProperty('serviceName', 'WEBHCAT');
  1511. var hcatUser = this.get('globals').someProperty('name', 'hcat_user') ? this.get('globals').findProperty('name', 'hcat_user').value : null;
  1512. var isGLUSTERFSSelected = this.get('selectedServices').someProperty('serviceName', 'GLUSTERFS');
  1513. // screen out the GLUSTERFS-specific core-site.xml entries when they are not needed
  1514. if (!isGLUSTERFSSelected) {
  1515. coreSiteObj = coreSiteObj.filter(function(_config) {
  1516. return _config.name.indexOf("fs.glusterfs") < 0;
  1517. });
  1518. }
  1519. coreSiteObj.forEach(function (_coreSiteObj) {
  1520. 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'))) {
  1521. coreSiteProperties[_coreSiteObj.name] = App.config.escapeXMLCharacters(_coreSiteObj.value);
  1522. this._recordHostOverrideFromObj(_coreSiteObj, 'core-site', 'version1', this);
  1523. }
  1524. if (isGLUSTERFSSelected && _coreSiteObj.name == "fs.default.name") {
  1525. 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;
  1526. }
  1527. if (isGLUSTERFSSelected && _coreSiteObj.name == "fs.defaultFS") {
  1528. coreSiteProperties[_coreSiteObj.name] = this.get('globals').someProperty('name', 'glusterfs_defaultFS_name') ? App.config.escapeXMLCharacters(this.get('globals').findProperty('name', 'glusterfs_defaultFS_name').value) : null;
  1529. }
  1530. console.log("STEP*: name of the property is: " + _coreSiteObj.name);
  1531. console.log("STEP8: value of the property is: " + _coreSiteObj.value);
  1532. }, this);
  1533. return {"type": "core-site", "tag": "version1", "properties": coreSiteProperties};
  1534. },
  1535. createHdfsSiteObj: function () {
  1536. var hdfsSiteObj = this.get('configs').filterProperty('filename', 'hdfs-site.xml');
  1537. var hdfsProperties = {};
  1538. hdfsSiteObj.forEach(function (_configProperty) {
  1539. hdfsProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1540. this._recordHostOverrideFromObj(_configProperty, 'hdfs-site', 'version1', this);
  1541. console.log("STEP*: name of the property is: " + _configProperty.name);
  1542. console.log("STEP8: value of the property is: " + _configProperty.value);
  1543. }, this);
  1544. return {"type": "hdfs-site", "tag": "version1", "properties": hdfsProperties };
  1545. },
  1546. createLog4jObj: function (fileName) {
  1547. fileName = fileName.toLowerCase();
  1548. var Log4jObj = this.get('configs').filterProperty('filename', fileName + '-log4j.xml');
  1549. var Log4jProperties = {};
  1550. Log4jObj.forEach(function (_configProperty) {
  1551. Log4jProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1552. this._recordHostOverrideFromObj(_configProperty, fileName + '-log4j', 'version1', this);
  1553. console.log("STEP*: name of the property is: " + _configProperty.name);
  1554. console.log("STEP8: value of the property is: " + _configProperty.value);
  1555. }, this);
  1556. return {"type": fileName + "-log4j", "tag": "version1", "properties": Log4jProperties };
  1557. },
  1558. createHueSiteObj: function () {
  1559. var hueSiteObj = this.get('configs').filterProperty('filename', 'hue-site.xml');
  1560. var hueProperties = {};
  1561. hueSiteObj.forEach(function (_configProperty) {
  1562. hueProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1563. this._recordHostOverrideFromObj(_configProperty, 'hue-site', 'version1', this);
  1564. console.log("STEP*: name of the property is: " + _configProperty.name);
  1565. console.log("STEP8: value of the property is: " + _configProperty.value);
  1566. }, this);
  1567. return {"type": "hue-site", "tag": "version1", "properties": hueProperties };
  1568. },
  1569. createMrSiteObj: function () {
  1570. var configs = this.get('configs').filterProperty('filename', 'mapred-site.xml');
  1571. var mrProperties = {};
  1572. configs.forEach(function (_configProperty) {
  1573. mrProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1574. this._recordHostOverrideFromObj(_configProperty, 'mapred-site', 'version1', this);
  1575. console.log("STEP*: name of the property is: " + _configProperty.name);
  1576. console.log("STEP8: value of the property is: " + _configProperty.value);
  1577. }, this);
  1578. return {type: 'mapred-site', tag: 'version1', properties: mrProperties};
  1579. },
  1580. createYarnSiteObj: function () {
  1581. var configs = this.get('configs').filterProperty('filename', 'yarn-site.xml');
  1582. var mrProperties = {};
  1583. configs.forEach(function (_configProperty) {
  1584. mrProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1585. this._recordHostOverrideFromObj(_configProperty, 'yarn-site', 'version1', this);
  1586. console.log("STEP*: name of the property is: " + _configProperty.name);
  1587. console.log("STEP8: value of the property is: " + _configProperty.value);
  1588. }, this);
  1589. return {type: 'yarn-site', tag: 'version1', properties: mrProperties};
  1590. },
  1591. createCapacityScheduler: function () {
  1592. var configs = this.get('configs').filterProperty('filename', 'capacity-scheduler.xml');
  1593. var csProperties = {};
  1594. configs.forEach(function (_configProperty) {
  1595. csProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1596. this._recordHostOverrideFromObj(_configProperty, 'capacity-scheduler', 'version1', this);
  1597. console.log("STEP*: name of the property is: " + _configProperty.name);
  1598. console.log("STEP8: value of the property is: " + _configProperty.value);
  1599. }, this);
  1600. return {type: 'capacity-scheduler', tag: 'version1', properties: csProperties};
  1601. },
  1602. createMapredQueueAcls: function () {
  1603. var configs = this.get('configs').filterProperty('filename', 'mapred-queue-acls.xml');
  1604. var mqProperties = {};
  1605. configs.forEach(function (_configProperty) {
  1606. mqProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1607. this._recordHostOverrideFromObj(_configProperty, 'mapred-queue-acls', 'version1', this);
  1608. console.log("STEP*: name of the property is: " + _configProperty.name);
  1609. console.log("STEP8: value of the property is: " + _configProperty.value);
  1610. }, this);
  1611. return {type: 'mapred-queue-acls', tag: 'version1', properties: mqProperties};
  1612. },
  1613. createHbaseSiteObj: function () {
  1614. var configs = this.get('configs').filterProperty('filename', 'hbase-site.xml');
  1615. var hbaseProperties = {};
  1616. configs.forEach(function (_configProperty) {
  1617. hbaseProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1618. this._recordHostOverrideFromObj(_configProperty, 'hbase-site', 'version1', this);
  1619. }, this);
  1620. return {type: 'hbase-site', tag: 'version1', properties: hbaseProperties};
  1621. },
  1622. createOozieSiteObj: function (serviceName) {
  1623. var configs = this.get('configs').filterProperty('filename', 'oozie-site.xml');
  1624. var oozieProperties = {};
  1625. configs.forEach(function (_configProperty) {
  1626. oozieProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1627. this._recordHostOverrideFromObj(_configProperty, 'oozie-site', 'version1', this);
  1628. }, this);
  1629. var globals = this.get('content.serviceConfigProperties').filterProperty('id', 'puppet var');
  1630. if (globals.someProperty('name', 'oozie_database')) {
  1631. var oozieDb = globals.findProperty('name', 'oozie_database');
  1632. if (oozieDb.value === 'New Derby Database') {
  1633. // oozieProperties["oozie.service.JPAService.jdbc.url"] = "jdbc:derby:${oozie.data.dir}/${oozie.db.schema.name}-db;create=true";
  1634. oozieProperties["oozie.service.JPAService.jdbc.driver"] = "org.apache.derby.jdbc.EmbeddedDriver";
  1635. } else if (oozieDb.value === 'Existing MySQL Database') {
  1636. // oozieProperties["oozie.service.JPAService.jdbc.url"] = "jdbc:mysql://" + oozieHost + "/" + oozieDbName;
  1637. oozieProperties["oozie.service.JPAService.jdbc.driver"] = "com.mysql.jdbc.Driver";
  1638. } else { //existing oracle database
  1639. // oozieProperties["oozie.service.JPAService.jdbc.url"] = "jdbc:oracle:thin:@//" + oozieHost + ":1521/" + oozieDbName;
  1640. oozieProperties["oozie.service.JPAService.jdbc.driver"] = "oracle.jdbc.driver.OracleDriver";
  1641. }
  1642. }
  1643. return {type: 'oozie-site', tag: 'version1', properties: oozieProperties};
  1644. },
  1645. createHiveSiteObj: function (serviceName) {
  1646. var configs = this.get('configs').filterProperty('filename', 'hive-site.xml');
  1647. var hiveProperties = {};
  1648. configs.forEach(function (_configProperty) {
  1649. hiveProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1650. this._recordHostOverrideFromObj(_configProperty, 'hive-site', 'version1', this);
  1651. }, this);
  1652. var globals = this.get('content.serviceConfigProperties').filterProperty('id', 'puppet var');
  1653. if (globals.someProperty('name', 'hive_database')) {
  1654. var hiveDb = globals.findProperty('name', 'hive_database');
  1655. if (hiveDb.value === 'New MySQL Database') {
  1656. hiveProperties["javax.jdo.option.ConnectionDriverName"] = "com.mysql.jdbc.Driver";
  1657. } else if (hiveDb.value === 'Existing MySQL Database'){
  1658. hiveProperties["javax.jdo.option.ConnectionDriverName"] = "com.mysql.jdbc.Driver";
  1659. } else { //existing oracle database
  1660. hiveProperties["javax.jdo.option.ConnectionDriverName"] = "oracle.jdbc.driver.OracleDriver";
  1661. }
  1662. }
  1663. return {type: 'hive-site', tag: 'version1', properties: hiveProperties};
  1664. },
  1665. createWebHCatSiteObj: function (serviceName) {
  1666. var configs = this.get('configs').filterProperty('filename', 'webhcat-site.xml');
  1667. var webHCatProperties = {};
  1668. configs.forEach(function (_configProperty) {
  1669. webHCatProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1670. this._recordHostOverrideFromObj(_configProperty, 'webhcat-site', 'version1', this);
  1671. }, this);
  1672. return {type: 'webhcat-site', tag: 'version1', properties: webHCatProperties};
  1673. },
  1674. createStormSiteObj: function (s) {
  1675. var configs = this.get('configs').filterProperty('filename', 'storm-site.xml');
  1676. var stormProperties = {};
  1677. configs.forEach(function (_configProperty) {
  1678. if (_configProperty.name == "storm.zookeeper.servers") {
  1679. stormProperties[_configProperty.name] = JSON.stringify(_configProperty.value).replace(/"/g, "'");
  1680. } else {
  1681. stormProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1682. }
  1683. this._recordHostOverrideFromObj(_configProperty, 'storm-site', 'version1', this);
  1684. }, this);
  1685. return {type: 'storm-site', tag: 'version1', properties: stormProperties};
  1686. },
  1687. ajaxQueueFinished: function () {
  1688. //do something
  1689. },
  1690. doNextAjaxCall: function () {
  1691. if (this.get('ajaxBusy')) {
  1692. return;
  1693. }
  1694. var queue = this.get('ajaxQueue');
  1695. if (!queue.length) {
  1696. this.ajaxQueueFinished();
  1697. return;
  1698. }
  1699. var first = queue[0];
  1700. this.set('ajaxQueue', queue.slice(1));
  1701. this.set('ajaxQueueLeft', this.get('ajaxQueue').length);
  1702. this.set('ajaxBusy', true);
  1703. $.ajax(first);
  1704. },
  1705. /**
  1706. * Records all the host overrides per site/tag
  1707. */
  1708. _recordHostOverrideFromObj: function(serviceConfigObj, siteName, tagName, self){
  1709. var overrides = serviceConfigObj.overrides;
  1710. if(overrides && overrides.length>0){
  1711. overrides.forEach(function(override){
  1712. override.hosts.forEach(function(host){
  1713. if(!(host in self.savedHostToOverrideSiteToTagMap)){
  1714. self.savedHostToOverrideSiteToTagMap[host] = {};
  1715. }
  1716. if(!(siteName in self.savedHostToOverrideSiteToTagMap[host])){
  1717. self.savedHostToOverrideSiteToTagMap[host][siteName] = {};
  1718. self.savedHostToOverrideSiteToTagMap[host][siteName].map = {};
  1719. }
  1720. var finalTag = tagName + '_' + host;
  1721. console.log("recordHostOverride(): Saving host override for host="+host+", site="+siteName+", tag="+finalTag+", (key,value)=("+serviceConfigObj.name+","+override.value+")");
  1722. self.savedHostToOverrideSiteToTagMap[host][siteName].tagName = finalTag;
  1723. self.savedHostToOverrideSiteToTagMap[host][siteName].map[serviceConfigObj.name] = override.value;
  1724. });
  1725. });
  1726. }
  1727. },
  1728. /**
  1729. * Creates host level overrides for service configuration.
  1730. *
  1731. */
  1732. createHostOverrideConfigurations: function () {
  1733. var singlePUTHostData = [];
  1734. var savedHostSiteArray = [];
  1735. for ( var host in this.savedHostToOverrideSiteToTagMap) {
  1736. for ( var siteName in this.savedHostToOverrideSiteToTagMap[host]) {
  1737. var tagName = this.savedHostToOverrideSiteToTagMap[host][siteName].tagName;
  1738. var map = this.savedHostToOverrideSiteToTagMap[host][siteName].map;
  1739. savedHostSiteArray.push(host + "///" + siteName);
  1740. singlePUTHostData.push({
  1741. RequestInfo: {
  1742. query: 'Hosts/host_name='+host
  1743. },
  1744. Body: {
  1745. Hosts: {
  1746. desired_config: {
  1747. type: siteName,
  1748. tag: tagName,
  1749. properties: map
  1750. }
  1751. }
  1752. }
  1753. });
  1754. }
  1755. }
  1756. console.log("createHostOverrideConfigSites(): PUTting host-overrides. Data=", singlePUTHostData);
  1757. if(singlePUTHostData.length>0){
  1758. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts';
  1759. this.ajax({
  1760. type: 'PUT',
  1761. url: url,
  1762. data: JSON.stringify(singlePUTHostData),
  1763. dataType: 'text',
  1764. beforeSend: function () {
  1765. console.log("createHostOverrideConfigSites() PUT override=", singlePUTHostData);
  1766. }
  1767. });
  1768. }
  1769. },
  1770. /**
  1771. * We need to do a lot of ajax calls async in special order. To do this,
  1772. * generate array of ajax objects and then send requests step by step. All
  1773. * ajax objects are stored in <code>ajaxQueue</code>
  1774. *
  1775. * @param params
  1776. */
  1777. ajax: function (params) {
  1778. if (App.testMode) return;
  1779. var self = this;
  1780. params = jQuery.extend({
  1781. async: true,
  1782. dataType: 'text',
  1783. statusCode: require('data/statusCodes'),
  1784. timeout: App.timeout,
  1785. error: function (request, ajaxOptions, error) {
  1786. console.log('Step8: In Error ');
  1787. // console.log('Step8: Error message is: ' + request.responseText);
  1788. },
  1789. success: function (data) {
  1790. console.log("TRACE: STep8 -> In success function");
  1791. }
  1792. }, params);
  1793. var success = params.success;
  1794. var error = params.error;
  1795. params.success = function () {
  1796. if (success) {
  1797. success();
  1798. }
  1799. self.set('ajaxBusy', false);
  1800. self.doNextAjaxCall();
  1801. }
  1802. params.error = function (xhr, status, error) {
  1803. var responseText = JSON.parse(xhr.responseText);
  1804. var controller = App.router.get(App.clusterStatus.wizardControllerName);
  1805. controller.registerErrPopup(Em.I18n.t('common.error'), responseText.message);
  1806. self.set('hasErrorOccurred', true);
  1807. // an error will break the ajax call chain and allow submission again
  1808. self.set('isSubmitDisabled', false);
  1809. self.set('isBackBtnDisabled', false);
  1810. App.router.get(self.get('content.controllerName')).setStepsEnable();
  1811. self.get('ajaxQueue').clear();
  1812. self.set('ajaxBusy', false);
  1813. }
  1814. this.get('ajaxQueue').pushObject(params);
  1815. }
  1816. });