step8_controller.js 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565
  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. * @param {String} templateName
  235. * @param {String} expression
  236. * @param {String} name
  237. * @return {Object}
  238. * example: <code>{
  239. * value: '...',
  240. * overrides: {
  241. * 'value1': [h1, h2],
  242. * 'value2': [h3]
  243. * }
  244. * }</code>
  245. */
  246. getGlobConfigValueWithOverrides: function (templateName, expression, name) {
  247. var express = expression.match(/<(.*?)>/g);
  248. var value = expression;
  249. if (express == null) {
  250. return { value : expression, overrides: []}; // if site property do not map any global property then return the value
  251. }
  252. var overrideHostToValue = {};
  253. express.forEach(function (_express) {
  254. //console.log("The value of template is: " + _express);
  255. var index = parseInt(_express.match(/\[([\d]*)(?=\])/)[1]);
  256. if (this.get('globals').someProperty('name', templateName[index])) {
  257. //console.log("The name of the variable is: " + this.get('content.serviceConfigProperties').findProperty('name', templateName[index]).name);
  258. var globalObj = this.get('globals').findProperty('name', templateName[index]);
  259. var globValue = globalObj.value;
  260. // Hack for templeton.zookeeper.hosts
  261. var preReplaceValue = null;
  262. 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
  263. preReplaceValue = value;
  264. value = this._replaceConfigValues(name, _express, value, globValue);
  265. }
  266. if(globalObj.overrides!=null){
  267. globalObj.overrides.forEach(function(override){
  268. var ov = override.value;
  269. var hostsArray = override.hosts;
  270. hostsArray.forEach(function(host){
  271. if(!(host in overrideHostToValue)){
  272. overrideHostToValue[host] = this._replaceConfigValues(name, _express, preReplaceValue, ov);
  273. }else{
  274. overrideHostToValue[host] = this._replaceConfigValues(name, _express, overrideHostToValue[host], ov);
  275. }
  276. }, this);
  277. }, this);
  278. }
  279. } else {
  280. /*
  281. console.log("ERROR: The variable name is: " + templateName[index]);
  282. console.log("ERROR: mapped config from configMapping file has no corresponding variable in " +
  283. "content.serviceConfigProperties. Two possible reasons for the error could be: 1) The service is not selected. " +
  284. "and/OR 2) The service_config metadata file has no corresponding global var for the site property variable");
  285. */
  286. value = null;
  287. }
  288. }, this);
  289. var valueWithOverrides = {
  290. value: value,
  291. overrides: []
  292. };
  293. var overrideValueToHostMap = {};
  294. if(!jQuery.isEmptyObject(overrideHostToValue)){
  295. for(var host in overrideHostToValue){
  296. var hostVal = overrideHostToValue[host];
  297. if(!(hostVal in overrideValueToHostMap)){
  298. overrideValueToHostMap[hostVal] = [];
  299. }
  300. overrideValueToHostMap[hostVal].push(host);
  301. }
  302. }
  303. for(var val in overrideValueToHostMap){
  304. valueWithOverrides.overrides.push({
  305. value: val,
  306. hosts: overrideValueToHostMap[val]
  307. });
  308. }
  309. return valueWithOverrides;
  310. },
  311. _replaceConfigValues: function (name, express, value, globValue) {
  312. return value.replace(express, globValue);
  313. },
  314. /**
  315. * Load all info about cluster to <code>clusterInfo</code> variable
  316. */
  317. loadClusterInfo: function () {
  318. //Admin name
  319. var admin = this.rawContent.findProperty('config_name', 'Admin');
  320. admin.config_value = App.db.getLoginName();
  321. console.log("STEP8: the value of content cluster name: " + App.db.getLoginName());
  322. if (admin.config_value) {
  323. this.get('clusterInfo').pushObject(Ember.Object.create(admin));
  324. }
  325. // cluster name
  326. var cluster = this.rawContent.findProperty('config_name', 'cluster');
  327. cluster.config_value = this.get('content.cluster.name');
  328. console.log("STEP8: the value of content cluster name: " + this.get('content.cluster.name'));
  329. this.get('clusterInfo').pushObject(Ember.Object.create(cluster));
  330. //hosts
  331. var masterHosts = this.get('content.masterComponentHosts').mapProperty('hostName').uniq();
  332. var slaveHosts = this.get('content.slaveComponentHosts');
  333. var hostObj = [];
  334. slaveHosts.forEach(function (_hosts) {
  335. hostObj = hostObj.concat(_hosts.hosts);
  336. }, this);
  337. slaveHosts = hostObj.mapProperty('hostName').uniq();
  338. var componentHosts = masterHosts.concat(slaveHosts).uniq();
  339. var totalHosts = App.Host.find().mapProperty('hostName').concat(componentHosts).uniq();
  340. var newHostsCount = totalHosts.length - App.Host.find().content.length;
  341. this.set('totalHosts', totalHosts);
  342. var totalHostsObj = this.rawContent.findProperty('config_name', 'hosts');
  343. totalHostsObj.config_value = totalHosts.length + ' (' + newHostsCount + ' new)';
  344. this.get('clusterInfo').pushObject(Ember.Object.create(totalHostsObj));
  345. //repo
  346. if (['addHostController', 'addServiceController'].contains(this.get('content.controllerName'))) {
  347. this.loadRepoInfo();
  348. } else { // from install wizard
  349. var selectedStack = this.get('content.stacks').findProperty('isSelected', true);
  350. var allRepos = [];
  351. var supportedOs = ['redhat5', 'redhat6', 'sles11'];
  352. if (selectedStack && selectedStack.operatingSystems) {
  353. selectedStack.operatingSystems.forEach(function (os) {
  354. if (os.selected && supportedOs.contains(os.osType)) {
  355. allRepos.push(Em.Object.create({
  356. base_url: os.baseUrl,
  357. os_type: Em.I18n.t("installer.step8.repoInfo.osType." + os.osType)
  358. }));
  359. }
  360. }, this);
  361. }
  362. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  363. this.get('clusterInfo').set('repoInfo', allRepos);
  364. }
  365. },
  366. /**
  367. * get the repositories info of HDP from server. Used only in addHost controller.
  368. */
  369. loadRepoInfo: function(){
  370. var nameVersionCombo = App.get('currentStackVersion');
  371. var stackName = nameVersionCombo.split('-')[0];
  372. var stackVersion = nameVersionCombo.split('-')[1];
  373. App.ajax.send({
  374. name: 'cluster.load_repositories',
  375. sender: this,
  376. data: {
  377. stackName: stackName,
  378. stackVersion: stackVersion
  379. },
  380. success: 'loadRepoInfoSuccessCallback',
  381. error: 'loadRepositoriesErrorCallback'
  382. });
  383. },
  384. loadRepoInfoSuccessCallback: function (data) {
  385. var allRepos = [];
  386. var supportedOs = ['redhat5', 'redhat6', 'sles11'];
  387. data.items.forEach(function (item) {
  388. var os = item.repositories[0].Repositories;
  389. if (supportedOs.contains(os.osType)) {
  390. allRepos.push(Em.Object.create({
  391. base_url: os.base_url,
  392. os_type: Em.I18n.t("installer.step8.repoInfo.osType." + os.os_type)
  393. }));
  394. }
  395. }, this);
  396. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  397. this.get('clusterInfo').set('repoInfo', allRepos);
  398. },
  399. loadRepoInfoErrorCallback: function(request, ajaxOptions, error) {
  400. console.log('Error message is: ' + request.responseText);
  401. var allRepos = [];
  402. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  403. this.get('clusterInfo').set('repoInfo', allRepos);
  404. },
  405. /**
  406. * Load all info about services to <code>services</code> variable
  407. */
  408. loadServices: function () {
  409. var reviewService = this.rawContent.findProperty('config_name', 'services');
  410. this.get('selectedServices').forEach(function (_service) {
  411. console.log('INFO: step8: Name of the service from getService function: ' + _service.serviceName);
  412. var serviceObj = reviewService.config_value.findProperty('service_name', _service.serviceName);
  413. if (serviceObj) {
  414. serviceObj.get('service_components').forEach(function (_component) {
  415. this.assignComponentHosts(_component);
  416. }, this);
  417. this.get('services').pushObject(serviceObj);
  418. }
  419. }, this);
  420. },
  421. assignComponentHosts: function (component) {
  422. var componentValue;
  423. if (component.get('customHandler')) {
  424. this[component.get('customHandler')].call(this, component);
  425. } else {
  426. if (component.get('isMaster')) {
  427. componentValue = this.get('content.masterComponentHosts')
  428. .findProperty('component', component.component_name).hostName;
  429. } else {
  430. var hostsLength = this.get('content.slaveComponentHosts')
  431. .findProperty('componentName', component.component_name)
  432. .hosts.length;
  433. componentValue = hostsLength + Em.I18n.t('installer.step8.host' + ((hostsLength > 1) ? 's' : ''));
  434. }
  435. component.set('component_value', componentValue);
  436. }
  437. },
  438. loadHiveDbValue: function (dbComponent) {
  439. var hiveDb = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'hive_database');
  440. if (hiveDb.value === 'New MySQL Database') {
  441. dbComponent.set('component_value', 'MySQL (New Database)');
  442. } else if(hiveDb.value === 'Existing MySQL Database'){
  443. var db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'hive_existing_mysql_database');
  444. dbComponent.set('component_value', db.value + ' (' + hiveDb.value + ')');
  445. } else { // existing oracle database
  446. var db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'hive_existing_oracle_database');
  447. dbComponent.set('component_value', db.value + ' (' + hiveDb.value + ')');
  448. }
  449. },
  450. loadHbaseMasterValue: function (hbaseMaster) {
  451. var hbaseHostName = this.get('content.masterComponentHosts').filterProperty('component', hbaseMaster.component_name);
  452. if (hbaseHostName.length == 1) {
  453. hbaseMaster.set('component_value', hbaseHostName[0].hostName);
  454. } else {
  455. hbaseMaster.set('component_value', hbaseHostName[0].hostName + Em.I18n.t('installer.step8.other').format(hbaseHostName.length - 1));
  456. }
  457. },
  458. loadZkServerValue: function (serverComponent) {
  459. var zkHostNames = this.get('content.masterComponentHosts').filterProperty('component', serverComponent.component_name).length;
  460. var hostSuffix;
  461. if (zkHostNames === 1) {
  462. hostSuffix = Em.I18n.t('installer.step8.host');
  463. } else {
  464. hostSuffix = Em.I18n.t('installer.step8.hosts');
  465. }
  466. serverComponent.set('component_value', zkHostNames + ' ' + hostSuffix);
  467. },
  468. loadOozieDbValue: function (dbComponent) {
  469. var oozieDb = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_database');
  470. if (oozieDb.value === 'New Derby Database'){
  471. var db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_derby_database');
  472. dbComponent.set('component_value', db.value + ' (' + oozieDb.value + ')');
  473. }/* else if (oozieDb.value === 'New MySQL Database') {
  474. dbComponent.set('component_value', 'MySQL (New Database)');
  475. } */else if(oozieDb.value === 'Existing MySQL Database'){
  476. var db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_mysql_database');
  477. dbComponent.set('component_value', db.value + ' (' + oozieDb.value + ')');
  478. } else { // existing oracle database
  479. var db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_oracle_database');
  480. dbComponent.set('component_value', db.value + ' (' + oozieDb.value + ')');
  481. }
  482. },
  483. loadNagiosAdminValue: function (nagiosAdmin) {
  484. var config = this.get('content.serviceConfigProperties');
  485. var adminLoginName = config.findProperty('name', 'nagios_web_login');
  486. var adminEmail = config.findProperty('name', 'nagios_contact');
  487. nagiosAdmin.set('component_value', adminLoginName.value + ' / (' + adminEmail.value + ')');
  488. },
  489. /**
  490. * Onclick handler for <code>next</code> button
  491. */
  492. submit: function () {
  493. if (this.get('isSubmitDisabled')) {
  494. return;
  495. }
  496. if ((this.get('content.controllerName') == 'addHostController') && this.get('securityEnabled')) {
  497. var self = this;
  498. App.showConfirmationPopup(function() {
  499. self.submitProceed();
  500. }, Em.I18n.t('installer.step8.securityConfirmationPopupBody'));
  501. }
  502. else {
  503. this.submitProceed();
  504. }
  505. },
  506. submitProceed: function() {
  507. this.set('isSubmitDisabled', true);
  508. this.set('isBackBtnDisabled', true);
  509. if (this.get('content.controllerName') == 'addHostController') {
  510. App.router.get('addHostController').setLowerStepsDisable(4);
  511. }
  512. // checkpoint the cluster status on the server so that the user can resume from where they left off
  513. switch (this.get('content.controllerName')) {
  514. case 'installerController':
  515. App.clusterStatus.setClusterStatus({
  516. clusterName: this.get('clusterName'),
  517. clusterState: 'CLUSTER_DEPLOY_PREP_2',
  518. wizardControllerName: this.get('content.controllerName'),
  519. localdb: App.db.data
  520. });
  521. break;
  522. case 'addHostController':
  523. App.clusterStatus.setClusterStatus({
  524. clusterName: this.get('clusterName'),
  525. clusterState: 'ADD_HOSTS_DEPLOY_PREP_2',
  526. wizardControllerName: this.get('content.controllerName'),
  527. localdb: App.db.data
  528. });
  529. break;
  530. case 'addServiceController':
  531. App.clusterStatus.setClusterStatus({
  532. clusterName: this.get('clusterName'),
  533. clusterState: 'ADD_SERVICES_DEPLOY_PREP_2',
  534. wizardControllerName: this.get('content.controllerName'),
  535. localdb: App.db.data
  536. });
  537. break;
  538. default:
  539. break;
  540. }
  541. // delete any existing clusters to start from a clean slate
  542. // before creating a new cluster in install wizard
  543. // TODO: modify for multi-cluster support
  544. if (this.get('content.controllerName') == 'installerController' && (!App.testMode)) {
  545. var clusterNames = this.getExistingClusterNames();
  546. this.deleteClusters(clusterNames);
  547. }
  548. this.setLocalRepositories();
  549. this.createCluster();
  550. this.createSelectedServices();
  551. this.createConfigurations();
  552. this.createComponents();
  553. this.registerHostsToCluster();
  554. if (App.supports.hostOverridesInstaller) {
  555. this.createConfigurationGroups();
  556. }
  557. this.createAllHostComponents();
  558. this.createHostOverrideConfigurations();
  559. this.ajaxQueueFinished = function () {
  560. console.log('everything is loaded');
  561. App.router.send('next');
  562. };
  563. this.doNextAjaxCall();
  564. },
  565. /**
  566. * Used in progress bar
  567. */
  568. ajaxQueueLength: function () {
  569. return this.get('ajaxQueue').length;
  570. }.property('ajaxQueue.length'),
  571. /**
  572. * Used in progress bar
  573. */
  574. ajaxQueueLeft: 0,
  575. setAmbariUIDb: function () {
  576. var dbContent = this.get('content.slaveGroupProperties');
  577. var slaveComponentConfig = this.get("slaveComponentConfig");
  578. this.persistKeyValues(slaveComponentConfig.version, dbContent);
  579. this.persistKeyValues('current_version', slaveComponentConfig.version);
  580. },
  581. persistKeyValues: function (key, value) {
  582. var str = "{ '" + key + "' : '" + JSON.stringify(value) + "'}";
  583. var obj = eval("(" + str + ")");
  584. this.ajax({
  585. type: "POST",
  586. url: App.apiPrefix + '/persist',
  587. data: JSON.stringify(obj),
  588. beforeSend: function () {
  589. console.log('BeforeSend: persistKeyValues', obj);
  590. }
  591. });
  592. },
  593. clusterName: function () {
  594. return this.get('content.cluster.name');
  595. }.property('content.cluster.name'),
  596. clusterNames: [],
  597. // returns an array of existing cluster names.
  598. // returns an empty array if there are no existing clusters.
  599. getExistingClusterNames: function () {
  600. var url = App.apiPrefix + '/clusters';
  601. App.ajax.send({
  602. name: 'wizard.step8.existing_cluster_names',
  603. sender: this,
  604. success: 'getExistingClusterNamesSuccessCallBack',
  605. error: 'getExistingClusterNamesErrorCallback'
  606. });
  607. return this.get('clusterNames');
  608. },
  609. getExistingClusterNamesSuccessCallBack: function (data) {
  610. var clusterNames = data.items.mapProperty('Clusters.cluster_name');
  611. console.log("Got existing cluster names: " + clusterNames);
  612. this.set('clusterNames', clusterNames);
  613. },
  614. getExistingClusterNamesErrorCallback: function () {
  615. console.log("Failed to get existing cluster names");
  616. this.set('clusterNames', []);
  617. },
  618. deleteClusters: function (clusterNames) {
  619. clusterNames.forEach(function (clusterName) {
  620. App.ajax.send({
  621. name: 'wizard.step8.delete_cluster',
  622. sender: this,
  623. data: {
  624. name: clusterName
  625. },
  626. success: 'deleteClustersSuccessCallback',
  627. error: 'deleteClustersErrorCallback'
  628. });
  629. }, this);
  630. },
  631. deleteClustersSuccessCallback: function(data, opt, params) {
  632. console.log('DELETE cluster ' + params.name + ' succeeded');
  633. },
  634. deleteClustersErrorCallback: function(request, ajaxOptions, error, opt) {
  635. console.log('DELETE cluster failed');
  636. },
  637. /**
  638. * Updates local repositories for the Ambari server.
  639. */
  640. setLocalRepositories: function () {
  641. if (this.get('content.controllerName') !== 'installerController' || !App.supports.localRepositories) {
  642. return false;
  643. }
  644. var self = this;
  645. var apiUrl = App.get('stack2VersionURL');
  646. var stacks = this.get('content.stacks');
  647. stacks.forEach(function (stack) {
  648. stack.operatingSystems.forEach(function (os) {
  649. if (os.baseUrl !== os.originalBaseUrl) {
  650. console.log("Updating local repository URL from " + os.originalBaseUrl + " -> " + os.baseUrl + ". ", os);
  651. var url = App.apiPrefix + apiUrl + "/operatingSystems/" + os.osType + "/repositories/" + stack.name;
  652. self.ajax({
  653. type: 'PUT',
  654. url: url,
  655. data: JSON.stringify({
  656. "Repositories": {
  657. "base_url": os.baseUrl
  658. }
  659. }),
  660. beforeSend: function () {
  661. console.log("BeforeSend: setLocalRepositories PUT to ", url);
  662. }
  663. });
  664. }
  665. });
  666. });
  667. },
  668. /**
  669. * The following create* functions are called upon submitting Step 8.
  670. */
  671. createCluster: function () {
  672. if (this.get('content.controllerName') !== 'installerController') {
  673. return false;
  674. }
  675. var clusterName = this.get('clusterName');
  676. var url = App.apiPrefix + '/clusters/' + clusterName;
  677. var stackVersion = (this.get('content.installOptions.localRepo')) ? App.currentStackVersion.replace(/(-\d+(\.\d)*)/ig, "Local$&") : App.currentStackVersion;
  678. this.ajax({
  679. type: 'POST',
  680. url: url,
  681. data: JSON.stringify({ "Clusters": {"version": stackVersion }}),
  682. beforeSend: function () {
  683. console.log("BeforeSend: createCluster for " + clusterName);
  684. }
  685. });
  686. },
  687. createSelectedServices: function () {
  688. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/services';
  689. var data = this.createServiceData();
  690. var httpMethod = 'POST';
  691. if (!data.length) {
  692. return;
  693. }
  694. this.ajax({
  695. type: httpMethod,
  696. url: url,
  697. data: JSON.stringify(data),
  698. beforeSend: function () {
  699. console.log('BeforeSend: createSelectedServices ', data);
  700. }
  701. });
  702. },
  703. createServiceData: function () {
  704. var services = this.get('selectedServices').mapProperty('serviceName');
  705. var data = [];
  706. services.forEach(function (_service) {
  707. data.pushObject({"ServiceInfo": { "service_name": _service }});
  708. }, this);
  709. return data;
  710. },
  711. createComponents: function () {
  712. var serviceComponents = require('data/service_components');
  713. var services = this.get('selectedServices').mapProperty('serviceName');
  714. services.forEach(function (_service) {
  715. var components = serviceComponents.filterProperty('service_name', _service);
  716. var componentsData = components.map(function (_component) {
  717. return { "ServiceComponentInfo": { "component_name": _component.component_name } };
  718. });
  719. // Service must be specified in terms of a query for creating multiple components at the same time.
  720. // See AMBARI-1018.
  721. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/services?ServiceInfo/service_name=' + _service;
  722. var data = {
  723. "components": componentsData
  724. };
  725. this.ajax({
  726. type: 'POST',
  727. url: url,
  728. data: JSON.stringify(data),
  729. beforeSend: function () {
  730. console.log('BeforeSend: createComponents for ' + _service, componentsData);
  731. }
  732. });
  733. }, this);
  734. },
  735. registerHostsToCluster: function () {
  736. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts';
  737. var data = this.createRegisterHostData();
  738. if (data.length == 0) {
  739. return;
  740. }
  741. this.ajax({
  742. type: 'POST',
  743. url: url,
  744. data: JSON.stringify(data),
  745. beforeSend: function () {
  746. console.log('BeforeSend: registerHostsToCluster', data);
  747. }
  748. });
  749. },
  750. createRegisterHostData: function () {
  751. var hosts = this.getRegisteredHosts().filterProperty('isInstalled', false);
  752. if (!hosts.length) {
  753. return [];
  754. }
  755. return hosts.map(function (host) {
  756. return {"Hosts": { "host_name": host.hostName}};
  757. });
  758. },
  759. // TODO: review the code for add hosts / add services scenarios...
  760. createAllHostComponents: function () {
  761. var masterHosts = this.get('content.masterComponentHosts');
  762. var slaveHosts = this.get('content.slaveComponentHosts');
  763. var clients = this.get('content.clients');
  764. // note: masterHosts has 'component' vs slaveHosts has 'componentName'
  765. var masterComponents = masterHosts.mapProperty('component').uniq();
  766. masterComponents.forEach(function (component) {
  767. var hostNames = masterHosts.filterProperty('component', component).filterProperty('isInstalled', false).mapProperty('hostName');
  768. this.registerHostsToComponent(hostNames, component);
  769. }, this);
  770. slaveHosts.forEach(function (_slave) {
  771. if (_slave.componentName !== 'CLIENT') {
  772. var hostNames = _slave.hosts.filterProperty('isInstalled', false).mapProperty('hostName');
  773. this.registerHostsToComponent(hostNames, _slave.componentName);
  774. } else {
  775. clients.forEach(function (_client) {
  776. var hostNames = _slave.hosts.mapProperty('hostName');
  777. switch (_client.component_name) {
  778. case 'HDFS_CLIENT':
  779. // install HDFS_CLIENT on HBASE_MASTER, HBASE_REGIONSERVER, WEBHCAT_SERVER, HISTORYSERVER and OOZIE_SERVER hosts
  780. masterHosts.filterProperty('component', 'HBASE_MASTER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  781. hostNames.pushObject(_masterHost.hostName);
  782. }, this);
  783. masterHosts.filterProperty('component', 'HBASE_REGIONSERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  784. hostNames.pushObject(_masterHost.hostName);
  785. }, this);
  786. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  787. hostNames.pushObject(_masterHost.hostName);
  788. }, this);
  789. masterHosts.filterProperty('component', 'HISTORYSERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  790. hostNames.pushObject(_masterHost.hostName);
  791. }, this);
  792. masterHosts.filterProperty('component', 'OOZIE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  793. hostNames.pushObject(_masterHost.hostName);
  794. }, this);
  795. break;
  796. case 'MAPREDUCE_CLIENT':
  797. // install MAPREDUCE_CLIENT on HIVE_SERVER, OOZIE_SERVER, NAGIOS_SERVER, and WEBHCAT_SERVER hosts
  798. masterHosts.filterProperty('component', 'HIVE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  799. hostNames.pushObject(_masterHost.hostName);
  800. }, this);
  801. masterHosts.filterProperty('component', 'OOZIE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  802. hostNames.pushObject(_masterHost.hostName);
  803. }, this);
  804. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  805. hostNames.pushObject(_masterHost.hostName);
  806. }, this);
  807. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  808. hostNames.pushObject(_masterHost.hostName);
  809. }, this);
  810. break;
  811. case 'OOZIE_CLIENT':
  812. // install OOZIE_CLIENT on NAGIOS_SERVER host
  813. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  814. hostNames.pushObject(_masterHost.hostName);
  815. }, this);
  816. break;
  817. case 'ZOOKEEPER_CLIENT':
  818. // install ZOOKEEPER_CLIENT on WEBHCAT_SERVER host
  819. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  820. hostNames.pushObject(_masterHost.hostName);
  821. }, this);
  822. break;
  823. case 'HIVE_CLIENT':
  824. //install HIVE client on NAGIOS_SERVER host
  825. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  826. hostNames.pushObject(_masterHost.hostName);
  827. }, this);
  828. masterHosts.filterProperty('component', 'HIVE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  829. hostNames.pushObject(_masterHost.hostName);
  830. }, this);
  831. break;
  832. case 'HCAT':
  833. // install HCAT (client) on NAGIOS_SERVER host
  834. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  835. hostNames.pushObject(_masterHost.hostName);
  836. }, this);
  837. break;
  838. case 'YARN_CLIENT':
  839. // install YARN_CLIENT on NAGIOS_SERVER,HIVE_SERVER,OOZIE_SERVER,WEBHCAT_SERVER host
  840. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  841. hostNames.pushObject(_masterHost.hostName);
  842. }, this);
  843. masterHosts.filterProperty('component', 'HIVE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  844. hostNames.pushObject(_masterHost.hostName);
  845. }, this);
  846. masterHosts.filterProperty('component', 'OOZIE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  847. hostNames.pushObject(_masterHost.hostName);
  848. }, this);
  849. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  850. hostNames.pushObject(_masterHost.hostName);
  851. }, this);
  852. break;
  853. }
  854. hostNames = hostNames.uniq();
  855. if (_client.isInstalled) {
  856. //check whether clients are already installed on selected master hosts!!!
  857. var installedHosts = _slave.hosts.filterProperty('isInstalled', true).mapProperty('hostName');
  858. installedHosts.forEach(function (host) {
  859. if (hostNames.contains(host)) {
  860. hostNames.splice(hostNames.indexOf(host), 1);
  861. }
  862. }, this);
  863. }
  864. this.registerHostsToComponent(hostNames, _client.component_name);
  865. }, this);
  866. }
  867. }, this);
  868. // add Ganglia Monitor (Slave) to all hosts if Ganglia service is selected
  869. var gangliaService = this.get('content.services').filterProperty('isSelected', true).findProperty('serviceName', 'GANGLIA');
  870. if (gangliaService) {
  871. var hosts = this.getRegisteredHosts();
  872. if (gangliaService.get('isInstalled')) {
  873. hosts = hosts.filterProperty('isInstalled', false);
  874. }
  875. if (hosts.length) {
  876. this.registerHostsToComponent(hosts.mapProperty('hostName'), 'GANGLIA_MONITOR');
  877. }
  878. }
  879. // add MySQL Server if Hive is selected
  880. var hiveService = this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).findProperty('serviceName', 'HIVE');
  881. if (hiveService) {
  882. var hiveDb = this.get('content.serviceConfigProperties').findProperty('name', 'hive_database');
  883. if(hiveDb.value == "New MySQL Database") {
  884. this.registerHostsToComponent(masterHosts.filterProperty('component', 'HIVE_SERVER').mapProperty('hostName'), 'MYSQL_SERVER');
  885. }
  886. }
  887. },
  888. registerHostsToComponent: function (hostNames, componentName) {
  889. if (hostNames.length == 0) {
  890. return;
  891. }
  892. var queryStr = '';
  893. hostNames.forEach(function (hostName) {
  894. queryStr += 'Hosts/host_name=' + hostName + '|';
  895. });
  896. //slice off last symbol '|'
  897. queryStr = queryStr.slice(0, -1);
  898. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts';
  899. var data = {
  900. "RequestInfo": {
  901. "query": queryStr
  902. },
  903. "Body": {
  904. "host_components": [
  905. {
  906. "HostRoles": {
  907. "component_name": componentName
  908. }
  909. }
  910. ]
  911. }
  912. };
  913. this.ajax({
  914. type: 'POST',
  915. url: url,
  916. data: JSON.stringify(data)
  917. });
  918. },
  919. createConfigurations: function () {
  920. var selectedServices = this.get('selectedServices');
  921. if (this.get('content.controllerName') == 'installerController') {
  922. this.get('serviceConfigTags').pushObject(this.createCoreSiteObj());
  923. this.get('serviceConfigTags').pushObject(this.createHdfsSiteObj());
  924. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HDFS'));
  925. }
  926. var globalSiteObj = this.createGlobalSiteObj();
  927. if (this.get('content.controllerName') == 'addServiceController') {
  928. globalSiteObj.tag = 'version' + (new Date).getTime();
  929. }
  930. this.get('serviceConfigTags').pushObject(globalSiteObj);
  931. if (selectedServices.someProperty('serviceName', 'MAPREDUCE')) {
  932. this.get('serviceConfigTags').pushObject(this.createMrSiteObj());
  933. if (App.supports.capacitySchedulerUi) {
  934. this.get('serviceConfigTags').pushObject(this.createCapacityScheduler());
  935. this.get('serviceConfigTags').pushObject(this.createMapredQueueAcls());
  936. }
  937. this.get('serviceConfigTags').pushObject(this.createLog4jObj('MAPREDUCE'));
  938. }
  939. if (selectedServices.someProperty('serviceName', 'MAPREDUCE2')) {
  940. this.get('serviceConfigTags').pushObject(this.createMrSiteObj());
  941. this.get('serviceConfigTags').pushObject(this.createLog4jObj('MAPREDUCE2'));
  942. }
  943. if (selectedServices.someProperty('serviceName', 'YARN')) {
  944. this.get('serviceConfigTags').pushObject(this.createYarnSiteObj());
  945. this.get('serviceConfigTags').pushObject(this.createCapacityScheduler());
  946. this.get('serviceConfigTags').pushObject(this.createLog4jObj('YARN'));
  947. }
  948. if (selectedServices.someProperty('serviceName', 'HBASE')) {
  949. this.get('serviceConfigTags').pushObject(this.createHbaseSiteObj());
  950. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HBASE'));
  951. }
  952. if (selectedServices.someProperty('serviceName', 'OOZIE')) {
  953. this.get('serviceConfigTags').pushObject(this.createOozieSiteObj('OOZIE'));
  954. this.get('serviceConfigTags').pushObject(this.createLog4jObj('OOZIE'));
  955. }
  956. if (selectedServices.someProperty('serviceName', 'HIVE')) {
  957. this.get('serviceConfigTags').pushObject(this.createHiveSiteObj('HIVE'));
  958. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HIVE'));
  959. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HIVE-EXEC'));
  960. }
  961. if (selectedServices.someProperty('serviceName', 'WEBHCAT')) {
  962. this.get('serviceConfigTags').pushObject(this.createWebHCatSiteObj('WEBHCAT'));
  963. }
  964. if (selectedServices.someProperty('serviceName', 'HUE')) {
  965. this.get('serviceConfigTags').pushObject(this.createHueSiteObj('HUE'));
  966. }
  967. if (selectedServices.someProperty('serviceName', 'PIG')) {
  968. this.get('serviceConfigTags').pushObject(this.createLog4jObj('PIG'));
  969. }
  970. if (selectedServices.someProperty('serviceName', 'FALCON')) {
  971. this.get('serviceConfigTags').pushObject(this.createFalconSiteObj('FALCON'));
  972. }
  973. if (selectedServices.someProperty('serviceName', 'STORM')) {
  974. this.get('serviceConfigTags').pushObject(this.createStormSiteObj());
  975. }
  976. if (selectedServices.someProperty('serviceName', 'TEZ')) {
  977. this.get('serviceConfigTags').pushObject(this.createTezSiteObj());
  978. }
  979. if (selectedServices.someProperty('serviceName', 'ZOOKEEPER')) {
  980. this.get('serviceConfigTags').pushObject(this.createZooCfgObj());
  981. this.get('serviceConfigTags').pushObject(this.createLog4jObj('ZOOKEEPER'));
  982. }
  983. this.applyConfigurationsToCluster();
  984. },
  985. applyConfigurationsToCluster: function() {
  986. var clusterUrl = App.apiPrefix + '/clusters/' + this.get('clusterName');
  987. var configData = [];
  988. this.get('serviceConfigTags').forEach(function (_serviceConfig) {
  989. var Clusters = {
  990. Clusters: {
  991. desired_config: {
  992. type: _serviceConfig.type,
  993. tag: _serviceConfig.tag,
  994. properties: _serviceConfig.properties
  995. }
  996. }
  997. };
  998. configData.pushObject(JSON.stringify(Clusters));
  999. }, this);
  1000. var data = {
  1001. configData: '[' + configData.toString() + ']'
  1002. };
  1003. console.debug("applyConfigurationsToCluster(Step8): Applying to URL", clusterUrl, " Data:", data.configData);
  1004. this.ajax({
  1005. type: 'PUT',
  1006. url: clusterUrl,
  1007. data: data.configData,
  1008. beforeSend: function () {
  1009. console.log("BeforeSend: Updating cluster config");
  1010. }
  1011. });
  1012. },
  1013. createConfigurationGroups: function () {
  1014. var configGroups = this.get('content.configGroups').filterProperty('isDefault', false);
  1015. var clusterName = this.get('clusterName');
  1016. var sendData = [];
  1017. var updateData = [];
  1018. var serviceConfigController = App.router.get('mainServiceInfoConfigsController');
  1019. var timeTag = (new Date).getTime();
  1020. var groupsToDelete = App.router.get(this.get('content.controllerName')).getDBProperty('groupsToDelete');
  1021. if (groupsToDelete && groupsToDelete.length > 0) {
  1022. this.removeInstalledServicesConfigurationGroups(groupsToDelete);
  1023. }
  1024. configGroups.forEach(function (configGroup) {
  1025. var groupConfigs = [];
  1026. var groupData = {
  1027. "cluster_name": clusterName,
  1028. "group_name": configGroup.name,
  1029. "tag": configGroup.service.id,
  1030. "description": configGroup.description,
  1031. "hosts": [],
  1032. "desired_configs": []
  1033. };
  1034. configGroup.hosts.forEach(function (hostName) {
  1035. groupData.hosts.push({"host_name": hostName});
  1036. });
  1037. //wrap properties into Em.Object to make them compatible with buildGroupDesiredConfigs method
  1038. configGroup.properties.forEach(function (property) {
  1039. groupConfigs.push(Em.Object.create(property));
  1040. });
  1041. groupData.desired_configs = serviceConfigController.buildGroupDesiredConfigs.call(serviceConfigController, groupConfigs, timeTag);
  1042. // check for group from installed service
  1043. if (configGroup.isForUpdate === true) {
  1044. // if group is a new one, create it
  1045. if (!configGroup.id) {
  1046. sendData.push({"ConfigGroup": groupData});
  1047. } else {
  1048. // update an existing group
  1049. groupData.id = configGroup.id;
  1050. updateData.push({"ConfigGroup": groupData});
  1051. }
  1052. } else {
  1053. sendData.push({"ConfigGroup": groupData});
  1054. }
  1055. //each group should have unique tag to prevent overriding configs from common sites
  1056. timeTag++;
  1057. }, this);
  1058. if (sendData.length > 0) {
  1059. this.applyConfigurationGroups(sendData);
  1060. }
  1061. if (updateData.length > 0) {
  1062. this.applyInstalledServicesConfigurationGroup(updateData);
  1063. }
  1064. },
  1065. applyConfigurationGroups: function (sendData) {
  1066. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/config_groups';
  1067. this.ajax({
  1068. type: 'POST',
  1069. url: url,
  1070. data: JSON.stringify(sendData)
  1071. });
  1072. },
  1073. applyInstalledServicesConfigurationGroup: function (updateData) {
  1074. updateData.forEach(function(item) {
  1075. App.router.get('mainServiceInfoConfigsController').putConfigGroupChanges(item);
  1076. });
  1077. },
  1078. removeInstalledServicesConfigurationGroups: function(groupsToDelete) {
  1079. groupsToDelete.forEach(function(item) {
  1080. App.config.deleteConfigGroup(Em.Object.create(item));
  1081. });
  1082. },
  1083. createGlobalSiteObj: function () {
  1084. var globalSiteProperties = {};
  1085. var globalSiteObj = this.get('globals');
  1086. var isGLUSTERFSSelected = this.get('selectedServices').someProperty('serviceName', 'GLUSTERFS');
  1087. // screen out the GLUSTERFS-specific global config entries when they are not required
  1088. if (!isGLUSTERFSSelected) {
  1089. globalSiteObj = globalSiteObj.filter(function(_config) {
  1090. return _config.name.indexOf("fs_glusterfs") < 0;
  1091. });
  1092. }
  1093. globalSiteObj.forEach(function (_globalSiteObj) {
  1094. var heapsizeException = ['hadoop_heapsize','yarn_heapsize','nodemanager_heapsize','resourcemanager_heapsize'];
  1095. // do not pass any globals whose name ends with _host or _hosts
  1096. if (_globalSiteObj.isRequiredByAgent !== false) {
  1097. // append "m" to JVM memory options except for hadoop_heapsize
  1098. if (/_heapsize|_newsize|_maxnewsize$/.test(_globalSiteObj.name) && !heapsizeException.contains(_globalSiteObj.name)) {
  1099. globalSiteProperties[_globalSiteObj.name] = _globalSiteObj.value + "m";
  1100. } else {
  1101. globalSiteProperties[_globalSiteObj.name] = App.config.escapeXMLCharacters(_globalSiteObj.value);
  1102. }
  1103. }
  1104. this._recordHostOverrideFromObj(_globalSiteObj, 'global', 'version1', this);
  1105. }, this);
  1106. // we don't expose gmond_user to the user; it needs to be the same as gmetad_user
  1107. globalSiteProperties['gmond_user'] = globalSiteProperties['gmetad_user'];
  1108. return {"type": "global", "tag": "version1", "properties": globalSiteProperties};
  1109. },
  1110. createCoreSiteObj: function () {
  1111. var coreSiteObj = this.get('configs').filterProperty('filename', 'core-site.xml');
  1112. var coreSiteProperties = {};
  1113. // hadoop.proxyuser.oozie.hosts needs to be skipped if oozie is not selected
  1114. var isOozieSelected = this.get('selectedServices').someProperty('serviceName', 'OOZIE');
  1115. var oozieUser = this.get('globals').someProperty('name', 'oozie_user') ? this.get('globals').findProperty('name', 'oozie_user').value : null;
  1116. var isHiveSelected = this.get('selectedServices').someProperty('serviceName', 'HIVE');
  1117. var hiveUser = this.get('globals').someProperty('name', 'hive_user') ? this.get('globals').findProperty('name', 'hive_user').value : null;
  1118. var isHcatSelected = this.get('selectedServices').someProperty('serviceName', 'WEBHCAT');
  1119. var hcatUser = this.get('globals').someProperty('name', 'hcat_user') ? this.get('globals').findProperty('name', 'hcat_user').value : null;
  1120. var isGLUSTERFSSelected = this.get('selectedServices').someProperty('serviceName', 'GLUSTERFS');
  1121. // screen out the GLUSTERFS-specific core-site.xml entries when they are not needed
  1122. if (!isGLUSTERFSSelected) {
  1123. coreSiteObj = coreSiteObj.filter(function(_config) {
  1124. return _config.name.indexOf("fs.glusterfs") < 0;
  1125. });
  1126. }
  1127. coreSiteObj.forEach(function (_coreSiteObj) {
  1128. 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'))) {
  1129. coreSiteProperties[_coreSiteObj.name] = App.config.escapeXMLCharacters(_coreSiteObj.value);
  1130. this._recordHostOverrideFromObj(_coreSiteObj, 'core-site', 'version1', this);
  1131. }
  1132. if (isGLUSTERFSSelected && _coreSiteObj.name == "fs.default.name") {
  1133. 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;
  1134. }
  1135. if (isGLUSTERFSSelected && _coreSiteObj.name == "fs.defaultFS") {
  1136. coreSiteProperties[_coreSiteObj.name] = this.get('globals').someProperty('name', 'glusterfs_defaultFS_name') ? App.config.escapeXMLCharacters(this.get('globals').findProperty('name', 'glusterfs_defaultFS_name').value) : null;
  1137. }
  1138. console.log("STEP*: name of the property is: " + _coreSiteObj.name);
  1139. console.log("STEP8: value of the property is: " + _coreSiteObj.value);
  1140. }, this);
  1141. return {"type": "core-site", "tag": "version1", "properties": coreSiteProperties};
  1142. },
  1143. createHdfsSiteObj: function () {
  1144. var hdfsSiteObj = this.get('configs').filterProperty('filename', 'hdfs-site.xml');
  1145. var hdfsProperties = {};
  1146. hdfsSiteObj.forEach(function (_configProperty) {
  1147. hdfsProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1148. this._recordHostOverrideFromObj(_configProperty, 'hdfs-site', 'version1', this);
  1149. console.log("STEP*: name of the property is: " + _configProperty.name);
  1150. console.log("STEP8: value of the property is: " + _configProperty.value);
  1151. }, this);
  1152. return {"type": "hdfs-site", "tag": "version1", "properties": hdfsProperties };
  1153. },
  1154. createLog4jObj: function (fileName) {
  1155. fileName = fileName.toLowerCase();
  1156. var Log4jObj = this.get('configs').filterProperty('filename', fileName + '-log4j.xml');
  1157. var Log4jProperties = {};
  1158. Log4jObj.forEach(function (_configProperty) {
  1159. Log4jProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1160. this._recordHostOverrideFromObj(_configProperty, fileName + '-log4j', 'version1', this);
  1161. console.log("STEP*: name of the property is: " + _configProperty.name);
  1162. console.log("STEP8: value of the property is: " + _configProperty.value);
  1163. }, this);
  1164. return {"type": fileName + "-log4j", "tag": "version1", "properties": Log4jProperties };
  1165. },
  1166. createHueSiteObj: function () {
  1167. var hueSiteObj = this.get('configs').filterProperty('filename', 'hue-site.xml');
  1168. var hueProperties = {};
  1169. hueSiteObj.forEach(function (_configProperty) {
  1170. hueProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1171. this._recordHostOverrideFromObj(_configProperty, 'hue-site', 'version1', this);
  1172. console.log("STEP*: name of the property is: " + _configProperty.name);
  1173. console.log("STEP8: value of the property is: " + _configProperty.value);
  1174. }, this);
  1175. return {"type": "hue-site", "tag": "version1", "properties": hueProperties };
  1176. },
  1177. createMrSiteObj: function () {
  1178. var configs = this.get('configs').filterProperty('filename', 'mapred-site.xml');
  1179. var mrProperties = {};
  1180. configs.forEach(function (_configProperty) {
  1181. mrProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1182. this._recordHostOverrideFromObj(_configProperty, 'mapred-site', 'version1', this);
  1183. console.log("STEP*: name of the property is: " + _configProperty.name);
  1184. console.log("STEP8: value of the property is: " + _configProperty.value);
  1185. }, this);
  1186. return {type: 'mapred-site', tag: 'version1', properties: mrProperties};
  1187. },
  1188. createYarnSiteObj: function () {
  1189. var configs = this.get('configs').filterProperty('filename', 'yarn-site.xml');
  1190. var mrProperties = {};
  1191. configs.forEach(function (_configProperty) {
  1192. mrProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1193. this._recordHostOverrideFromObj(_configProperty, 'yarn-site', 'version1', this);
  1194. console.log("STEP*: name of the property is: " + _configProperty.name);
  1195. console.log("STEP8: value of the property is: " + _configProperty.value);
  1196. }, this);
  1197. return {type: 'yarn-site', tag: 'version1', properties: mrProperties};
  1198. },
  1199. createCapacityScheduler: function () {
  1200. var configs = this.get('configs').filterProperty('filename', 'capacity-scheduler.xml');
  1201. var csProperties = {};
  1202. configs.forEach(function (_configProperty) {
  1203. csProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1204. this._recordHostOverrideFromObj(_configProperty, 'capacity-scheduler', 'version1', this);
  1205. console.log("STEP*: name of the property is: " + _configProperty.name);
  1206. console.log("STEP8: value of the property is: " + _configProperty.value);
  1207. }, this);
  1208. return {type: 'capacity-scheduler', tag: 'version1', properties: csProperties};
  1209. },
  1210. createMapredQueueAcls: function () {
  1211. var configs = this.get('configs').filterProperty('filename', 'mapred-queue-acls.xml');
  1212. var mqProperties = {};
  1213. configs.forEach(function (_configProperty) {
  1214. mqProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1215. this._recordHostOverrideFromObj(_configProperty, 'mapred-queue-acls', 'version1', this);
  1216. console.log("STEP*: name of the property is: " + _configProperty.name);
  1217. console.log("STEP8: value of the property is: " + _configProperty.value);
  1218. }, this);
  1219. return {type: 'mapred-queue-acls', tag: 'version1', properties: mqProperties};
  1220. },
  1221. createHbaseSiteObj: function () {
  1222. var configs = this.get('configs').filterProperty('filename', 'hbase-site.xml');
  1223. var hbaseProperties = {};
  1224. configs.forEach(function (_configProperty) {
  1225. hbaseProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1226. this._recordHostOverrideFromObj(_configProperty, 'hbase-site', 'version1', this);
  1227. }, this);
  1228. return {type: 'hbase-site', tag: 'version1', properties: hbaseProperties};
  1229. },
  1230. createOozieSiteObj: function (serviceName) {
  1231. var configs = this.get('configs').filterProperty('filename', 'oozie-site.xml');
  1232. var oozieProperties = {};
  1233. configs.forEach(function (_configProperty) {
  1234. oozieProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1235. this._recordHostOverrideFromObj(_configProperty, 'oozie-site', 'version1', this);
  1236. }, this);
  1237. return {type: 'oozie-site', tag: 'version1', properties: oozieProperties};
  1238. },
  1239. createHiveSiteObj: function (serviceName) {
  1240. var configs = this.get('configs').filterProperty('filename', 'hive-site.xml');
  1241. var hiveProperties = {};
  1242. configs.forEach(function (_configProperty) {
  1243. hiveProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1244. this._recordHostOverrideFromObj(_configProperty, 'hive-site', 'version1', this);
  1245. }, this);
  1246. return {type: 'hive-site', tag: 'version1', properties: hiveProperties};
  1247. },
  1248. createWebHCatSiteObj: function (serviceName) {
  1249. var configs = this.get('configs').filterProperty('filename', 'webhcat-site.xml');
  1250. var webHCatProperties = {};
  1251. configs.forEach(function (_configProperty) {
  1252. webHCatProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1253. this._recordHostOverrideFromObj(_configProperty, 'webhcat-site', 'version1', this);
  1254. }, this);
  1255. return {type: 'webhcat-site', tag: 'version1', properties: webHCatProperties};
  1256. },
  1257. createZooCfgObj: function () {
  1258. var configs = this.get('configs').filterProperty('filename', 'zoo.cfg');
  1259. var csProperties = {};
  1260. configs.forEach(function (_configProperty) {
  1261. csProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1262. this._recordHostOverrideFromObj(_configProperty, 'zoo.cfg', 'version1', this);
  1263. }, this);
  1264. return {type: 'zoo.cfg', tag: 'version1', properties: csProperties};
  1265. },
  1266. createStormSiteObj: function () {
  1267. var configs = this.get('configs').filterProperty('filename', 'storm-site.xml');
  1268. var stormProperties = {};
  1269. configs.forEach(function (_configProperty) {
  1270. if (_configProperty.name == "storm.zookeeper.servers") {
  1271. stormProperties[_configProperty.name] = JSON.stringify(_configProperty.value).replace(/"/g, "'");
  1272. } else {
  1273. stormProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1274. }
  1275. this._recordHostOverrideFromObj(_configProperty, 'storm-site', 'version1', this);
  1276. }, this);
  1277. return {type: 'storm-site', tag: 'version1', properties: stormProperties};
  1278. },
  1279. createTezSiteObj: function () {
  1280. var configs = this.get('configs').filterProperty('filename', 'tez-site.xml');
  1281. var tezProperty = {};
  1282. configs.forEach(function (_configProperty) {
  1283. tezProperty[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1284. this._recordHostOverrideFromObj(_configProperty, 'tez-site', 'version1', this);
  1285. }, this);
  1286. return {type: 'tez-site', tag: 'version1', properties: tezProperty};
  1287. },
  1288. createFalconSiteObj: function (s) {
  1289. var configs = this.get('configs').filterProperty('filename', 'oozie-site.xml');
  1290. var falconProperties = {};
  1291. configs.forEach(function (_configProperty) {
  1292. falconProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1293. this._recordHostOverrideFromObj(_configProperty, 'oozie-site', 'version1', this);
  1294. }, this);
  1295. return {type: 'oozie-site', tag: 'version1', properties: falconProperties};
  1296. },
  1297. ajaxQueueFinished: function () {
  1298. //do something
  1299. },
  1300. doNextAjaxCall: function () {
  1301. if (this.get('ajaxBusy')) {
  1302. return;
  1303. }
  1304. var queue = this.get('ajaxQueue');
  1305. if (!queue.length) {
  1306. this.ajaxQueueFinished();
  1307. return;
  1308. }
  1309. var first = queue[0];
  1310. this.set('ajaxQueue', queue.slice(1));
  1311. this.set('ajaxQueueLeft', this.get('ajaxQueue').length);
  1312. this.set('ajaxBusy', true);
  1313. $.ajax(first);
  1314. },
  1315. /**
  1316. * Records all the host overrides per site/tag
  1317. */
  1318. _recordHostOverrideFromObj: function(serviceConfigObj, siteName, tagName, self){
  1319. var overrides = serviceConfigObj.overrides;
  1320. if(overrides && overrides.length>0){
  1321. overrides.forEach(function(override){
  1322. override.hosts.forEach(function(host){
  1323. if(!(host in self.savedHostToOverrideSiteToTagMap)){
  1324. self.savedHostToOverrideSiteToTagMap[host] = {};
  1325. }
  1326. if(!(siteName in self.savedHostToOverrideSiteToTagMap[host])){
  1327. self.savedHostToOverrideSiteToTagMap[host][siteName] = {};
  1328. self.savedHostToOverrideSiteToTagMap[host][siteName].map = {};
  1329. }
  1330. var finalTag = tagName + '_' + host;
  1331. console.log("recordHostOverride(): Saving host override for host="+host+", site="+siteName+", tag="+finalTag+", (key,value)=("+serviceConfigObj.name+","+override.value+")");
  1332. self.savedHostToOverrideSiteToTagMap[host][siteName].tagName = finalTag;
  1333. self.savedHostToOverrideSiteToTagMap[host][siteName].map[serviceConfigObj.name] = override.value;
  1334. });
  1335. });
  1336. }
  1337. },
  1338. /**
  1339. * Creates host level overrides for service configuration.
  1340. *
  1341. */
  1342. createHostOverrideConfigurations: function () {
  1343. var singlePUTHostData = [];
  1344. var savedHostSiteArray = [];
  1345. for ( var host in this.savedHostToOverrideSiteToTagMap) {
  1346. for ( var siteName in this.savedHostToOverrideSiteToTagMap[host]) {
  1347. var tagName = this.savedHostToOverrideSiteToTagMap[host][siteName].tagName;
  1348. var map = this.savedHostToOverrideSiteToTagMap[host][siteName].map;
  1349. savedHostSiteArray.push(host + "///" + siteName);
  1350. singlePUTHostData.push({
  1351. RequestInfo: {
  1352. query: 'Hosts/host_name='+host
  1353. },
  1354. Body: {
  1355. Hosts: {
  1356. desired_config: {
  1357. type: siteName,
  1358. tag: tagName,
  1359. properties: map
  1360. }
  1361. }
  1362. }
  1363. });
  1364. }
  1365. }
  1366. console.log("createHostOverrideConfigSites(): PUTting host-overrides. Data=", singlePUTHostData);
  1367. if(singlePUTHostData.length>0){
  1368. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts';
  1369. this.ajax({
  1370. type: 'PUT',
  1371. url: url,
  1372. data: JSON.stringify(singlePUTHostData),
  1373. dataType: 'text',
  1374. beforeSend: function () {
  1375. console.log("createHostOverrideConfigSites() PUT override=", singlePUTHostData);
  1376. }
  1377. });
  1378. }
  1379. },
  1380. /**
  1381. * We need to do a lot of ajax calls async in special order. To do this,
  1382. * generate array of ajax objects and then send requests step by step. All
  1383. * ajax objects are stored in <code>ajaxQueue</code>
  1384. *
  1385. * @param params
  1386. */
  1387. ajax: function (params) {
  1388. if (App.testMode) return;
  1389. var self = this;
  1390. params = jQuery.extend({
  1391. async: true,
  1392. dataType: 'text',
  1393. statusCode: require('data/statusCodes'),
  1394. timeout: App.timeout,
  1395. error: function (request, ajaxOptions, error) {
  1396. console.log('Step8: In Error ');
  1397. // console.log('Step8: Error message is: ' + request.responseText);
  1398. },
  1399. success: function (data) {
  1400. console.log("TRACE: STep8 -> In success function");
  1401. }
  1402. }, params);
  1403. var success = params.success;
  1404. var error = params.error;
  1405. params.success = function () {
  1406. if (success) {
  1407. success();
  1408. }
  1409. self.set('ajaxBusy', false);
  1410. self.doNextAjaxCall();
  1411. };
  1412. params.error = function (xhr, status, error) {
  1413. var responseText = JSON.parse(xhr.responseText);
  1414. var controller = App.router.get(App.clusterStatus.wizardControllerName);
  1415. controller.registerErrPopup(Em.I18n.t('common.error'), responseText.message);
  1416. self.set('hasErrorOccurred', true);
  1417. // an error will break the ajax call chain and allow submission again
  1418. self.set('isSubmitDisabled', false);
  1419. self.set('isBackBtnDisabled', false);
  1420. App.router.get(self.get('content.controllerName')).setStepsEnable();
  1421. self.get('ajaxQueue').clear();
  1422. self.set('ajaxBusy', false);
  1423. };
  1424. this.get('ajaxQueue').pushObject(params);
  1425. }
  1426. });