step8_controller.js 76 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947
  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 'TEZ':
  484. break;
  485. case 'PIG':
  486. this.loadPig(serviceObj);
  487. break;
  488. case 'SQOOP':
  489. this.loadSqoop(serviceObj);
  490. break;
  491. */
  492. case 'STORM':
  493. if (App.testMode) {
  494. this.loadSTORM(serviceObj);
  495. }
  496. case 'HCATALOG':
  497. break;
  498. default:
  499. }
  500. }
  501. }, this);
  502. },
  503. /**
  504. * load all info about HDFS service
  505. * @param hdfsObj
  506. */
  507. loadHDFS: function (hdfsObj) {
  508. hdfsObj.get('service_components').forEach(function (_component) {
  509. switch (_component.get('display_name')) {
  510. case 'NameNode':
  511. this.loadNnValue(_component);
  512. break;
  513. case 'SecondaryNameNode':
  514. this.loadSnnValue(_component);
  515. break;
  516. case 'DataNodes':
  517. this.loadDnValue(_component);
  518. break;
  519. default:
  520. }
  521. }, this);
  522. //var
  523. this.get('services').pushObject(hdfsObj);
  524. },
  525. /**
  526. * load all info about GLUSTERFS service
  527. * @param glusterfsObj
  528. */
  529. loadGLUSTERFS: function (glusterfsObj) {
  530. glusterfsObj.get('service_components').forEach(function (_component) {
  531. switch (_component.get('display_name')) {
  532. case 'GLUSTERFS Client':
  533. this.loadGLUSTERFSClientValue(_component);
  534. break;
  535. default:
  536. }
  537. }, this);
  538. this.get('services').pushObject(glusterfsObj);
  539. },
  540. loadGLUSTERFSClientValue: function (glusterfsComponent) {
  541. var glusterfsClientHosts = this.get('content.slaveComponentHosts').findProperty('displayName', 'Client');
  542. var totalGLUSTERFSHosts = glusterfsClientHosts.hosts.length;
  543. glusterfsComponent.set('component_value', totalGLUSTERFSHosts + ' hosts');
  544. },
  545. loadNnValue: function (nnComponent) {
  546. var nnHostName = this.get('content.masterComponentHosts').findProperty('display_name', nnComponent.display_name);
  547. nnComponent.set('component_value', nnHostName.hostName);
  548. },
  549. loadSnnValue: function (snnComponent) {
  550. var snnHostName = this.get('content.masterComponentHosts').findProperty('display_name', 'SNameNode');
  551. snnComponent.set('component_value', snnHostName.hostName);
  552. },
  553. loadDnValue: function (dnComponent) {
  554. var dnHosts = this.get('content.slaveComponentHosts').findProperty('displayName', 'DataNode');
  555. var totalDnHosts = dnHosts.hosts.length;
  556. /* var totalGroups = this.get('slaveComponentConfig.components').findProperty('componentName', 'DATANODE').groups.length;
  557. var groupLabel;
  558. if (totalGroups == 1) {
  559. groupLabel = 'group';
  560. } else {
  561. groupLabel = 'groups';
  562. }
  563. */
  564. dnComponent.set('component_value', totalDnHosts + Em.I18n.t('installer.step8.hosts'));
  565. },
  566. /**
  567. * Load all info about mapReduce service
  568. * @param mrObj
  569. */
  570. loadMapReduce: function (mrObj) {
  571. mrObj.get('service_components').forEach(function (_component) {
  572. switch (_component.get('display_name')) {
  573. case 'JobTracker':
  574. this.loadJtValue(_component);
  575. break;
  576. case 'TaskTrackers':
  577. this.loadTtValue(_component);
  578. break;
  579. default:
  580. }
  581. }, this);
  582. this.get('services').pushObject(mrObj);
  583. },
  584. loadMapReduce2: function(mrObj){
  585. mrObj.get('service_components').forEach(function (_component) {
  586. switch (_component.get('display_name')) {
  587. case 'History Server':
  588. _component.set('component_value', this.get('content.masterComponentHosts').findProperty('component', 'HISTORYSERVER').hostName);
  589. break;
  590. }
  591. }, this);
  592. this.get('services').pushObject(mrObj);
  593. },
  594. loadYARN: function(mrObj){
  595. mrObj.get('service_components').forEach(function (_component) {
  596. switch (_component.get('display_name')) {
  597. case 'NodeManager':
  598. this.loadNMValue(_component);
  599. break;
  600. case 'ResourceManager':
  601. _component.set('component_value', this.get('content.masterComponentHosts').findProperty('component', 'RESOURCEMANAGER').hostName);
  602. break;
  603. case 'History Server':
  604. _component.set('component_value', this.get('content.masterComponentHosts').findProperty('component', 'HISTORYSERVER').hostName);
  605. break;
  606. }
  607. }, this);
  608. this.get('services').pushObject(mrObj);
  609. },
  610. loadNMValue: function (nmComponent) {
  611. var nmHosts = this.get('content.slaveComponentHosts').findProperty('componentName', 'NODEMANAGER');
  612. nmComponent.set('component_value', nmHosts.hosts.length + Em.I18n.t('installer.step8.hosts'));
  613. },
  614. loadJtValue: function (jtComponent) {
  615. var jtHostName = this.get('content.masterComponentHosts').findProperty('display_name', jtComponent.display_name);
  616. jtComponent.set('component_value', jtHostName.hostName);
  617. },
  618. loadTtValue: function (ttComponent) {
  619. var ttHosts = this.get('content.slaveComponentHosts').findProperty('displayName', 'TaskTracker');
  620. var totalTtHosts = ttHosts.hosts.length;
  621. ttComponent.set('component_value', totalTtHosts + Em.I18n.t('installer.step8.hosts'));
  622. },
  623. /**
  624. * Load all info about Hive service
  625. * @param hiveObj
  626. */
  627. loadHive: function (hiveObj) {
  628. hiveObj.get('service_components').forEach(function (_component) {
  629. switch (_component.get('display_name')) {
  630. case 'Hive Metastore':
  631. this.loadHiveMetaStoreValue(_component);
  632. break;
  633. case 'Database':
  634. this.loadHiveDbValue(_component);
  635. break;
  636. default:
  637. }
  638. }, this);
  639. this.get('services').pushObject(hiveObj);
  640. },
  641. loadHiveMetaStoreValue: function (metaStoreComponent) {
  642. var hiveHostName = this.get('content.masterComponentHosts').findProperty('display_name', 'HiveServer2');
  643. metaStoreComponent.set('component_value', hiveHostName.hostName);
  644. },
  645. loadHiveDbValue: function (dbComponent) {
  646. var hiveDb = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'hive_database');
  647. if (hiveDb.value === 'New MySQL Database') {
  648. dbComponent.set('component_value', 'MySQL (New Database)');
  649. } else if(hiveDb.value === 'Existing MySQL Database'){
  650. var db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'hive_existing_mysql_database');
  651. dbComponent.set('component_value', db.value + ' (' + hiveDb.value + ')');
  652. } else { // existing oracle database
  653. var db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'hive_existing_oracle_database');
  654. dbComponent.set('component_value', db.value + ' (' + hiveDb.value + ')');
  655. }
  656. },
  657. /**
  658. * Load all info about Hbase
  659. * @param hbaseObj
  660. */
  661. loadHbase: function (hbaseObj) {
  662. hbaseObj.service_components.forEach(function (_component) {
  663. switch (_component.display_name) {
  664. case 'Master':
  665. this.loadMasterValue(_component);
  666. break;
  667. case 'RegionServers':
  668. this.loadRegionServerValue(_component);
  669. break;
  670. default:
  671. }
  672. }, this);
  673. this.get('services').pushObject(hbaseObj);
  674. },
  675. loadMasterValue: function (hbaseMaster) {
  676. var hbaseHostName = this.get('content.masterComponentHosts').filterProperty('display_name', 'HBase Master');
  677. if (hbaseHostName.length == 1) {
  678. hbaseMaster.set('component_value', hbaseHostName[0].hostName);
  679. } else {
  680. hbaseMaster.set('component_value', hbaseHostName[0].hostName + Em.I18n.t('installer.step8.other').format(hbaseHostName.length - 1));
  681. }
  682. },
  683. loadRegionServerValue: function (rsComponent) {
  684. var rsHosts = this.get('content.slaveComponentHosts').findProperty('displayName', 'RegionServer');
  685. var totalRsHosts = rsHosts.hosts.length;
  686. /* var totalGroups = this.get('slaveComponentConfig.components').findProperty('componentName', 'HBASE_REGIONSERVER').groups.length;
  687. var groupLabel;
  688. if (totalGroups == 1) {
  689. groupLabel = 'group';
  690. } else {
  691. groupLabel = 'groups';
  692. } */
  693. rsComponent.set('component_value', totalRsHosts + Em.I18n.t('installer.step8.hosts'));
  694. },
  695. /**
  696. * Load all info about ZooKeeper service
  697. * @param zkObj
  698. */
  699. loadZk: function (zkObj) {
  700. zkObj.get('service_components').forEach(function (_component) {
  701. switch (_component.get('display_name')) {
  702. case 'Servers':
  703. this.loadZkServerValue(_component);
  704. break;
  705. default:
  706. }
  707. }, this);
  708. this.get('services').pushObject(zkObj);
  709. },
  710. loadZkServerValue: function (serverComponent) {
  711. var zkHostNames = this.get('content.masterComponentHosts').filterProperty('display_name', 'ZooKeeper').length;
  712. var hostSuffix;
  713. if (zkHostNames === 1) {
  714. hostSuffix = Em.I18n.t('installer.step8.host');
  715. } else {
  716. hostSuffix = Em.I18n.t('installer.step8.hosts');
  717. }
  718. serverComponent.set('component_value', zkHostNames + ' ' + hostSuffix);
  719. },
  720. /**
  721. * Load all info about Hue services
  722. * @param hueObj
  723. */
  724. loadHue: function (hueObj) {
  725. hueObj.get('service_components').forEach(function (_component) {
  726. switch (_component.get('display_name')) {
  727. case 'Server':
  728. this.loadHueServerValue(_component);
  729. break;
  730. default:
  731. }
  732. }, this);
  733. this.get('services').pushObject(hueObj);
  734. },
  735. loadHueServerValue: function (hueServer) {
  736. var hueServerName = this.get('content.masterComponentHosts').findProperty('display_name', 'Hue Server');
  737. hueServer.set('component_value', hueServerName.hostName);
  738. },
  739. /**
  740. * Load all info about Oozie services
  741. * @param oozieObj
  742. */
  743. loadOozie: function (oozieObj) {
  744. oozieObj.get('service_components').forEach(function (_component) {
  745. switch (_component.get('display_name')) {
  746. case 'Server':
  747. this.loadOozieServerValue(_component);
  748. break;
  749. case 'Database':
  750. // TODO: uncomment when ready to integrate with Oozie Database other than Derby
  751. this.loadOozieDbValue(_component);
  752. break;
  753. default:
  754. }
  755. }, this);
  756. this.get('services').pushObject(oozieObj);
  757. },
  758. loadOozieServerValue: function (oozieServer) {
  759. var oozieServerName = this.get('content.masterComponentHosts').findProperty('display_name', 'Oozie Server');
  760. oozieServer.set('component_value', oozieServerName.hostName);
  761. },
  762. loadOozieDbValue: function (dbComponent) {
  763. var oozieDb = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_database');
  764. if (oozieDb.value === 'New Derby Database'){
  765. var db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_derby_database');
  766. dbComponent.set('component_value', db.value + ' (' + oozieDb.value + ')');
  767. }/* else if (oozieDb.value === 'New MySQL Database') {
  768. dbComponent.set('component_value', 'MySQL (New Database)');
  769. } */else if(oozieDb.value === 'Existing MySQL Database'){
  770. var db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_mysql_database');
  771. dbComponent.set('component_value', db.value + ' (' + oozieDb.value + ')');
  772. } else { // existing oracle database
  773. var db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_oracle_database');
  774. dbComponent.set('component_value', db.value + ' (' + oozieDb.value + ')');
  775. }
  776. },
  777. /**
  778. * Load all info about Nagios service
  779. * @param nagiosObj
  780. */
  781. loadNagios: function (nagiosObj) {
  782. nagiosObj.service_components.forEach(function (_component) {
  783. switch (_component.display_name) {
  784. case 'Server':
  785. this.loadNagiosServerValue(_component);
  786. break;
  787. case 'Administrator':
  788. this.loadNagiosAdminValue(_component);
  789. break;
  790. default:
  791. }
  792. }, this);
  793. this.get('services').pushObject(nagiosObj);
  794. },
  795. loadNagiosServerValue: function (nagiosServer) {
  796. var nagiosServerName = this.get('content.masterComponentHosts').findProperty('display_name', 'Nagios Server');
  797. nagiosServer.set('component_value', nagiosServerName.hostName);
  798. },
  799. loadNagiosAdminValue: function (nagiosAdmin) {
  800. var config = this.get('content.serviceConfigProperties');
  801. var adminLoginName = config.findProperty('name', 'nagios_web_login');
  802. var adminEmail = config.findProperty('name', 'nagios_contact');
  803. nagiosAdmin.set('component_value', adminLoginName.value + ' / (' + adminEmail.value + ')');
  804. },
  805. /**
  806. * Load all info about ganglia
  807. * @param gangliaObj
  808. */
  809. loadGanglia: function (gangliaObj) {
  810. gangliaObj.get('service_components').forEach(function (_component) {
  811. switch (_component.get('display_name')) {
  812. case 'Server':
  813. this.loadGangliaServerValue(_component);
  814. break;
  815. default:
  816. }
  817. }, this);
  818. this.get('services').pushObject(gangliaObj);
  819. },
  820. loadGangliaServerValue: function (gangliaServer) {
  821. var gangliaServerName = this.get('content.masterComponentHosts').findProperty('display_name', 'Ganglia Server');
  822. gangliaServer.set('component_value', gangliaServerName.hostName);
  823. },
  824. loadSqoop: function (sqoopObj) {
  825. this.get('services').pushObject(sqoopObj);
  826. },
  827. loadPig: function (pigObj) {
  828. this.get('services').pushObject(pigObj);
  829. },
  830. loadSTORM: function (stormObj) {
  831. stormObj.get('service_components').forEach(function(component) {
  832. switch (component.get('display_name')) {
  833. case 'Nimbus':
  834. this.loadNimbusValue(component);
  835. break;
  836. case 'SuperVisor':
  837. this.loadSuperVisorValue(component);
  838. break;
  839. default:
  840. }
  841. }, this);
  842. this.get('services').pushObject(stormObj);
  843. },
  844. loadNimbusValue: function(component) {
  845. var nimbusHost = this.get('content.masterComponentHosts').filterProperty('display_name', component.get('display_name'));
  846. component.set('component_value', nimbusHost[0].hostName);
  847. },
  848. loadSuperVisorValue: function(component) {
  849. var hostsCount = this.get('content.slaveComponentHosts').findProperty('componentName', 'CLIENT').hosts.length;
  850. var hostsText = hostsCount > 1 ? hostsCount + ' hosts' : hostsCount + ' host'
  851. component.set('component_value', hostsText);
  852. },
  853. /**
  854. * Onclick handler for <code>next</code> button
  855. */
  856. submit: function () {
  857. if (this.get('isSubmitDisabled')) {
  858. return;
  859. }
  860. if ((this.get('content.controllerName') == 'addHostController') && this.get('securityEnabled')) {
  861. var self = this;
  862. App.showConfirmationPopup(function() {
  863. self.submitProceed();
  864. }, Em.I18n.t('installer.step8.securityConfirmationPopupBody'));
  865. }
  866. else {
  867. this.submitProceed();
  868. }
  869. },
  870. submitProceed: function() {
  871. this.set('isSubmitDisabled', true);
  872. this.set('isBackBtnDisabled', true);
  873. if (this.get('content.controllerName') == 'addHostController') {
  874. App.router.get('addHostController').setLowerStepsDisable(4);
  875. }
  876. // checkpoint the cluster status on the server so that the user can resume from where they left off
  877. switch (this.get('content.controllerName')) {
  878. case 'installerController':
  879. App.clusterStatus.setClusterStatus({
  880. clusterName: this.get('clusterName'),
  881. clusterState: 'CLUSTER_DEPLOY_PREP_2',
  882. wizardControllerName: this.get('content.controllerName'),
  883. localdb: App.db.data
  884. });
  885. break;
  886. case 'addHostController':
  887. App.clusterStatus.setClusterStatus({
  888. clusterName: this.get('clusterName'),
  889. clusterState: 'ADD_HOSTS_DEPLOY_PREP_2',
  890. wizardControllerName: this.get('content.controllerName'),
  891. localdb: App.db.data
  892. });
  893. break;
  894. case 'addServiceController':
  895. App.clusterStatus.setClusterStatus({
  896. clusterName: this.get('clusterName'),
  897. clusterState: 'ADD_SERVICES_DEPLOY_PREP_2',
  898. wizardControllerName: this.get('content.controllerName'),
  899. localdb: App.db.data
  900. });
  901. break;
  902. default:
  903. break;
  904. }
  905. // delete any existing clusters to start from a clean slate
  906. // before creating a new cluster in install wizard
  907. // TODO: modify for multi-cluster support
  908. if (this.get('content.controllerName') == 'installerController' && (!App.testMode)) {
  909. var clusterNames = this.getExistingClusterNames();
  910. this.deleteClusters(clusterNames);
  911. }
  912. this.setLocalRepositories();
  913. this.createCluster();
  914. this.createSelectedServices();
  915. this.createConfigurations();
  916. this.createComponents();
  917. this.registerHostsToCluster();
  918. if (App.supports.hostOverridesInstaller) {
  919. this.createConfigurationGroups();
  920. }
  921. this.createAllHostComponents();
  922. this.createHostOverrideConfigurations();
  923. this.ajaxQueueFinished = function () {
  924. console.log('everything is loaded');
  925. App.router.send('next');
  926. };
  927. this.doNextAjaxCall();
  928. },
  929. /**
  930. * Used in progress bar
  931. */
  932. ajaxQueueLength: function () {
  933. return this.get('ajaxQueue').length;
  934. }.property('ajaxQueue.length'),
  935. /**
  936. * Used in progress bar
  937. */
  938. ajaxQueueLeft: 0,
  939. setAmbariUIDb: function () {
  940. var dbContent = this.get('content.slaveGroupProperties');
  941. var slaveComponentConfig = this.get("slaveComponentConfig");
  942. this.persistKeyValues(slaveComponentConfig.version, dbContent);
  943. this.persistKeyValues('current_version', slaveComponentConfig.version);
  944. },
  945. persistKeyValues: function (key, value) {
  946. var str = "{ '" + key + "' : '" + JSON.stringify(value) + "'}";
  947. var obj = eval("(" + str + ")");
  948. this.ajax({
  949. type: "POST",
  950. url: App.apiPrefix + '/persist',
  951. data: JSON.stringify(obj),
  952. beforeSend: function () {
  953. console.log('BeforeSend: persistKeyValues', obj);
  954. }
  955. });
  956. },
  957. clusterName: function () {
  958. return this.get('content.cluster.name');
  959. }.property('content.cluster.name'),
  960. clusterNames: [],
  961. // returns an array of existing cluster names.
  962. // returns an empty array if there are no existing clusters.
  963. getExistingClusterNames: function () {
  964. var url = App.apiPrefix + '/clusters';
  965. App.ajax.send({
  966. name: 'wizard.step8.existing_cluster_names',
  967. sender: this,
  968. success: 'getExistingClusterNamesSuccessCallBack',
  969. error: 'getExistingClusterNamesErrorCallback'
  970. });
  971. return this.get('clusterNames');
  972. },
  973. getExistingClusterNamesSuccessCallBack: function (data) {
  974. var clusterNames = data.items.mapProperty('Clusters.cluster_name');
  975. console.log("Got existing cluster names: " + clusterNames);
  976. this.set('clusterNames', clusterNames);
  977. },
  978. getExistingClusterNamesErrorCallback: function () {
  979. console.log("Failed to get existing cluster names");
  980. this.set('clusterNames', []);
  981. },
  982. deleteClusters: function (clusterNames) {
  983. clusterNames.forEach(function (clusterName) {
  984. App.ajax.send({
  985. name: 'wizard.step8.delete_cluster',
  986. sender: this,
  987. data: {
  988. name: clusterName
  989. },
  990. success: 'deleteClustersSuccessCallback',
  991. error: 'deleteClustersErrorCallback'
  992. });
  993. }, this);
  994. },
  995. deleteClustersSuccessCallback: function(data, opt, params) {
  996. console.log('DELETE cluster ' + params.name + ' succeeded');
  997. },
  998. deleteClustersErrorCallback: function(request, ajaxOptions, error, opt) {
  999. console.log('DELETE cluster failed');
  1000. },
  1001. /**
  1002. * Updates local repositories for the Ambari server.
  1003. */
  1004. setLocalRepositories: function () {
  1005. if (this.get('content.controllerName') !== 'installerController' || !App.supports.localRepositories) {
  1006. return false;
  1007. }
  1008. var self = this;
  1009. var apiUrl = App.get('stack2VersionURL');
  1010. var stacks = this.get('content.stacks');
  1011. stacks.forEach(function (stack) {
  1012. stack.operatingSystems.forEach(function (os) {
  1013. if (os.baseUrl !== os.originalBaseUrl) {
  1014. console.log("Updating local repository URL from " + os.originalBaseUrl + " -> " + os.baseUrl + ". ", os);
  1015. var url = App.apiPrefix + apiUrl + "/operatingSystems/" + os.osType + "/repositories/" + stack.name;
  1016. self.ajax({
  1017. type: 'PUT',
  1018. url: url,
  1019. data: JSON.stringify({
  1020. "Repositories": {
  1021. "base_url": os.baseUrl
  1022. }
  1023. }),
  1024. beforeSend: function () {
  1025. console.log("BeforeSend: setLocalRepositories PUT to ", url);
  1026. }
  1027. });
  1028. }
  1029. });
  1030. });
  1031. },
  1032. /**
  1033. * The following create* functions are called upon submitting Step 8.
  1034. */
  1035. createCluster: function () {
  1036. if (this.get('content.controllerName') !== 'installerController') {
  1037. return false;
  1038. }
  1039. var clusterName = this.get('clusterName');
  1040. var url = App.apiPrefix + '/clusters/' + clusterName;
  1041. var stackVersion = (this.get('content.installOptions.localRepo')) ? App.currentStackVersion.replace(/(-\d+(\.\d)*)/ig, "Local$&") : App.currentStackVersion;
  1042. this.ajax({
  1043. type: 'POST',
  1044. url: url,
  1045. data: JSON.stringify({ "Clusters": {"version": stackVersion }}),
  1046. beforeSend: function () {
  1047. console.log("BeforeSend: createCluster for " + clusterName);
  1048. }
  1049. });
  1050. },
  1051. createSelectedServices: function () {
  1052. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/services';
  1053. var data = this.createServiceData();
  1054. var httpMethod = 'POST';
  1055. if (!data.length) {
  1056. return;
  1057. }
  1058. this.ajax({
  1059. type: httpMethod,
  1060. url: url,
  1061. data: JSON.stringify(data),
  1062. beforeSend: function () {
  1063. console.log('BeforeSend: createSelectedServices ', data);
  1064. }
  1065. });
  1066. },
  1067. createServiceData: function () {
  1068. var services = this.get('selectedServices').mapProperty('serviceName');
  1069. var data = [];
  1070. services.forEach(function (_service) {
  1071. data.pushObject({"ServiceInfo": { "service_name": _service }});
  1072. }, this);
  1073. return data;
  1074. },
  1075. createComponents: function () {
  1076. var serviceComponents = require('data/service_components');
  1077. var services = this.get('selectedServices').mapProperty('serviceName');
  1078. services.forEach(function (_service) {
  1079. var components = serviceComponents.filterProperty('service_name', _service);
  1080. var componentsData = components.map(function (_component) {
  1081. return { "ServiceComponentInfo": { "component_name": _component.component_name } };
  1082. });
  1083. // Service must be specified in terms of a query for creating multiple components at the same time.
  1084. // See AMBARI-1018.
  1085. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/services?ServiceInfo/service_name=' + _service;
  1086. var data = {
  1087. "components": componentsData
  1088. }
  1089. this.ajax({
  1090. type: 'POST',
  1091. url: url,
  1092. data: JSON.stringify(data),
  1093. beforeSend: function () {
  1094. console.log('BeforeSend: createComponents for ' + _service, componentsData);
  1095. }
  1096. });
  1097. }, this);
  1098. },
  1099. registerHostsToCluster: function () {
  1100. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts';
  1101. var data = this.createRegisterHostData();
  1102. if (data.length == 0) {
  1103. return;
  1104. }
  1105. this.ajax({
  1106. type: 'POST',
  1107. url: url,
  1108. data: JSON.stringify(data),
  1109. beforeSend: function () {
  1110. console.log('BeforeSend: registerHostsToCluster', data);
  1111. }
  1112. });
  1113. },
  1114. createRegisterHostData: function () {
  1115. var hosts = this.getRegisteredHosts().filterProperty('isInstalled', false);
  1116. if (!hosts.length) {
  1117. return [];
  1118. }
  1119. return hosts.map(function (host) {
  1120. return {"Hosts": { "host_name": host.hostName}};
  1121. });
  1122. },
  1123. // TODO: review the code for add hosts / add services scenarios...
  1124. createAllHostComponents: function () {
  1125. var masterHosts = this.get('content.masterComponentHosts');
  1126. var slaveHosts = this.get('content.slaveComponentHosts');
  1127. var clients = this.get('content.clients');
  1128. // note: masterHosts has 'component' vs slaveHosts has 'componentName'
  1129. var masterComponents = masterHosts.mapProperty('component').uniq();
  1130. masterComponents.forEach(function (component) {
  1131. var hostNames = masterHosts.filterProperty('component', component).filterProperty('isInstalled', false).mapProperty('hostName');
  1132. this.registerHostsToComponent(hostNames, component);
  1133. }, this);
  1134. slaveHosts.forEach(function (_slave) {
  1135. if (_slave.componentName !== 'CLIENT') {
  1136. var hostNames = _slave.hosts.filterProperty('isInstalled', false).mapProperty('hostName');
  1137. this.registerHostsToComponent(hostNames, _slave.componentName);
  1138. } else {
  1139. clients.forEach(function (_client) {
  1140. var hostNames = _slave.hosts.mapProperty('hostName');
  1141. switch (_client.component_name) {
  1142. case 'HDFS_CLIENT':
  1143. // install HDFS_CLIENT on HBASE_MASTER, HBASE_REGIONSERVER, WEBHCAT_SERVER, HISTORYSERVER and OOZIE_SERVER hosts
  1144. masterHosts.filterProperty('component', 'HBASE_MASTER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1145. hostNames.pushObject(_masterHost.hostName);
  1146. }, this);
  1147. masterHosts.filterProperty('component', 'HBASE_REGIONSERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1148. hostNames.pushObject(_masterHost.hostName);
  1149. }, this);
  1150. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1151. hostNames.pushObject(_masterHost.hostName);
  1152. }, this);
  1153. masterHosts.filterProperty('component', 'HISTORYSERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1154. hostNames.pushObject(_masterHost.hostName);
  1155. }, this);
  1156. masterHosts.filterProperty('component', 'OOZIE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1157. hostNames.pushObject(_masterHost.hostName);
  1158. }, this);
  1159. break;
  1160. case 'MAPREDUCE_CLIENT':
  1161. // install MAPREDUCE_CLIENT on HIVE_SERVER, OOZIE_SERVER, NAGIOS_SERVER, and WEBHCAT_SERVER hosts
  1162. masterHosts.filterProperty('component', 'HIVE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1163. hostNames.pushObject(_masterHost.hostName);
  1164. }, this);
  1165. masterHosts.filterProperty('component', 'OOZIE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1166. hostNames.pushObject(_masterHost.hostName);
  1167. }, this);
  1168. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1169. hostNames.pushObject(_masterHost.hostName);
  1170. }, this);
  1171. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1172. hostNames.pushObject(_masterHost.hostName);
  1173. }, this);
  1174. break;
  1175. case 'OOZIE_CLIENT':
  1176. // install OOZIE_CLIENT on NAGIOS_SERVER host
  1177. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1178. hostNames.pushObject(_masterHost.hostName);
  1179. }, this);
  1180. break;
  1181. case 'ZOOKEEPER_CLIENT':
  1182. // install ZOOKEEPER_CLIENT on WEBHCAT_SERVER host
  1183. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1184. hostNames.pushObject(_masterHost.hostName);
  1185. }, this);
  1186. break;
  1187. case 'HIVE_CLIENT':
  1188. //install HIVE client on NAGIOS_SERVER host
  1189. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1190. hostNames.pushObject(_masterHost.hostName);
  1191. }, this);
  1192. masterHosts.filterProperty('component', 'HIVE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1193. hostNames.pushObject(_masterHost.hostName);
  1194. }, this);
  1195. break;
  1196. case 'HCAT':
  1197. // install HCAT (client) on NAGIOS_SERVER host
  1198. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1199. hostNames.pushObject(_masterHost.hostName);
  1200. }, this);
  1201. break;
  1202. case 'YARN_CLIENT':
  1203. // install YARN_CLIENT on NAGIOS_SERVER,HIVE_SERVER,OOZIE_SERVER,WEBHCAT_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. masterHosts.filterProperty('component', 'OOZIE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1211. hostNames.pushObject(_masterHost.hostName);
  1212. }, this);
  1213. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1214. hostNames.pushObject(_masterHost.hostName);
  1215. }, this);
  1216. break;
  1217. }
  1218. hostNames = hostNames.uniq();
  1219. if (_client.isInstalled) {
  1220. //check whether clients are already installed on selected master hosts!!!
  1221. var installedHosts = _slave.hosts.filterProperty('isInstalled', true).mapProperty('hostName');
  1222. installedHosts.forEach(function (host) {
  1223. if (hostNames.contains(host)) {
  1224. hostNames.splice(hostNames.indexOf(host), 1);
  1225. }
  1226. }, this);
  1227. }
  1228. this.registerHostsToComponent(hostNames, _client.component_name);
  1229. }, this);
  1230. }
  1231. }, this);
  1232. // add Ganglia Monitor (Slave) to all hosts if Ganglia service is selected
  1233. var gangliaService = this.get('content.services').filterProperty('isSelected', true).findProperty('serviceName', 'GANGLIA');
  1234. if (gangliaService) {
  1235. var hosts = this.getRegisteredHosts();
  1236. if (gangliaService.get('isInstalled')) {
  1237. hosts = hosts.filterProperty('isInstalled', false);
  1238. }
  1239. if (hosts.length) {
  1240. this.registerHostsToComponent(hosts.mapProperty('hostName'), 'GANGLIA_MONITOR');
  1241. }
  1242. }
  1243. // add MySQL Server if Hive is selected
  1244. var hiveService = this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).findProperty('serviceName', 'HIVE');
  1245. if (hiveService) {
  1246. var hiveDb = this.get('content.serviceConfigProperties').findProperty('name', 'hive_database');
  1247. if(hiveDb.value == "New MySQL Database") {
  1248. this.registerHostsToComponent(masterHosts.filterProperty('component', 'HIVE_SERVER').mapProperty('hostName'), 'MYSQL_SERVER');
  1249. }
  1250. }
  1251. },
  1252. registerHostsToComponent: function (hostNames, componentName) {
  1253. if (hostNames.length == 0) {
  1254. return;
  1255. }
  1256. // currently we are specifying the predicate as a query string.
  1257. // this can hit a ~4000-character limit in Jetty server.
  1258. // chunk to multiple calls if needed
  1259. // var hostsPredicate = hostNames.map(function (hostName) {
  1260. // return 'Hosts/host_name=' + hostName;
  1261. // }).join('|');
  1262. var queryStrArr = [];
  1263. var queryStr = '';
  1264. hostNames.forEach(function (hostName) {
  1265. queryStr += 'Hosts/host_name=' + hostName + '|';
  1266. if (queryStr.length > 3500) {
  1267. queryStrArr.push(queryStr.slice(0, -1));
  1268. queryStr = '';
  1269. }
  1270. });
  1271. if (queryStr.length > 0) {
  1272. queryStrArr.push(queryStr.slice(0, -1));
  1273. }
  1274. queryStrArr.forEach(function (queryStr) {
  1275. // console.log('creating host components for ' + queryStr);
  1276. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts?' + queryStr;
  1277. var data = {
  1278. "host_components": [
  1279. {
  1280. "HostRoles": {
  1281. "component_name": componentName
  1282. }
  1283. }
  1284. ]
  1285. };
  1286. this.ajax({
  1287. type: 'POST',
  1288. url: url,
  1289. data: JSON.stringify(data)
  1290. });
  1291. }, this);
  1292. },
  1293. createConfigurations: function () {
  1294. var selectedServices = this.get('selectedServices');
  1295. if (this.get('content.controllerName') == 'installerController') {
  1296. this.get('serviceConfigTags').pushObject(this.createCoreSiteObj());
  1297. this.get('serviceConfigTags').pushObject(this.createHdfsSiteObj());
  1298. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HDFS'));
  1299. }
  1300. var globalSiteObj = this.createGlobalSiteObj();
  1301. if (this.get('content.controllerName') == 'addServiceController') {
  1302. globalSiteObj.tag = 'version' + (new Date).getTime();
  1303. }
  1304. this.get('serviceConfigTags').pushObject(globalSiteObj);
  1305. if (selectedServices.someProperty('serviceName', 'MAPREDUCE')) {
  1306. this.get('serviceConfigTags').pushObject(this.createMrSiteObj());
  1307. if (App.supports.capacitySchedulerUi) {
  1308. this.get('serviceConfigTags').pushObject(this.createCapacityScheduler());
  1309. this.get('serviceConfigTags').pushObject(this.createMapredQueueAcls());
  1310. }
  1311. this.get('serviceConfigTags').pushObject(this.createLog4jObj('MAPREDUCE'));
  1312. }
  1313. if (selectedServices.someProperty('serviceName', 'MAPREDUCE2')) {
  1314. this.get('serviceConfigTags').pushObject(this.createMrSiteObj());
  1315. this.get('serviceConfigTags').pushObject(this.createLog4jObj('MAPREDUCE2'));
  1316. }
  1317. if (selectedServices.someProperty('serviceName', 'YARN')) {
  1318. this.get('serviceConfigTags').pushObject(this.createYarnSiteObj());
  1319. this.get('serviceConfigTags').pushObject(this.createCapacityScheduler());
  1320. this.get('serviceConfigTags').pushObject(this.createLog4jObj('YARN'));
  1321. }
  1322. if (selectedServices.someProperty('serviceName', 'HBASE')) {
  1323. this.get('serviceConfigTags').pushObject(this.createHbaseSiteObj());
  1324. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HBASE'));
  1325. }
  1326. if (selectedServices.someProperty('serviceName', 'OOZIE')) {
  1327. this.get('serviceConfigTags').pushObject(this.createOozieSiteObj('OOZIE'));
  1328. this.get('serviceConfigTags').pushObject(this.createLog4jObj('OOZIE'));
  1329. }
  1330. if (selectedServices.someProperty('serviceName', 'HIVE')) {
  1331. this.get('serviceConfigTags').pushObject(this.createHiveSiteObj('HIVE'));
  1332. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HIVE'));
  1333. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HIVE-EXEC'));
  1334. }
  1335. if (selectedServices.someProperty('serviceName', 'WEBHCAT')) {
  1336. this.get('serviceConfigTags').pushObject(this.createWebHCatSiteObj('WEBHCAT'));
  1337. }
  1338. if (selectedServices.someProperty('serviceName', 'HUE')) {
  1339. this.get('serviceConfigTags').pushObject(this.createHueSiteObj('HUE'));
  1340. }
  1341. if (selectedServices.someProperty('serviceName', 'PIG')) {
  1342. this.get('serviceConfigTags').pushObject(this.createLog4jObj('PIG'));
  1343. }
  1344. if (selectedServices.someProperty('serviceName', 'ZOOKEEPER')) {
  1345. this.get('serviceConfigTags').pushObject(this.createLog4jObj('ZOOKEEPER'));
  1346. }
  1347. this.applyConfigurationsToCluster();
  1348. },
  1349. applyConfigurationsToCluster: function() {
  1350. var clusterUrl = App.apiPrefix + '/clusters/' + this.get('clusterName');
  1351. var configData = [];
  1352. this.get('serviceConfigTags').forEach(function (_serviceConfig) {
  1353. var Clusters = {
  1354. Clusters: {
  1355. desired_config: {
  1356. type: _serviceConfig.type,
  1357. tag: _serviceConfig.tag,
  1358. properties: _serviceConfig.properties
  1359. }
  1360. }
  1361. };
  1362. configData.pushObject(JSON.stringify(Clusters));
  1363. }, this);
  1364. var data = {
  1365. configData: '[' + configData.toString() + ']'
  1366. };
  1367. console.debug("applyConfigurationsToCluster(Step8): Applying to URL", clusterUrl, " Data:", data.configData);
  1368. this.ajax({
  1369. type: 'PUT',
  1370. url: clusterUrl,
  1371. data: data.configData,
  1372. beforeSend: function () {
  1373. console.log("BeforeSend: Updating cluster config");
  1374. }
  1375. });
  1376. },
  1377. createConfigurationGroups: function () {
  1378. var configGroups = this.get('content.configGroups').filterProperty('isDefault', false);
  1379. var clusterName = this.get('clusterName');
  1380. var sendData = [];
  1381. var updateData = [];
  1382. var serviceConfigController = App.router.get('mainServiceInfoConfigsController');
  1383. var timeTag = (new Date).getTime();
  1384. var groupsToDelete = App.router.get(this.get('content.controllerName')).getDBProperty('groupsToDelete');
  1385. if (groupsToDelete && groupsToDelete.length > 0) {
  1386. this.removeInstalledServicesConfigurationGroups(groupsToDelete);
  1387. }
  1388. configGroups.forEach(function (configGroup) {
  1389. var groupConfigs = [];
  1390. var groupData = {
  1391. "cluster_name": clusterName,
  1392. "group_name": configGroup.name,
  1393. "tag": configGroup.service.id,
  1394. "description": configGroup.description,
  1395. "hosts": [],
  1396. "desired_configs": []
  1397. };
  1398. configGroup.hosts.forEach(function (hostName) {
  1399. groupData.hosts.push({"host_name": hostName});
  1400. });
  1401. //wrap properties into Em.Object to make them compatible with buildGroupDesiredConfigs method
  1402. configGroup.properties.forEach(function (property) {
  1403. groupConfigs.push(Em.Object.create(property));
  1404. });
  1405. groupData.desired_configs = serviceConfigController.buildGroupDesiredConfigs.call(serviceConfigController, groupConfigs, timeTag);
  1406. // check for group from installed service
  1407. if (configGroup.isForUpdate === true) {
  1408. // if group is a new one, create it
  1409. if (!configGroup.id) {
  1410. sendData.push({"ConfigGroup": groupData});
  1411. } else {
  1412. // update an existing group
  1413. groupData.id = configGroup.id;
  1414. updateData.push({"ConfigGroup": groupData});
  1415. }
  1416. } else {
  1417. sendData.push({"ConfigGroup": groupData});
  1418. }
  1419. //each group should have unique tag to prevent overriding configs from common sites
  1420. timeTag++;
  1421. }, this);
  1422. if (sendData.length > 0) {
  1423. this.applyConfigurationGroups(sendData);
  1424. }
  1425. if (updateData.length > 0) {
  1426. this.applyInstalledServicesConfigurationGroup(updateData);
  1427. }
  1428. },
  1429. applyConfigurationGroups: function (sendData) {
  1430. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/config_groups';
  1431. this.ajax({
  1432. type: 'POST',
  1433. url: url,
  1434. data: JSON.stringify(sendData)
  1435. });
  1436. },
  1437. applyInstalledServicesConfigurationGroup: function (updateData) {
  1438. updateData.forEach(function(item) {
  1439. App.router.get('mainServiceInfoConfigsController').putConfigGroupChanges(item);
  1440. });
  1441. },
  1442. removeInstalledServicesConfigurationGroups: function(groupsToDelete) {
  1443. groupsToDelete.forEach(function(item) {
  1444. App.config.deleteConfigGroup(Em.Object.create(item));
  1445. });
  1446. },
  1447. createGlobalSiteObj: function () {
  1448. var globalSiteProperties = {};
  1449. var globalSiteObj = this.get('globals');
  1450. var isGLUSTERFSSelected = this.get('selectedServices').someProperty('serviceName', 'GLUSTERFS');
  1451. // screen out the GLUSTERFS-specific global config entries when they are not required
  1452. if (!isGLUSTERFSSelected) {
  1453. globalSiteObj = globalSiteObj.filter(function(_config) {
  1454. return _config.name.indexOf("fs_glusterfs") < 0;
  1455. });
  1456. }
  1457. globalSiteObj.forEach(function (_globalSiteObj) {
  1458. var heapsizeException = ['hadoop_heapsize','yarn_heapsize','nodemanager_heapsize','resourcemanager_heapsize'];
  1459. // do not pass any globals whose name ends with _host or _hosts
  1460. if (_globalSiteObj.isRequiredByAgent !== false) {
  1461. // append "m" to JVM memory options except for hadoop_heapsize
  1462. if (/_heapsize|_newsize|_maxnewsize$/.test(_globalSiteObj.name) && !heapsizeException.contains(_globalSiteObj.name)) {
  1463. globalSiteProperties[_globalSiteObj.name] = _globalSiteObj.value + "m";
  1464. } else {
  1465. globalSiteProperties[_globalSiteObj.name] = App.config.escapeXMLCharacters(_globalSiteObj.value);
  1466. }
  1467. }
  1468. this._recordHostOverrideFromObj(_globalSiteObj, 'global', 'version1', this);
  1469. }, this);
  1470. // we don't expose gmond_user to the user; it needs to be the same as gmetad_user
  1471. globalSiteProperties['gmond_user'] = globalSiteProperties['gmetad_user'];
  1472. return {"type": "global", "tag": "version1", "properties": globalSiteProperties};
  1473. },
  1474. createCoreSiteObj: function () {
  1475. var coreSiteObj = this.get('configs').filterProperty('filename', 'core-site.xml');
  1476. var coreSiteProperties = {};
  1477. // hadoop.proxyuser.oozie.hosts needs to be skipped if oozie is not selected
  1478. var isOozieSelected = this.get('selectedServices').someProperty('serviceName', 'OOZIE');
  1479. var oozieUser = this.get('globals').someProperty('name', 'oozie_user') ? this.get('globals').findProperty('name', 'oozie_user').value : null;
  1480. var isHiveSelected = this.get('selectedServices').someProperty('serviceName', 'HIVE');
  1481. var hiveUser = this.get('globals').someProperty('name', 'hive_user') ? this.get('globals').findProperty('name', 'hive_user').value : null;
  1482. var isHcatSelected = this.get('selectedServices').someProperty('serviceName', 'WEBHCAT');
  1483. var hcatUser = this.get('globals').someProperty('name', 'hcat_user') ? this.get('globals').findProperty('name', 'hcat_user').value : null;
  1484. var isGLUSTERFSSelected = this.get('selectedServices').someProperty('serviceName', 'GLUSTERFS');
  1485. // screen out the GLUSTERFS-specific core-site.xml entries when they are not needed
  1486. if (!isGLUSTERFSSelected) {
  1487. coreSiteObj = coreSiteObj.filter(function(_config) {
  1488. return _config.name.indexOf("fs.glusterfs") < 0;
  1489. });
  1490. }
  1491. coreSiteObj.forEach(function (_coreSiteObj) {
  1492. 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'))) {
  1493. coreSiteProperties[_coreSiteObj.name] = App.config.escapeXMLCharacters(_coreSiteObj.value);
  1494. this._recordHostOverrideFromObj(_coreSiteObj, 'core-site', 'version1', this);
  1495. }
  1496. if (isGLUSTERFSSelected && _coreSiteObj.name == "fs.default.name") {
  1497. 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;
  1498. }
  1499. console.log("STEP*: name of the property is: " + _coreSiteObj.name);
  1500. console.log("STEP8: value of the property is: " + _coreSiteObj.value);
  1501. }, this);
  1502. return {"type": "core-site", "tag": "version1", "properties": coreSiteProperties};
  1503. },
  1504. createHdfsSiteObj: function () {
  1505. var hdfsSiteObj = this.get('configs').filterProperty('filename', 'hdfs-site.xml');
  1506. var hdfsProperties = {};
  1507. hdfsSiteObj.forEach(function (_configProperty) {
  1508. hdfsProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1509. this._recordHostOverrideFromObj(_configProperty, 'hdfs-site', 'version1', this);
  1510. console.log("STEP*: name of the property is: " + _configProperty.name);
  1511. console.log("STEP8: value of the property is: " + _configProperty.value);
  1512. }, this);
  1513. return {"type": "hdfs-site", "tag": "version1", "properties": hdfsProperties };
  1514. },
  1515. createLog4jObj: function (fileName) {
  1516. fileName = fileName.toLowerCase();
  1517. var Log4jObj = this.get('configs').filterProperty('filename', fileName + '-log4j.xml');
  1518. var Log4jProperties = {};
  1519. Log4jObj.forEach(function (_configProperty) {
  1520. Log4jProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1521. this._recordHostOverrideFromObj(_configProperty, fileName + '-log4j', 'version1', this);
  1522. console.log("STEP*: name of the property is: " + _configProperty.name);
  1523. console.log("STEP8: value of the property is: " + _configProperty.value);
  1524. }, this);
  1525. return {"type": fileName + "-log4j", "tag": "version1", "properties": Log4jProperties };
  1526. },
  1527. createHueSiteObj: function () {
  1528. var hueSiteObj = this.get('configs').filterProperty('filename', 'hue-site.xml');
  1529. var hueProperties = {};
  1530. hueSiteObj.forEach(function (_configProperty) {
  1531. hueProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1532. this._recordHostOverrideFromObj(_configProperty, 'hue-site', 'version1', this);
  1533. console.log("STEP*: name of the property is: " + _configProperty.name);
  1534. console.log("STEP8: value of the property is: " + _configProperty.value);
  1535. }, this);
  1536. return {"type": "hue-site", "tag": "version1", "properties": hueProperties };
  1537. },
  1538. createMrSiteObj: function () {
  1539. var configs = this.get('configs').filterProperty('filename', 'mapred-site.xml');
  1540. var mrProperties = {};
  1541. configs.forEach(function (_configProperty) {
  1542. mrProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1543. this._recordHostOverrideFromObj(_configProperty, 'mapred-site', 'version1', this);
  1544. console.log("STEP*: name of the property is: " + _configProperty.name);
  1545. console.log("STEP8: value of the property is: " + _configProperty.value);
  1546. }, this);
  1547. return {type: 'mapred-site', tag: 'version1', properties: mrProperties};
  1548. },
  1549. createYarnSiteObj: function () {
  1550. var configs = this.get('configs').filterProperty('filename', 'yarn-site.xml');
  1551. var mrProperties = {};
  1552. configs.forEach(function (_configProperty) {
  1553. mrProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1554. this._recordHostOverrideFromObj(_configProperty, 'yarn-site', 'version1', this);
  1555. console.log("STEP*: name of the property is: " + _configProperty.name);
  1556. console.log("STEP8: value of the property is: " + _configProperty.value);
  1557. }, this);
  1558. return {type: 'yarn-site', tag: 'version1', properties: mrProperties};
  1559. },
  1560. createCapacityScheduler: function () {
  1561. var configs = this.get('configs').filterProperty('filename', 'capacity-scheduler.xml');
  1562. var csProperties = {};
  1563. configs.forEach(function (_configProperty) {
  1564. csProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1565. this._recordHostOverrideFromObj(_configProperty, 'capacity-scheduler', 'version1', this);
  1566. console.log("STEP*: name of the property is: " + _configProperty.name);
  1567. console.log("STEP8: value of the property is: " + _configProperty.value);
  1568. }, this);
  1569. return {type: 'capacity-scheduler', tag: 'version1', properties: csProperties};
  1570. },
  1571. createMapredQueueAcls: function () {
  1572. var configs = this.get('configs').filterProperty('filename', 'mapred-queue-acls.xml');
  1573. var mqProperties = {};
  1574. configs.forEach(function (_configProperty) {
  1575. mqProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1576. this._recordHostOverrideFromObj(_configProperty, 'mapred-queue-acls', 'version1', this);
  1577. console.log("STEP*: name of the property is: " + _configProperty.name);
  1578. console.log("STEP8: value of the property is: " + _configProperty.value);
  1579. }, this);
  1580. return {type: 'mapred-queue-acls', tag: 'version1', properties: mqProperties};
  1581. },
  1582. createHbaseSiteObj: function () {
  1583. var configs = this.get('configs').filterProperty('filename', 'hbase-site.xml');
  1584. var hbaseProperties = {};
  1585. configs.forEach(function (_configProperty) {
  1586. hbaseProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1587. this._recordHostOverrideFromObj(_configProperty, 'hbase-site', 'version1', this);
  1588. }, this);
  1589. return {type: 'hbase-site', tag: 'version1', properties: hbaseProperties};
  1590. },
  1591. createOozieSiteObj: function (serviceName) {
  1592. var configs = this.get('configs').filterProperty('filename', 'oozie-site.xml');
  1593. var oozieProperties = {};
  1594. configs.forEach(function (_configProperty) {
  1595. oozieProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1596. this._recordHostOverrideFromObj(_configProperty, 'oozie-site', 'version1', this);
  1597. }, this);
  1598. var globals = this.get('content.serviceConfigProperties').filterProperty('id', 'puppet var');
  1599. if (globals.someProperty('name', 'oozie_database')) {
  1600. var oozieDb = globals.findProperty('name', 'oozie_database');
  1601. if (oozieDb.value === 'New Derby Database') {
  1602. // oozieProperties["oozie.service.JPAService.jdbc.url"] = "jdbc:derby:${oozie.data.dir}/${oozie.db.schema.name}-db;create=true";
  1603. oozieProperties["oozie.service.JPAService.jdbc.driver"] = "org.apache.derby.jdbc.EmbeddedDriver";
  1604. } else if (oozieDb.value === 'Existing MySQL Database') {
  1605. // oozieProperties["oozie.service.JPAService.jdbc.url"] = "jdbc:mysql://" + oozieHost + "/" + oozieDbName;
  1606. oozieProperties["oozie.service.JPAService.jdbc.driver"] = "com.mysql.jdbc.Driver";
  1607. } else { //existing oracle database
  1608. // oozieProperties["oozie.service.JPAService.jdbc.url"] = "jdbc:oracle:thin:@//" + oozieHost + ":1521/" + oozieDbName;
  1609. oozieProperties["oozie.service.JPAService.jdbc.driver"] = "oracle.jdbc.driver.OracleDriver";
  1610. }
  1611. }
  1612. return {type: 'oozie-site', tag: 'version1', properties: oozieProperties};
  1613. },
  1614. createHiveSiteObj: function (serviceName) {
  1615. var configs = this.get('configs').filterProperty('filename', 'hive-site.xml');
  1616. var hiveProperties = {};
  1617. configs.forEach(function (_configProperty) {
  1618. hiveProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1619. this._recordHostOverrideFromObj(_configProperty, 'hive-site', 'version1', this);
  1620. }, this);
  1621. var globals = this.get('content.serviceConfigProperties').filterProperty('id', 'puppet var');
  1622. if (globals.someProperty('name', 'hive_database')) {
  1623. var hiveDb = globals.findProperty('name', 'hive_database');
  1624. if (hiveDb.value === 'New MySQL Database') {
  1625. hiveProperties["javax.jdo.option.ConnectionDriverName"] = "com.mysql.jdbc.Driver";
  1626. } else if (hiveDb.value === 'Existing MySQL Database'){
  1627. hiveProperties["javax.jdo.option.ConnectionDriverName"] = "com.mysql.jdbc.Driver";
  1628. } else { //existing oracle database
  1629. hiveProperties["javax.jdo.option.ConnectionDriverName"] = "oracle.jdbc.driver.OracleDriver";
  1630. }
  1631. }
  1632. return {type: 'hive-site', tag: 'version1', properties: hiveProperties};
  1633. },
  1634. createWebHCatSiteObj: function (serviceName) {
  1635. var configs = this.get('configs').filterProperty('filename', 'webhcat-site.xml');
  1636. var webHCatProperties = {};
  1637. configs.forEach(function (_configProperty) {
  1638. webHCatProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1639. this._recordHostOverrideFromObj(_configProperty, 'webhcat-site', 'version1', this);
  1640. }, this);
  1641. return {type: 'webhcat-site', tag: 'version1', properties: webHCatProperties};
  1642. },
  1643. ajaxQueueFinished: function () {
  1644. //do something
  1645. },
  1646. doNextAjaxCall: function () {
  1647. if (this.get('ajaxBusy')) {
  1648. return;
  1649. }
  1650. var queue = this.get('ajaxQueue');
  1651. if (!queue.length) {
  1652. this.ajaxQueueFinished();
  1653. return;
  1654. }
  1655. var first = queue[0];
  1656. this.set('ajaxQueue', queue.slice(1));
  1657. this.set('ajaxQueueLeft', this.get('ajaxQueue').length);
  1658. this.set('ajaxBusy', true);
  1659. $.ajax(first);
  1660. },
  1661. /**
  1662. * Records all the host overrides per site/tag
  1663. */
  1664. _recordHostOverrideFromObj: function(serviceConfigObj, siteName, tagName, self){
  1665. var overrides = serviceConfigObj.overrides;
  1666. if(overrides && overrides.length>0){
  1667. overrides.forEach(function(override){
  1668. override.hosts.forEach(function(host){
  1669. if(!(host in self.savedHostToOverrideSiteToTagMap)){
  1670. self.savedHostToOverrideSiteToTagMap[host] = {};
  1671. }
  1672. if(!(siteName in self.savedHostToOverrideSiteToTagMap[host])){
  1673. self.savedHostToOverrideSiteToTagMap[host][siteName] = {};
  1674. self.savedHostToOverrideSiteToTagMap[host][siteName].map = {};
  1675. }
  1676. var finalTag = tagName + '_' + host;
  1677. console.log("recordHostOverride(): Saving host override for host="+host+", site="+siteName+", tag="+finalTag+", (key,value)=("+serviceConfigObj.name+","+override.value+")");
  1678. self.savedHostToOverrideSiteToTagMap[host][siteName].tagName = finalTag;
  1679. self.savedHostToOverrideSiteToTagMap[host][siteName].map[serviceConfigObj.name] = override.value;
  1680. });
  1681. });
  1682. }
  1683. },
  1684. /**
  1685. * Creates host level overrides for service configuration.
  1686. *
  1687. */
  1688. createHostOverrideConfigurations: function () {
  1689. var singlePUTHostData = [];
  1690. var savedHostSiteArray = [];
  1691. for ( var host in this.savedHostToOverrideSiteToTagMap) {
  1692. for ( var siteName in this.savedHostToOverrideSiteToTagMap[host]) {
  1693. var tagName = this.savedHostToOverrideSiteToTagMap[host][siteName].tagName;
  1694. var map = this.savedHostToOverrideSiteToTagMap[host][siteName].map;
  1695. savedHostSiteArray.push(host + "///" + siteName);
  1696. singlePUTHostData.push({
  1697. RequestInfo: {
  1698. query: 'Hosts/host_name='+host
  1699. },
  1700. Body: {
  1701. Hosts: {
  1702. desired_config: {
  1703. type: siteName,
  1704. tag: tagName,
  1705. properties: map
  1706. }
  1707. }
  1708. }
  1709. });
  1710. }
  1711. }
  1712. console.log("createHostOverrideConfigSites(): PUTting host-overrides. Data=", singlePUTHostData);
  1713. if(singlePUTHostData.length>0){
  1714. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts';
  1715. this.ajax({
  1716. type: 'PUT',
  1717. url: url,
  1718. data: JSON.stringify(singlePUTHostData),
  1719. dataType: 'text',
  1720. beforeSend: function () {
  1721. console.log("createHostOverrideConfigSites() PUT override=", singlePUTHostData);
  1722. }
  1723. });
  1724. }
  1725. },
  1726. /**
  1727. * We need to do a lot of ajax calls async in special order. To do this,
  1728. * generate array of ajax objects and then send requests step by step. All
  1729. * ajax objects are stored in <code>ajaxQueue</code>
  1730. *
  1731. * @param params
  1732. */
  1733. ajax: function (params) {
  1734. if (App.testMode) return;
  1735. var self = this;
  1736. params = jQuery.extend({
  1737. async: true,
  1738. dataType: 'text',
  1739. statusCode: require('data/statusCodes'),
  1740. timeout: App.timeout,
  1741. error: function (request, ajaxOptions, error) {
  1742. console.log('Step8: In Error ');
  1743. // console.log('Step8: Error message is: ' + request.responseText);
  1744. },
  1745. success: function (data) {
  1746. console.log("TRACE: STep8 -> In success function");
  1747. }
  1748. }, params);
  1749. var success = params.success;
  1750. var error = params.error;
  1751. params.success = function () {
  1752. if (success) {
  1753. success();
  1754. }
  1755. self.set('ajaxBusy', false);
  1756. self.doNextAjaxCall();
  1757. }
  1758. params.error = function (xhr, status, error) {
  1759. var responseText = JSON.parse(xhr.responseText);
  1760. var controller = App.router.get(App.clusterStatus.wizardControllerName);
  1761. controller.registerErrPopup(Em.I18n.t('common.error'), responseText.message);
  1762. self.set('hasErrorOccurred', true);
  1763. // an error will break the ajax call chain and allow submission again
  1764. self.set('isSubmitDisabled', false);
  1765. self.set('isBackBtnDisabled', false);
  1766. App.router.get(self.get('content.controllerName')).setStepsEnable();
  1767. self.get('ajaxQueue').clear();
  1768. self.set('ajaxBusy', false);
  1769. }
  1770. this.get('ajaxQueue').pushObject(params);
  1771. }
  1772. });