configs.js 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629
  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. require('controllers/wizard/slave_component_groups_controller');
  20. App.MainServiceInfoConfigsController = Em.Controller.extend({
  21. name: 'mainServiceInfoConfigsController',
  22. dataIsLoaded: false,
  23. stepConfigs: [], //contains all field properties that are viewed in this service
  24. selectedService: null,
  25. serviceConfigTags: null,
  26. globalConfigs: [],
  27. uiConfigs: [],
  28. customConfig: [],
  29. isApplyingChanges: false,
  30. serviceConfigs: function(){
  31. return App.config.get('preDefinedServiceConfigs');
  32. }.property('App.config.preDefinedServiceConfigs'),
  33. configMapping: function(){
  34. return App.config.get('configMapping');
  35. }.property('App.config.configMapping'),
  36. customConfigs: require('data/custom_configs'),
  37. configs: function() {
  38. return App.config.get('preDefinedConfigProperties');
  39. }.property('App.config.preDefinedConfigProperties'),
  40. secureConfigs: require('data/secure_mapping'),
  41. /**
  42. * During page load time, we get the host overrides from the server.
  43. * The current host -> site:tag map is stored below. This will be
  44. * useful during save, so that removals can also be determined.
  45. *
  46. * Example:
  47. * {
  48. * 'hostname1':{
  49. * 'global': 'version1',
  50. * 'core-site': 'version1',
  51. * 'hdfs-site', 'tag3187261938'
  52. * }
  53. * }
  54. *
  55. * @see savedHostToOverrideSiteToTagMap
  56. */
  57. loadedHostToOverrideSiteToTagMap: {},
  58. /**
  59. * During page load time the cluster level site to tag
  60. * mapping is stored here.
  61. *
  62. * Example:
  63. * {
  64. * 'global': 'version1',
  65. * 'hdfs-site': 'version1',
  66. * 'core-site': 'version1'
  67. * }
  68. */
  69. loadedClusterSiteToTagMap: {},
  70. /**
  71. * During page save time, we set the host overrides to the server.
  72. * The new host -> site:tag map is stored below. This will be
  73. * useful during save, to update the host's host components. Also,
  74. * it will be useful in deletion of overrides.
  75. *
  76. * Example:
  77. * {
  78. * 'hostname1': {
  79. * 'global': {
  80. * 'tagName': 'tag3187261938_hostname1',
  81. * 'map': {
  82. * 'hadoop_heapsize': '2048m'
  83. * }
  84. * }
  85. * }
  86. * }
  87. *
  88. * @see loadedHostToOverrideSiteToTagMap
  89. */
  90. savedHostToOverrideSiteToTagMap: {},
  91. /**
  92. * Holds the actual base service-config server data uploaded.
  93. * This is used by the host-override mechanism to update host
  94. * specific values.
  95. */
  96. savedSiteNameToServerServiceConfigDataMap: {},
  97. isSubmitDisabled: function () {
  98. return (!(this.stepConfigs.everyProperty('errorCount', 0)) || this.get('isApplyingChanges'));
  99. }.property('stepConfigs.@each.errorCount', 'isApplyingChanges'),
  100. slaveComponentGroups: null,
  101. /**
  102. * Filter text will be located here
  103. */
  104. filter: '',
  105. /**
  106. * Dropdown menu items in filter compbobox
  107. */
  108. filterColumns: function(){
  109. var result = [];
  110. for(var i = 1; i<4; i++){
  111. result.push(Ember.Object.create({
  112. name: this.t('common.combobox.dropdown.' + i),
  113. selected: false
  114. }));
  115. }
  116. return result;
  117. }.property(),
  118. /**
  119. * clear and set properties to default value
  120. */
  121. clearStep: function () {
  122. this.set('dataIsLoaded', false);
  123. this.set('filter', '');
  124. this.get('filterColumns').setEach('selected', false);
  125. this.get('stepConfigs').clear();
  126. this.get('globalConfigs').clear();
  127. this.get('uiConfigs').clear();
  128. this.get('customConfig').clear();
  129. this.set('loadedHostToOverrideSiteToTagMap', {});
  130. this.set('savedHostToOverrideSiteToTagMap', {});
  131. this.set('savedSiteNameToServerServiceConfigDataMap', {});
  132. if (this.get('serviceConfigTags')) {
  133. this.set('serviceConfigTags', null);
  134. }
  135. },
  136. serviceConfigProperties: function () {
  137. return App.db.getServiceConfigProperties();
  138. }.property('content'),
  139. /**
  140. * On load function
  141. */
  142. loadStep: function () {
  143. console.log("TRACE: Loading configure for service");
  144. this.clearStep();
  145. this.loadServiceConfigs();
  146. },
  147. /**
  148. * Loads the actual configuration of all host components.
  149. * This helps in determining which services need a restart, and also
  150. * in showing which properties are actually applied or not.
  151. * This method also compares the actual_configs with the desired_configs
  152. * and builds a diff structure.
  153. *
  154. * Internall it calculates an array of host-components which need restart.
  155. * Example:
  156. * [
  157. * {
  158. * componentName: 'DATANODE',
  159. * serviceName: 'HDFS',
  160. * host: 'host.name',
  161. * type: 'core-site',
  162. * desiredConfigTags: {tag:'version1'},
  163. * actualConfigTags: {tag:'version4'. host_override:'version2'}
  164. * },
  165. * ...
  166. * ]
  167. *
  168. * From there it return the following restart-data for this service.
  169. * It represents the hosts, whose components need restart, and the
  170. * properties which require restart.
  171. *
  172. * {
  173. * hostAndHostComponents: {
  174. * 'hostname1': {
  175. * 'DATANODE': {
  176. * 'property1': 'value1',
  177. * 'property2': 'value2'
  178. * },
  179. * 'TASKTRACKER': {
  180. * 'prop1': 'val1'
  181. * }
  182. * },
  183. * 'hostname6': {
  184. * 'ZOOKEEPER': {
  185. * 'property1': 'value3'
  186. * }
  187. * }
  188. * },
  189. * propertyToHostAndComponent: {
  190. * 'property1': {
  191. * 'hostname1': ['DATANODE'],
  192. * 'hostname6': ['ZOOKEEPER']
  193. * },
  194. * 'property2': {
  195. * 'hostname1': ['DATANODE']
  196. * },
  197. * 'prop1': {
  198. * 'hostname1': ['TASKTRACKER']
  199. * }
  200. * }
  201. * }
  202. */
  203. loadActualConfigsAndCalculateRestarts: function () {
  204. var currentService = this.get('content.serviceName');
  205. var restartData = {
  206. hostAndHostComponents: {},
  207. propertyToHostAndComponent: {}
  208. };
  209. var self = this;
  210. var actualConfigsUrl = this.getUrl('/data/services/host_component_actual_configs.json', '/services?fields=components/host_components/HostRoles/actual_configs');
  211. $.ajax({
  212. type: 'GET',
  213. url: actualConfigsUrl,
  214. async: false,
  215. timeout: 10000,
  216. dataType: 'json',
  217. success: function (data) {
  218. var diffHostComponents = [];
  219. console.debug("loadActualConfigs(" + actualConfigsUrl + "): Data=", data);
  220. var configsToDownload = [];
  221. data.items.forEach(function (service) {
  222. // For current service, do any of the host_components differ in
  223. // configuration?
  224. if (currentService === service.ServiceInfo.service_name) {
  225. service.components.forEach(function (serviceComponent) {
  226. serviceComponent.host_components.forEach(function (hostComponent) {
  227. if (hostComponent.HostRoles.actual_configs) {
  228. for ( var site in hostComponent.HostRoles.actual_configs) {
  229. var actualConfigsTags = hostComponent.HostRoles.actual_configs[site];
  230. var desiredConfigTags = self.getDesiredConfigTag(site, hostComponent.HostRoles.host_name);
  231. if (desiredConfigTags.tag !== actualConfigsTags.tag ||
  232. (desiredConfigTags.host_override != null &&
  233. actualConfigsTags.host_override != null &&
  234. desiredConfigTags.host_override !== actualConfigsTags.host_override)) {
  235. // Restart may be necessary for this host-component
  236. diffHostComponents.push({
  237. componentName: hostComponent.HostRoles.component_name,
  238. serviceName: serviceComponent.ServiceComponentInfo.service_name,
  239. host: hostComponent.HostRoles.host_name,
  240. type: site,
  241. desiredConfigTags: desiredConfigTags,
  242. actualConfigTags: actualConfigsTags
  243. });
  244. self.addConfigDownloadParam(site, actualConfigsTags.tag, configsToDownload);
  245. self.addConfigDownloadParam(site, actualConfigsTags.host_override, configsToDownload);
  246. self.addConfigDownloadParam(site, desiredConfigTags.tag, configsToDownload);
  247. self.addConfigDownloadParam(site, desiredConfigTags.host_override, configsToDownload);
  248. }
  249. }
  250. }
  251. });
  252. });
  253. }
  254. });
  255. if (configsToDownload.length > 0) {
  256. var url = self.getUrl('/data/configurations/cluster_level_actual_configs.json?' + configsToDownload.join('|'), '/configurations?' + configsToDownload.join('|'));
  257. $.ajax({
  258. type: 'GET',
  259. url: url,
  260. async: false,
  261. timeout: 10000,
  262. dataType: 'json',
  263. success: function (data) {
  264. console.log("configsToDownload(): In success for ", url);
  265. if (data.items) {
  266. data.items.forEach(function (item) {
  267. App.config.loadedConfigurationsCache[item.type + "_" + item.tag] = item.properties;
  268. });
  269. }
  270. },
  271. error: function (request, ajaxOptions, error) {
  272. console.log("TRACE: In error function for the configsToDownload call");
  273. console.log("TRACE: value of the url is: " + url);
  274. console.log("TRACE: error code status is: " + request.status);
  275. },
  276. statusCode: require('data/statusCodes')
  277. });
  278. }
  279. // Now all the configurations are loaded.
  280. // Find the diff in properties
  281. if (diffHostComponents.length > 0) {
  282. diffHostComponents.forEach(function (diffHostComponent) {
  283. var actualConfigs = App.config.loadedConfigurationsCache[diffHostComponent.type + "_" + diffHostComponent.actualConfigTags.tag];
  284. var desiredConfigs = App.config.loadedConfigurationsCache[diffHostComponent.type + "_" + diffHostComponent.desiredConfigTags.tag];
  285. var diffs = self.getConfigDifferences(actualConfigs, desiredConfigs);
  286. if (!jQuery.isEmptyObject(diffs)) {
  287. var skip = false;
  288. if (diffHostComponent.type == 'global') {
  289. if(!App.config.isServiceEffectedByGlobalChange(
  290. diffHostComponent.serviceName,
  291. diffHostComponent.desiredConfigTags.tag,
  292. diffHostComponent.actualConfigTags.tag)){
  293. skip = true;
  294. }
  295. }
  296. if(!skip){
  297. // Populate restartData.hostAndHostComponents
  298. if (!(diffHostComponent.host in restartData.hostAndHostComponents)) {
  299. restartData.hostAndHostComponents[diffHostComponent.host] = {};
  300. }
  301. if (!(diffHostComponent.componentName in restartData.hostAndHostComponents[diffHostComponent.host])) {
  302. restartData.hostAndHostComponents[diffHostComponent.host][diffHostComponent.componentName] = {};
  303. }
  304. jQuery.extend(restartData.hostAndHostComponents[diffHostComponent.host][diffHostComponent.componentName], diffs);
  305. // Populate restartData.propertyToHostAndComponent
  306. for ( var diff in diffs) {
  307. if (!(diff in restartData.propertyToHostAndComponent)) {
  308. restartData.propertyToHostAndComponent[diff] = {};
  309. }
  310. if (!(diffHostComponent.host in restartData.propertyToHostAndComponent[diff])) {
  311. restartData.propertyToHostAndComponent[diff][diffHostComponent.host] = [];
  312. }
  313. if (!(restartData.propertyToHostAndComponent[diff][diffHostComponent.host].contains(diffHostComponent.componentName))) {
  314. restartData.propertyToHostAndComponent[diff][diffHostComponent.host].push(diffHostComponent.componentName);
  315. }
  316. }
  317. }
  318. }
  319. });
  320. }
  321. console.log("loadActualConfigs(): Finished loading. Restart host components = ", diffHostComponents);
  322. },
  323. error: function (request, ajaxOptions, error) {
  324. console.log("loadActualConfigs(): URL:" + actualConfigsUrl + ". Status:", request.status, ", Error:", error);
  325. },
  326. statusCode: require('data/statusCodes')
  327. });
  328. console.log("loadActualConfigsAndCalculateRestarts(): Restart data = ", restartData);
  329. return restartData;
  330. },
  331. /**
  332. * Determines the differences between desired and actual configs and returns
  333. * them as an object. The key is the property, and value is actual_config.
  334. */
  335. getConfigDifferences: function (actualConfigs, desiredConfigs) {
  336. var differences = {};
  337. if (actualConfigs != null && desiredConfigs != null) {
  338. for(var desiredProp in desiredConfigs){
  339. if(desiredConfigs[desiredProp] !== actualConfigs[desiredProp]){
  340. differences[desiredProp] = actualConfigs[desiredProp];
  341. }
  342. }
  343. }
  344. return differences;
  345. },
  346. addConfigDownloadParam: function(site, tag, configsToDownload){
  347. if(tag!=null && !(site+"_"+tag in App.config.loadedConfigurationsCache)){
  348. var configParam = "(type="+site+"&tag="+tag+")";
  349. if(!configsToDownload.contains(configParam)){
  350. configsToDownload.push(configParam);
  351. }
  352. }
  353. },
  354. getDesiredConfigTag: function(site, hostName){
  355. var tag = {tag: this.loadedClusterSiteToTagMap[site], host_override: null};
  356. if(hostName in this.loadedHostToOverrideSiteToTagMap){
  357. var map = this.loadedHostToOverrideSiteToTagMap[hostName];
  358. if(site in map){
  359. tag.host_overrides = map[site];
  360. }
  361. }
  362. return tag;
  363. },
  364. /**
  365. * Loads service configurations
  366. */
  367. loadServiceConfigs: function () {
  368. App.ajax.send({
  369. name: 'config.tags',
  370. sender: this,
  371. data: {
  372. serviceName: this.get('content.serviceName'),
  373. serviceConfigsDef: this.get('serviceConfigs').findProperty('serviceName', this.get('content.serviceName'))
  374. },
  375. success: 'loadServiceTagsSuccess'
  376. });
  377. },
  378. loadServiceTagsSuccess: function(data, opt, params){
  379. var serviceConfigsDef = params.serviceConfigsDef;
  380. var serviceName = this.get('content.serviceName');
  381. console.debug("loadServiceConfigs(): data=", data);
  382. this.loadedClusterSiteToTagMap = {};
  383. //STEP 1: handle tags from JSON data
  384. for ( var site in data.Clusters.desired_configs) {
  385. if (serviceConfigsDef.sites.indexOf(site) > -1) {
  386. this.loadedClusterSiteToTagMap[site] = data.Clusters.desired_configs[site]['tag'];
  387. var overrides = data.Clusters.desired_configs[site].host_overrides;
  388. if (overrides) {
  389. overrides.forEach(function (override) {
  390. var hostname = override.host_name;
  391. var tag = override.tag;
  392. if(!this.loadedHostToOverrideSiteToTagMap[hostname]){
  393. this.loadedHostToOverrideSiteToTagMap[hostname] = {};
  394. }
  395. this.loadedHostToOverrideSiteToTagMap[hostname][site] = tag;
  396. }, this);
  397. }
  398. }
  399. }
  400. //STEP 2: Create an array of objects defining tag names to be polled and new tag names to be set after submit
  401. this.setServiceConfigTags(this.loadedClusterSiteToTagMap);
  402. //STEP 3: Load advanced configs from server
  403. var advancedConfigs = App.config.loadAdvancedConfig(serviceName) || [];
  404. //STEP 4: Load on-site config by service from server
  405. var configGroups = App.config.loadConfigsByTags(this.get('serviceConfigTags'));
  406. //STEP 5: Merge global and on-site configs with pre-defined
  407. var configSet = App.config.mergePreDefinedWithLoaded(configGroups, advancedConfigs, this.get('serviceConfigTags'), serviceName);
  408. //var serviceConfigs = this.getSitesConfigProperties(advancedConfigs);
  409. var configs = configSet.configs;
  410. //put global configs into globalConfigs to save them separately
  411. this.set('globalConfigs', configSet.globalConfigs);
  412. //STEP 6: add advanced configs
  413. //App.config.addAdvancedConfigs(configs, advancedConfigs, serviceName);
  414. //STEP 7: add custom configs
  415. App.config.addCustomConfigs(configs);
  416. //STEP 8: add configs as names of host components
  417. this.addHostNamesToGlobalConfig();
  418. var allConfigs = this.get('globalConfigs').concat(configs);
  419. //this.loadServiceConfigHostsOverrides(serviceConfigs, this.loadedHostToOverrideSiteToTagMap);
  420. //STEP 9: Load and add host override configs
  421. App.config.loadServiceConfigHostsOverrides(allConfigs, this.loadedHostToOverrideSiteToTagMap);
  422. var restartData = this.loadActualConfigsAndCalculateRestarts();
  423. //STEP 10: creation of serviceConfig object which contains configs for current service
  424. var serviceConfig = App.config.createServiceConfig(serviceName);
  425. this.checkForRestart(serviceConfig, restartData);
  426. if (serviceName || serviceConfig.serviceName === 'MISC') {
  427. //STEP 11: render configs and wrap each in ServiceConfigProperty object
  428. this.loadComponentConfigs(allConfigs, serviceConfig, restartData);
  429. this.get('stepConfigs').pushObject(serviceConfig);
  430. }
  431. this.set('selectedService', this.get('stepConfigs').objectAt(0));
  432. this.checkForSecureConfig( this.get('selectedService'));
  433. this.set('dataIsLoaded', true);
  434. },
  435. /**
  436. * Changes format from Object to Array
  437. *
  438. * {
  439. * 'core-site': 'version1',
  440. * 'hdfs-site': 'version1',
  441. * 'global': 'version2',
  442. * ...
  443. * }
  444. *
  445. * to
  446. *
  447. * [
  448. * {
  449. * siteName: 'core-site',
  450. * tagName: 'version1',
  451. * newTageName: null
  452. * },
  453. * ...
  454. * ]
  455. *
  456. * set tagnames for configuration of the *-site.xml
  457. */
  458. setServiceConfigTags: function (desiredConfigsSiteTags) {
  459. console.debug("setServiceConfigTags(): Trying to set ", desiredConfigsSiteTags);
  460. var newServiceConfigTags = [];
  461. for (var index in desiredConfigsSiteTags) {
  462. newServiceConfigTags.pushObject({
  463. siteName: index,
  464. tagName: desiredConfigsSiteTags[index],
  465. newTagName: null
  466. }, this);
  467. }
  468. console.debug("setServiceConfigTags(): Setting 'serviceConfigTags' to ", newServiceConfigTags);
  469. this.set('serviceConfigTags', newServiceConfigTags);
  470. },
  471. /**
  472. * check whether host component must be restarted
  473. * @param serviceConfig
  474. * @param restartData
  475. */
  476. checkForRestart: function(serviceConfig, restartData){
  477. var hostsCount = 0;
  478. var hostComponentCount = 0;
  479. var restartHosts = Ember.A([]);
  480. if(restartData != null && restartData.hostAndHostComponents != null && !jQuery.isEmptyObject(restartData.hostAndHostComponents)){
  481. serviceConfig.set('restartRequired', true);
  482. for(var host in restartData.hostAndHostComponents) {
  483. hostsCount++;
  484. var componentsArray = Ember.A([]);
  485. for(var component in restartData.hostAndHostComponents[host]){
  486. componentsArray.push(Ember.Object.create({name: App.format.role(component)}));
  487. hostComponentCount++;
  488. }
  489. var hostObj = App.Host.find(host);
  490. restartHosts.push(Ember.Object.create({hostData: hostObj, components: componentsArray}))
  491. }
  492. serviceConfig.set('restartRequiredHostsAndComponents', restartHosts);
  493. serviceConfig.set('restartRequiredMessage', 'Service needs '+hostComponentCount+' components on ' + hostsCount +' hosts to be restarted.')
  494. }
  495. },
  496. /**
  497. * check whether the config property is a security related knob
  498. * @param serviceConfig
  499. */
  500. checkForSecureConfig: function(serviceConfig) {
  501. serviceConfig.get('configs').forEach(function(_config){
  502. this.get('secureConfigs').forEach(function(_secureConfig){
  503. if(_config.get('name')=== _secureConfig.name) {
  504. _config.set('isSecureConfig',true);
  505. }
  506. },this)
  507. },this)
  508. },
  509. /**
  510. * Load child components to service config object
  511. * @param configs
  512. * @param componentConfig
  513. * @param restartData
  514. */
  515. loadComponentConfigs: function (configs, componentConfig, restartData) {
  516. configs.forEach(function (_serviceConfigProperty) {
  517. console.log("config", _serviceConfigProperty);
  518. if (!_serviceConfigProperty) return;
  519. var overrides = _serviceConfigProperty.overrides;
  520. // we will populate the override properties below
  521. _serviceConfigProperty.overrides = null;
  522. if (_serviceConfigProperty.isOverridable === undefined) {
  523. _serviceConfigProperty.isOverridable = true;
  524. }
  525. var serviceConfigProperty = App.ServiceConfigProperty.create(_serviceConfigProperty);
  526. var propertyName = serviceConfigProperty.get('name');
  527. if (restartData != null && propertyName in restartData.propertyToHostAndComponent) {
  528. serviceConfigProperty.set('isRestartRequired', true);
  529. var message = '<ul>';
  530. for(var host in restartData.propertyToHostAndComponent[propertyName]){
  531. var appHost = App.Host.find(host);
  532. message += "<li>"+appHost.get('publicHostName');
  533. message += "<ul>";
  534. restartData.propertyToHostAndComponent[propertyName][host].forEach(function(comp){
  535. message += "<li>"+App.format.role(comp)+"</li>"
  536. });
  537. message += "</ul></li>";
  538. }
  539. message += "</ul>";
  540. serviceConfigProperty.set('restartRequiredMessage', message);
  541. }
  542. if (serviceConfigProperty.get('serviceName') === this.get('content.serviceName')) {
  543. // serviceConfigProperty.serviceConfig = componentConfig;
  544. if (App.get('isAdmin')) {
  545. serviceConfigProperty.set('isEditable', serviceConfigProperty.get('isReconfigurable'));
  546. } else {
  547. serviceConfigProperty.set('isEditable', false);
  548. }
  549. console.log("config result", serviceConfigProperty);
  550. } else {
  551. serviceConfigProperty.set('isVisible', false);
  552. }
  553. if (overrides != null) {
  554. for(var overridenValue in overrides){
  555. var hostsArray = overrides[overridenValue];
  556. var newSCP = App.ServiceConfigProperty.create(_serviceConfigProperty);
  557. newSCP.set('value', overridenValue);
  558. newSCP.set('isOriginalSCP', false); // indicated this is overridden value,
  559. newSCP.set('parentSCP', serviceConfigProperty);
  560. newSCP.set('selectedHostOptions', Ember.A(hostsArray));
  561. var parentOverridesArray = serviceConfigProperty.get('overrides');
  562. if(parentOverridesArray == null){
  563. parentOverridesArray = Ember.A([]);
  564. serviceConfigProperty.set('overrides', parentOverridesArray);
  565. }
  566. parentOverridesArray.pushObject(newSCP);
  567. console.debug("createOverrideProperty(): Added:", newSCP, " to main-property:", serviceConfigProperty)
  568. }
  569. }
  570. componentConfig.configs.pushObject(serviceConfigProperty);
  571. serviceConfigProperty.validate();
  572. }, this);
  573. },
  574. /**
  575. * Determines which host components are running on each host.
  576. * @param status 'running' or 'unknown'
  577. * @return Returned in the following format:
  578. * {
  579. * runningHosts: {
  580. * 'hostname1': 'NameNode, DataNode, JobTracker',
  581. * 'hostname2': 'DataNode',
  582. * },
  583. * runningComponentCount: 5
  584. * }
  585. */
  586. getHostComponentsByStatus: function (services, status) {
  587. var hosts = [];
  588. var componentCount = 0;
  589. var hostToIndexMap = {};
  590. services.forEach(function (service) {
  591. var hostComponents = (status == App.HostComponentStatus.started) ? service.get('runningHostComponents') : service.get('unknownHostComponents');
  592. if (hostComponents != null) {
  593. hostComponents.forEach(function (hc) {
  594. var hostName = hc.get('host.publicHostName');
  595. var componentName = hc.get('displayName');
  596. componentCount++;
  597. if (!(hostName in hostToIndexMap)) {
  598. hosts.push({
  599. name: hostName,
  600. components: ""
  601. });
  602. hostToIndexMap[hostName] = hosts.length - 1;
  603. }
  604. var hostObj = hosts[hostToIndexMap[hostName]];
  605. if (hostObj.components.length > 0)
  606. hostObj.components += ", " + componentName;
  607. else
  608. hostObj.components += componentName;
  609. });
  610. hosts.sort(function (a, b) {
  611. return a.name.localeCompare(b.name);
  612. });
  613. }
  614. });
  615. return {
  616. hosts: hosts,
  617. componentCount: componentCount
  618. };
  619. },
  620. /**
  621. * open popup with appropriate message
  622. */
  623. restartServicePopup: function (event) {
  624. if(this.get("isSubmitDisabled")){
  625. return;
  626. }
  627. var header;
  628. var message;
  629. var messageClass;
  630. var hasUnknown = false;
  631. var value;
  632. var flag = false;
  633. var runningHosts = null;
  634. var runningComponentCount = 0;
  635. var unknownHosts = null;
  636. var unknownComponentCount = 0;
  637. var dfd = $.Deferred();
  638. var self = this;
  639. var serviceName = this.get('content.serviceName');
  640. var displayName = this.get('content.displayName');
  641. if (App.supports.hostOverrides ||
  642. (serviceName !== 'HDFS' && this.get('content.isStopped') === true) ||
  643. ((serviceName === 'HDFS') && this.get('content.isStopped') === true && (!App.Service.find().someProperty('id', 'MAPREDUCE') || App.Service.find('MAPREDUCE').get('isStopped')))) {
  644. // warn the user if any service directories are being changed
  645. var dirChanged = false;
  646. if (serviceName === 'HDFS') {
  647. var hdfsConfigs = self.get('stepConfigs').findProperty('serviceName', 'HDFS').get('configs');
  648. if (
  649. hdfsConfigs.findProperty('name', 'dfs_name_dir').get('isNotDefaultValue') ||
  650. hdfsConfigs.findProperty('name', 'fs_checkpoint_dir').get('isNotDefaultValue') ||
  651. hdfsConfigs.findProperty('name', 'dfs_data_dir').get('isNotDefaultValue')
  652. ) {
  653. dirChanged = true;
  654. }
  655. } else if (serviceName === 'MAPREDUCE') {
  656. var mapredConfigs = self.get('stepConfigs').findProperty('serviceName', 'MAPREDUCE').get('configs');
  657. if (
  658. mapredConfigs.findProperty('name', 'mapred_local_dir').get('isNotDefaultValue') ||
  659. mapredConfigs.findProperty('name', 'mapred_system_dir').get('isNotDefaultValue')
  660. ) {
  661. dirChanged = true;
  662. }
  663. }
  664. if (dirChanged) {
  665. App.showConfirmationPopup(function() {
  666. dfd.resolve();
  667. }, Em.I18n.t('services.service.config.confirmDirectoryChange').format(displayName));
  668. } else {
  669. dfd.resolve();
  670. }
  671. dfd.done(function() {
  672. var result = self.saveServiceConfigProperties();
  673. App.router.get('clusterController').updateClusterData();
  674. flag = result.flag;
  675. if (result.flag === true) {
  676. header = Em.I18n.t('services.service.config.saved');
  677. message = Em.I18n.t('services.service.config.saved.message');
  678. messageClass = 'alert alert-success';
  679. // warn the user if any of the components are in UNKNOWN state
  680. var uhc;
  681. if (self.get('content.serviceName') !== 'HDFS' || (self.get('content.serviceName') === 'HDFS' && !App.Service.find().someProperty('id', 'MAPREDUCE'))) {
  682. uhc = self.getHostComponentsByStatus([self.get('content')], App.HostComponentStatus.unknown);
  683. } else {
  684. uhc = self.getHostComponentsByStatus([self.get('content'), App.Service.find('MAPREDUCE')], App.HostComponentStatus.unknown);
  685. }
  686. unknownHosts = uhc.hosts;
  687. unknownComponentCount = uhc.componentCount;
  688. } else {
  689. header = Em.I18n.t('common.failure');
  690. message = result.message;
  691. messageClass = 'alert alert-error';
  692. value = result.value;
  693. }
  694. });
  695. } else {
  696. var rhc;
  697. if (this.get('content.serviceName') !== 'HDFS' || (this.get('content.serviceName') === 'HDFS' && !App.Service.find().someProperty('id', 'MAPREDUCE'))) {
  698. rhc = this.getHostComponentsByStatus([this.get('content')], App.HostComponentStatus.started);
  699. header = Em.I18n.t('services.service.config.notSaved');
  700. message = Em.I18n.t('services.service.config.msgServiceStop');
  701. } else {
  702. rhc = this.getHostComponentsByStatus([this.get('content'), App.Service.find('MAPREDUCE')], App.HostComponentStatus.started);
  703. header = Em.I18n.t('services.service.config.notSaved');
  704. message = Em.I18n.t('services.service.config.msgHDFSMapRServiceStop');
  705. }
  706. messageClass = 'alert alert-error';
  707. runningHosts = rhc.hosts;
  708. runningComponentCount = rhc.componentCount;
  709. dfd.resolve();
  710. }
  711. dfd.done(function () {
  712. App.ModalPopup.show({
  713. header: header,
  714. primary: Em.I18n.t('ok'),
  715. secondary: null,
  716. onPrimary: function () {
  717. this.hide();
  718. if (flag) {
  719. self.loadStep();
  720. }
  721. },
  722. bodyClass: Ember.View.extend({
  723. flag: flag,
  724. message: message,
  725. messageClass: messageClass,
  726. runningHosts: runningHosts,
  727. runningComponentCount: runningComponentCount,
  728. unknownHosts: unknownHosts,
  729. unknownComponentCount: unknownComponentCount,
  730. siteProperties: value,
  731. getDisplayMessage: function () {
  732. var displayMsg = [];
  733. var siteProperties = this.get('siteProperties');
  734. if (siteProperties) {
  735. siteProperties.forEach(function (_siteProperty) {
  736. var displayProperty = _siteProperty.siteProperty;
  737. var displayNames = _siteProperty.displayNames;
  738. /////////
  739. if (displayNames && displayNames.length) {
  740. if (displayNames.length === 1) {
  741. displayMsg.push(displayProperty + Em.I18n.t('as') + displayNames[0]);
  742. } else {
  743. var name;
  744. displayNames.forEach(function (_name, index) {
  745. if (index === 0) {
  746. name = _name;
  747. } else if (index === siteProperties.length - 1) {
  748. name = name + Em.I18n.t('and') + _name;
  749. } else {
  750. name = name + ', ' + _name;
  751. }
  752. }, this);
  753. displayMsg.push(displayProperty + Em.I18n.t('as') + name);
  754. }
  755. } else {
  756. displayMsg.push(displayProperty);
  757. }
  758. }, this);
  759. }
  760. return displayMsg;
  761. }.property('siteProperties'),
  762. runningHostsMessage: function () {
  763. return Em.I18n.t('services.service.config.stopService.runningHostComponents').format(this.get('runningComponentCount'), this.get('runningHosts.length'));
  764. }.property('runningComponentCount', 'runningHosts.length'),
  765. unknownHostsMessage: function () {
  766. return Em.I18n.t('services.service.config.stopService.unknownHostComponents').format(this.get('unknownComponentCount'), this.get('unknownHosts.length'));
  767. }.property('unknownComponentCount', 'unknownHosts.length'),
  768. templateName: require('templates/main/service/info/configs_save_popup')
  769. })
  770. })
  771. });
  772. },
  773. /**
  774. * Save config properties
  775. */
  776. saveServiceConfigProperties: function () {
  777. var result = {
  778. flag: false,
  779. message: null,
  780. value: null
  781. };
  782. this.savedHostToOverrideSiteToTagMap = {};
  783. var configs = this.get('stepConfigs').findProperty('serviceName', this.get('content.serviceName')).get('configs');
  784. this.saveGlobalConfigs(configs);
  785. this.saveSiteConfigs(configs);
  786. /**
  787. * First we put cluster configurations, which automatically creates /configurations
  788. * resources. Next we update host level overrides.
  789. */
  790. result.flag = this.doPUTClusterConfigurations();
  791. if (!result.flag) {
  792. result.message = Em.I18n.t('services.service.config.failSaveConfig');
  793. }else{
  794. result.flag = result.flag && this.doPUTHostOverridesConfigurationSites();
  795. if (!result.flag) {
  796. result.message = Em.I18n.t('services.service.config.failSaveConfigHostExceptions');
  797. }
  798. }
  799. console.log("The result from applyCreatdConfToService is: " + result);
  800. return result;
  801. },
  802. /**
  803. * save new or change exist configs in global configs
  804. * @param configs
  805. */
  806. saveGlobalConfigs: function (configs) {
  807. var globalConfigs = this.get('globalConfigs');
  808. configs.filterProperty('id', 'puppet var').forEach(function (uiConfigProperty) {
  809. if (globalConfigs.someProperty('name', uiConfigProperty.name)) {
  810. var modelGlobalConfig = globalConfigs.findProperty('name', uiConfigProperty.name);
  811. modelGlobalConfig.value = uiConfigProperty.value;
  812. var uiOverrides = uiConfigProperty.get('overrides');
  813. if(uiOverrides!=null && uiOverrides.get('length')>0){
  814. modelGlobalConfig.overrides = {};
  815. uiOverrides.forEach(function(uiOverride){
  816. var value = uiOverride.get('value');
  817. modelGlobalConfig.overrides[value] = [];
  818. uiOverride.get('selectedHostOptions').forEach(function(host){
  819. modelGlobalConfig.overrides[value].push(host);
  820. });
  821. });
  822. }
  823. } else {
  824. globalConfigs.pushObject({
  825. name: uiConfigProperty.name,
  826. value: uiConfigProperty.value
  827. });
  828. }
  829. }, this);
  830. this.setHiveHostName(globalConfigs);
  831. this.setOozieHostName(globalConfigs);
  832. this.set('globalConfigs', globalConfigs);
  833. },
  834. /**
  835. * set hive hostnames in global configs
  836. * @param globals
  837. */
  838. setHiveHostName: function (globals) {
  839. if (globals.someProperty('name', 'hive_database')) {
  840. var hiveDb = globals.findProperty('name', 'hive_database');
  841. if (hiveDb.value === 'New MySQL Database') {
  842. var ambariHost = globals.findProperty('name', 'hive_ambari_host');
  843. if (ambariHost) {
  844. ambariHost.name = 'hive_hostname';
  845. }
  846. globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_host'));
  847. globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_database'));
  848. globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_host'));
  849. globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_database'));
  850. } else if (hiveDb.value === 'Existing MySQL Database'){
  851. var existingMySqlHost = globals.findProperty('name', 'hive_existing_mysql_host');
  852. if (existingMySqlHost) {
  853. existingMySqlHost.name = 'hive_hostname';
  854. }
  855. globals = globals.without(globals.findProperty('name', 'hive_ambari_host'));
  856. globals = globals.without(globals.findProperty('name', 'hive_ambari_database'));
  857. globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_host'));
  858. globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_database'));
  859. } else { //existing oracle database
  860. var existingOracleHost = globals.findProperty('name', 'hive_existing_oracle_host');
  861. if (existingOracleHost) {
  862. existingOracleHost.name = 'hive_hostname';
  863. }
  864. globals = globals.without(globals.findProperty('name', 'hive_ambari_host'));
  865. globals = globals.without(globals.findProperty('name', 'hive_ambari_database'));
  866. globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_host'));
  867. globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_database'));
  868. }
  869. }
  870. },
  871. /**
  872. * set oozie hostnames in global configs
  873. * @param globals
  874. */
  875. setOozieHostName: function (globals) {
  876. if (globals.someProperty('name', 'oozie_database')) {
  877. var oozieDb = globals.findProperty('name', 'oozie_database');
  878. if (oozieDb.value === 'New Derby Database'){
  879. globals = globals.without(globals.findProperty('name', 'oozie_ambari_host'));
  880. globals = globals.without(globals.findProperty('name', 'oozie_ambari_database'));
  881. globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_host'));
  882. globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_database'));
  883. globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_host'));
  884. globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_database'));
  885. } else if (oozieDb.value === 'New MySQL Database') {
  886. var ambariHost = globals.findProperty('name', 'oozie_ambari_host');
  887. if (ambariHost) {
  888. ambariHost.name = 'oozie_hostname';
  889. }
  890. globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_host'));
  891. globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_database'));
  892. globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_host'));
  893. globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_database'));
  894. globals = globals.without(globals.findProperty('name', 'oozie_derby_database'));
  895. } else if (oozieDb.value === 'Existing MySQL Database') {
  896. var existingMySqlHost = globals.findProperty('name', 'oozie_existing_mysql_host');
  897. if (existingMySqlHost) {
  898. existingMySqlHost.name = 'oozie_hostname';
  899. }
  900. globals = globals.without(globals.findProperty('name', 'oozie_ambari_host'));
  901. globals = globals.without(globals.findProperty('name', 'oozie_ambari_database'));
  902. globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_host'));
  903. globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_database'));
  904. globals = globals.without(globals.findProperty('name', 'oozie_derby_database'));
  905. } else{ //existing oracle database
  906. var existingOracleHost = globals.findProperty('name', 'oozie_existing_oracle_host');
  907. if (existingOracleHost) {
  908. existingOracleHost.name = 'oozie_hostname';
  909. }
  910. globals = globals.without(globals.findProperty('name', 'oozie_ambari_host'));
  911. globals = globals.without(globals.findProperty('name', 'oozie_ambari_database'));
  912. globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_host'));
  913. globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_database'));
  914. globals = globals.without(globals.findProperty('name', 'oozie_derby_database'));
  915. }
  916. }
  917. },
  918. /**
  919. * save site configs
  920. * @param configs
  921. */
  922. saveSiteConfigs: function (configs) {
  923. //storedConfigs contains custom configs as well
  924. var serviceConfigProperties = configs.filterProperty('id', 'site property');
  925. serviceConfigProperties.forEach(function(_config){
  926. if(typeof _config.get('value') === "boolean") _config.set('value', _config.value.toString());
  927. });
  928. var storedConfigs = serviceConfigProperties.filterProperty('value');
  929. var allUiConfigs = this.loadUiSideConfigs(this.get('configMapping').all());
  930. this.set('uiConfigs', storedConfigs.concat(allUiConfigs));
  931. },
  932. /**
  933. * return configs from the UI side
  934. * @param configMapping array with configs
  935. * @return {Array}
  936. */
  937. loadUiSideConfigs: function (configMapping) {
  938. var uiConfig = [];
  939. var configs = configMapping.filterProperty('foreignKey', null);
  940. configs.forEach(function (_config) {
  941. var valueWithOverrides = this.getGlobConfigValueWithOverrides(_config.templateName, _config.value, _config.name);
  942. if (valueWithOverrides !== null) {
  943. uiConfig.pushObject({
  944. "id": "site property",
  945. "name": _config.name,
  946. "value": valueWithOverrides.value,
  947. "filename": _config.filename,
  948. "overrides": valueWithOverrides.overrides
  949. });
  950. }
  951. }, this);
  952. return uiConfig;
  953. },
  954. /**
  955. * return global config value
  956. * @param templateName
  957. * @param expression
  958. * @param name
  959. * @return {
  960. * value: '...',
  961. * overrides: {
  962. * 'value1': [h1, h2],
  963. * 'value2': [h3]
  964. * }
  965. * }
  966. */
  967. getGlobConfigValueWithOverrides: function (templateName, expression, name) {
  968. var express = expression.match(/<(.*?)>/g);
  969. var value = expression;
  970. if (express == null) {
  971. return { value : expression, overrides: {}}; // if site property do not map any global property then return the value
  972. }
  973. var overrideHostToValue = {};
  974. express.forEach(function (_express) {
  975. //console.log("The value of template is: " + _express);
  976. var index = parseInt(_express.match(/\[([\d]*)(?=\])/)[1]);
  977. if (this.get('globalConfigs').someProperty('name', templateName[index])) {
  978. //console.log("The name of the variable is: " + this.get('content.serviceConfigProperties').findProperty('name', templateName[index]).name);
  979. var globalObj = this.get('globalConfigs').findProperty('name', templateName[index]);
  980. var globValue = globalObj.value;
  981. // Hack for templeton.zookeeper.hosts
  982. var preReplaceValue = null;
  983. 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
  984. preReplaceValue = value;
  985. value = this._replaceConfigValues(name, _express, value, globValue);
  986. }
  987. if(globalObj.overrides!=null){
  988. for(ov in globalObj.overrides){
  989. var hostsArray = globalObj.overrides[ov];
  990. hostsArray.forEach(function(host){
  991. if(!(host in overrideHostToValue)){
  992. overrideHostToValue[host] = this._replaceConfigValues(name, _express, preReplaceValue, ov);
  993. }else{
  994. overrideHostToValue[host] = this._replaceConfigValues(name, _express, overrideHostToValue[host], ov);
  995. }
  996. }, this);
  997. }
  998. }
  999. } else {
  1000. /*
  1001. console.log("ERROR: The variable name is: " + templateName[index]);
  1002. console.log("ERROR: mapped config from configMapping file has no corresponding variable in " +
  1003. "content.serviceConfigProperties. Two possible reasons for the error could be: 1) The service is not selected. " +
  1004. "and/OR 2) The service_config metadata file has no corresponding global var for the site property variable");
  1005. */
  1006. value = null;
  1007. }
  1008. }, this);
  1009. var valueWithOverrides = {
  1010. value: value,
  1011. overrides: {}
  1012. };
  1013. if(!jQuery.isEmptyObject(overrideHostToValue)){
  1014. for(var host in overrideHostToValue){
  1015. var hostVal = overrideHostToValue[host];
  1016. if(!(hostVal in valueWithOverrides.overrides)){
  1017. valueWithOverrides.overrides[hostVal] = [];
  1018. }
  1019. valueWithOverrides.overrides[hostVal].push(host);
  1020. }
  1021. }
  1022. return valueWithOverrides;
  1023. },
  1024. _replaceConfigValues: function (name, express, value, globValue) {
  1025. if (name === "templeton.zookeeper.hosts" || name === 'hbase.zookeeper.quorum') {
  1026. var zooKeeperPort = '2181';
  1027. if (typeof globValue === 'string') {
  1028. var temp = [];
  1029. temp.push(globValue);
  1030. globValue = temp;
  1031. }
  1032. if (name === "templeton.zookeeper.hosts") {
  1033. var temp = [];
  1034. globValue.forEach(function (_host, index) {
  1035. temp.push(globValue[index] + ':' + zooKeeperPort);
  1036. }, this);
  1037. globValue = temp;
  1038. }
  1039. value = value.replace(express, globValue.toString());
  1040. } else {
  1041. value = value.replace(express, globValue);
  1042. }
  1043. return value;
  1044. },
  1045. /**
  1046. * Saves cluster level configurations for all necessary sites.
  1047. * PUT calls are made to /api/v1/clusters/clusterName for each site.
  1048. *
  1049. * @return {Boolean}
  1050. */
  1051. doPUTClusterConfigurations: function () {
  1052. var result = true;
  1053. var serviceConfigTags = this.get('serviceConfigTags');
  1054. this.setNewTagNames(serviceConfigTags);
  1055. var siteNameToServerDataMap = {};
  1056. serviceConfigTags.forEach(function (_serviceTags) {
  1057. if (_serviceTags.siteName === 'global') {
  1058. console.log("TRACE: Inside global");
  1059. var serverGlobalConfigs = this.createGlobalSiteObj(_serviceTags.newTagName);
  1060. siteNameToServerDataMap['global'] = serverGlobalConfigs;
  1061. if(this.isConfigChanged(App.config.loadedConfigurationsCache['global_'+this.loadedClusterSiteToTagMap['global']], serverGlobalConfigs.properties)){
  1062. result = result && this.doPUTClusterConfigurationSite(serverGlobalConfigs);
  1063. }
  1064. } else if (_serviceTags.siteName === 'core-site') {
  1065. console.log("TRACE: Inside core-site");
  1066. if (this.get('content.serviceName') === 'HDFS' || this.get('content.serviceName') === 'HCFS') {
  1067. var coreSiteConfigs = this.createCoreSiteObj(_serviceTags.newTagName);
  1068. siteNameToServerDataMap['core-site'] = coreSiteConfigs;
  1069. if(this.isConfigChanged(App.config.loadedConfigurationsCache['core-site_'+this.loadedClusterSiteToTagMap['core-site']], coreSiteConfigs.properties)){
  1070. result = result && this.doPUTClusterConfigurationSite(coreSiteConfigs);
  1071. }
  1072. }
  1073. } else {
  1074. var serverConfigs = this.createSiteObj(_serviceTags.siteName, _serviceTags.newTagName);
  1075. siteNameToServerDataMap[_serviceTags.siteName] = serverConfigs;
  1076. if(this.isConfigChanged(App.config.loadedConfigurationsCache[_serviceTags.siteName+'_'+this.loadedClusterSiteToTagMap[_serviceTags.siteName]], serverConfigs.properties)){
  1077. result = result && this.doPUTClusterConfigurationSite(serverConfigs);
  1078. }
  1079. }
  1080. }, this);
  1081. this.savedSiteNameToServerServiceConfigDataMap = siteNameToServerDataMap;
  1082. return result;
  1083. },
  1084. /**
  1085. * Compares the loaded config values with the saving config values.
  1086. */
  1087. isConfigChanged: function (loadedConfig, savingConfig) {
  1088. var changed = false;
  1089. if (loadedConfig != null && savingConfig != null) {
  1090. var seenLoadKeys = [];
  1091. for ( var loadKey in loadedConfig) {
  1092. seenLoadKeys.push(loadKey);
  1093. var loadValue = loadedConfig[loadKey];
  1094. var saveValue = savingConfig[loadKey];
  1095. if("boolean" == typeof(saveValue)){
  1096. saveValue = saveValue.toString();
  1097. }
  1098. if(saveValue==null){
  1099. saveValue = "null";
  1100. }
  1101. if (loadValue !== saveValue) {
  1102. changed = true;
  1103. break;
  1104. }
  1105. }
  1106. for ( var saveKey in savingConfig) {
  1107. if (seenLoadKeys.indexOf(saveKey) < 0) {
  1108. changed = true;
  1109. break;
  1110. }
  1111. }
  1112. }
  1113. return changed;
  1114. },
  1115. /**
  1116. * Saves configuration of a particular site. The provided data
  1117. * contains the site name and tag to be used.
  1118. */
  1119. doPUTClusterConfigurationSite: function (data) {
  1120. var result;
  1121. var url = this.getUrl('', '');
  1122. var clusterData = {
  1123. Clusters: {
  1124. desired_config: data
  1125. }
  1126. };
  1127. console.log("applyClusterConfigurationToSite(): PUTting data:", clusterData);
  1128. $.ajax({
  1129. type: 'PUT',
  1130. url: url,
  1131. async: false,
  1132. dataType: 'text',
  1133. data: JSON.stringify(clusterData),
  1134. timeout: 5000,
  1135. success: function (data) {
  1136. console.log("applyClusterConfigurationToSite(): In success for data:", data);
  1137. result = true;
  1138. },
  1139. error: function (request, ajaxOptions, error) {
  1140. console.log('applyClusterConfigurationToSite(): ERROR:', request.responseText, ", error=", error);
  1141. result = false;
  1142. },
  1143. statusCode: require('data/statusCodes')
  1144. });
  1145. console.log("applyClusterConfigurationToSite(): Exiting with result=" + result);
  1146. return result;
  1147. },
  1148. /**
  1149. * Creates host level overrides for service configuration.
  1150. *
  1151. */
  1152. doPUTHostOverridesConfigurationSites: function(){
  1153. var singlePUTHostData = [];
  1154. var savedHostSiteArray = [];
  1155. for ( var host in this.savedHostToOverrideSiteToTagMap) {
  1156. for ( var siteName in this.savedHostToOverrideSiteToTagMap[host]) {
  1157. var tagName = this.savedHostToOverrideSiteToTagMap[host][siteName].tagName;
  1158. var map = this.savedHostToOverrideSiteToTagMap[host][siteName].map;
  1159. savedHostSiteArray.push(host+"///"+siteName);
  1160. singlePUTHostData.push({
  1161. RequestInfo: {
  1162. query: 'Hosts/host_name='+host
  1163. },
  1164. Body: {
  1165. Hosts: {
  1166. desired_config: {
  1167. type: siteName,
  1168. tag: tagName,
  1169. properties: map
  1170. }
  1171. }
  1172. }
  1173. });
  1174. }
  1175. }
  1176. // Now cleanup removed overrides
  1177. for ( var loadedHost in this.loadedHostToOverrideSiteToTagMap) {
  1178. for ( var loadedSiteName in this.loadedHostToOverrideSiteToTagMap[loadedHost]) {
  1179. if (!(savedHostSiteArray.contains(loadedHost + "///" + loadedSiteName))) {
  1180. // This host-site combination was loaded, but not saved.
  1181. // Meaning it is not needed anymore. Hence send a DELETE command.
  1182. singlePUTHostData.push({
  1183. RequestInfo: {
  1184. query: 'Hosts/host_name='+loadedHost
  1185. },
  1186. Body: {
  1187. Hosts: {
  1188. desired_config: {
  1189. type: loadedSiteName,
  1190. tag: this.loadedHostToOverrideSiteToTagMap[loadedHost][loadedSiteName],
  1191. selected: false
  1192. }
  1193. }
  1194. }
  1195. });
  1196. }
  1197. }
  1198. }
  1199. console.debug("createHostOverrideConfigSites(): PUTting host-overrides. Data=",singlePUTHostData);
  1200. if(singlePUTHostData.length>0){
  1201. var url = this.getUrl('', '/hosts');
  1202. var hostOverrideResult = true;
  1203. $.ajax({
  1204. type: 'PUT',
  1205. url: url,
  1206. data: JSON.stringify(singlePUTHostData),
  1207. async: false,
  1208. dataType: 'text',
  1209. timeout: 5000,
  1210. success: function (data) {
  1211. var jsonData = jQuery.parseJSON(data);
  1212. hostOverrideResult = true;
  1213. console.log("createHostOverrideConfigSites(): SUCCESS:", url, ". RESPONSE:",jsonData);
  1214. },
  1215. error: function (request, ajaxOptions, error) {
  1216. hostOverrideResult = false;
  1217. console.log("createHostOverrideConfigSites(): ERROR:", url, ". RESPONSE:",request.responseText);
  1218. },
  1219. statusCode: require('data/statusCodes')
  1220. });
  1221. return hostOverrideResult;
  1222. }
  1223. return true;
  1224. },
  1225. /**
  1226. * add newTagName property to each config in serviceConfigs
  1227. * @param serviceConfigs
  1228. */
  1229. setNewTagNames: function (serviceConfigs) {
  1230. var time = (new Date).getTime();
  1231. serviceConfigs.forEach(function (_serviceConfigs) {
  1232. _serviceConfigs.newTagName = 'version' + time;
  1233. }, this);
  1234. },
  1235. /**
  1236. * create global site object
  1237. * @param tagName
  1238. * @return {Object}
  1239. */
  1240. createGlobalSiteObj: function (tagName) {
  1241. var globalSiteProperties = {};
  1242. this.get('globalConfigs').forEach(function (_globalSiteObj) {
  1243. // do not pass any globalConfigs whose name ends with _host or _hosts
  1244. if (!/_hosts?$/.test(_globalSiteObj.name)) {
  1245. // append "m" to JVM memory options except for hadoop_heapsize
  1246. if (/_heapsize|_newsize|_maxnewsize$/.test(_globalSiteObj.name) && _globalSiteObj.name !== 'hadoop_heapsize') {
  1247. _globalSiteObj.value += "m";
  1248. }
  1249. globalSiteProperties[_globalSiteObj.name] = _globalSiteObj.value;
  1250. this.recordHostOverride(_globalSiteObj, 'global', tagName, this);
  1251. //console.log("TRACE: name of the global property is: " + _globalSiteObj.name);
  1252. //console.log("TRACE: value of the global property is: " + _globalSiteObj.value);
  1253. }
  1254. }, this);
  1255. return {"type": "global", "tag": tagName, "properties": globalSiteProperties};
  1256. },
  1257. recordHostOverride: function(serviceConfigObj, siteName, tagName, self){
  1258. if('get' in serviceConfigObj){
  1259. return this._recordHostOverrideFromEmberObj(serviceConfigObj, siteName, tagName, self);
  1260. }else{
  1261. return this._recordHostOverrideFromObj(serviceConfigObj, siteName, tagName, self);
  1262. }
  1263. },
  1264. /**
  1265. * Records all the host overrides per site/tag
  1266. */
  1267. _recordHostOverrideFromObj: function(serviceConfigObj, siteName, tagName, self){
  1268. var overrides = serviceConfigObj.overrides;
  1269. if(overrides){
  1270. for(var value in overrides){
  1271. overrides[value].forEach(function(host){
  1272. if(!(host in self.savedHostToOverrideSiteToTagMap)){
  1273. self.savedHostToOverrideSiteToTagMap[host] = {};
  1274. }
  1275. if(!(siteName in self.savedHostToOverrideSiteToTagMap[host])){
  1276. self.savedHostToOverrideSiteToTagMap[host][siteName] = {};
  1277. self.savedHostToOverrideSiteToTagMap[host][siteName].map = {};
  1278. }
  1279. var finalTag = tagName + '_' + host;
  1280. console.log("recordHostOverride(): Saving host override for host="+host+", site="+siteName+", tag="+finalTag+", (key,value)=("+serviceConfigObj.name+","+value+")");
  1281. self.savedHostToOverrideSiteToTagMap[host][siteName].tagName = finalTag;
  1282. self.savedHostToOverrideSiteToTagMap[host][siteName].map[serviceConfigObj.name] = value;
  1283. });
  1284. }
  1285. }
  1286. },
  1287. /**
  1288. * Records all the host overrides per site/tag
  1289. */
  1290. _recordHostOverrideFromEmberObj: function(serviceConfigObj, siteName, tagName, self){
  1291. var overrides = serviceConfigObj.get('overrides');
  1292. if(overrides){
  1293. overrides.forEach(function(override){
  1294. override.get('selectedHostOptions').forEach(function(host){
  1295. if(!(host in self.savedHostToOverrideSiteToTagMap)){
  1296. self.savedHostToOverrideSiteToTagMap[host] = {};
  1297. }
  1298. if(!(siteName in self.savedHostToOverrideSiteToTagMap[host])){
  1299. self.savedHostToOverrideSiteToTagMap[host][siteName] = {};
  1300. self.savedHostToOverrideSiteToTagMap[host][siteName].map = {};
  1301. }
  1302. var finalTag = tagName + '_' + host;
  1303. console.log("recordHostOverride(): Saving host override for host="+host+", site="+siteName+", tag="+finalTag+", (key,value)=("+serviceConfigObj.name+","+override.get('value')+")");
  1304. self.savedHostToOverrideSiteToTagMap[host][siteName].tagName = finalTag;
  1305. self.savedHostToOverrideSiteToTagMap[host][siteName].map[serviceConfigObj.name] = override.get('value');
  1306. });
  1307. });
  1308. }
  1309. },
  1310. /**
  1311. * create core site object
  1312. * @param tagName
  1313. * @return {Object}
  1314. */
  1315. createCoreSiteObj: function (tagName) {
  1316. var coreSiteObj = this.get('uiConfigs').filterProperty('filename', 'core-site.xml');
  1317. var coreSiteProperties = {};
  1318. // hadoop.proxyuser.oozie.hosts needs to be skipped if oozie is not selected
  1319. var isOozieSelected = App.Service.find().someProperty('serviceName', 'OOZIE');
  1320. var oozieUser = this.get('globalConfigs').someProperty('name', 'oozie_user') ? this.get('globalConfigs').findProperty('name', 'oozie_user').value : null;
  1321. var isHiveSelected = App.Service.find().someProperty('serviceName', 'HIVE');
  1322. var hiveUser = this.get('globalConfigs').someProperty('name', 'hive_user') ? this.get('globalConfigs').findProperty('name', 'hive_user').value : null;
  1323. var isHcatSelected = App.Service.find().someProperty('serviceName', 'WEBHCAT');
  1324. var hcatUser = this.get('globalConfigs').someProperty('name', 'hcat_user') ? this.get('globalConfigs').findProperty('name', 'hcat_user').value : null;
  1325. coreSiteObj.forEach(function (_coreSiteObj) {
  1326. 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'))) {
  1327. coreSiteProperties[_coreSiteObj.name] = _coreSiteObj.value;
  1328. this.recordHostOverride(_coreSiteObj, 'core-site', tagName, this);
  1329. }
  1330. }, this);
  1331. return {"type": "core-site", "tag": tagName, "properties": coreSiteProperties};
  1332. },
  1333. /**
  1334. * create site object
  1335. * @param siteName
  1336. * @param tagName
  1337. * @return {Object}
  1338. */
  1339. createSiteObj: function (siteName, tagName) {
  1340. var siteObj = this.get('uiConfigs').filterProperty('filename', siteName + '.xml');
  1341. var siteProperties = {};
  1342. if (siteName == 'oozie-site') {
  1343. siteObj = this.getOozieSiteObj(siteObj);
  1344. } else if (siteName == 'hive-site') {
  1345. siteObj = this.getHiveSiteObj(siteObj);
  1346. }
  1347. siteObj.forEach(function (_siteObj) {
  1348. siteProperties[_siteObj.name] = _siteObj.value;
  1349. this.recordHostOverride(_siteObj, siteName, tagName, this);
  1350. }, this);
  1351. return {"type": siteName, "tag": tagName, "properties": siteProperties};
  1352. },
  1353. /**
  1354. * create site object for Oozie
  1355. * @param siteObj
  1356. * @return {Object}
  1357. */
  1358. getOozieSiteObj: function (siteObj) {
  1359. var jdbcUrl = siteObj.findProperty('name', 'oozie.service.JPAService.jdbc.url');
  1360. var jdbcDriver = siteObj.findProperty('name', 'oozie.service.JPAService.jdbc.driver');
  1361. var oozieDb = this.get('globalConfigs').findProperty('name', 'oozie_database').value;
  1362. // oozieHost is undefined if the database is oozie
  1363. var oozieHost = (oozieDb == 'New Derby Database') ? '' : this.get('globalConfigs').findProperty('name', 'oozie_hostname').value;
  1364. var oozieDbName = this.get('globalConfigs').findProperty('name', 'oozie_database_name').value;
  1365. switch (oozieDb) {
  1366. case 'New Derby Database':
  1367. jdbcUrl.value = "jdbc:derby:${oozie.data.dir}/${oozie.db.schema.name}-db;create=true";
  1368. jdbcDriver.value = "org.apache.derby.jdbc.EmbeddedDriver";
  1369. break;
  1370. case 'Existing MySQL Database':
  1371. jdbcUrl.value = "jdbc:mysql://" + oozieHost + "/" + oozieDbName;
  1372. jdbcDriver.value = "com.mysql.jdbc.Driver";
  1373. break;
  1374. case 'Existing Oracle Database':
  1375. jdbcUrl.value = "jdbc:oracle:thin:@//" + oozieHost + ":1521/" + oozieDbName;
  1376. jdbcDriver.value = "oracle.jdbc.driver.OracleDriver";
  1377. break;
  1378. }
  1379. return siteObj;
  1380. },
  1381. /**
  1382. * create site object for Hive
  1383. * @param siteObj
  1384. * @return {Object}
  1385. */
  1386. getHiveSiteObj: function (siteObj) {
  1387. var jdbcUrl = siteObj.findProperty('name', 'javax.jdo.option.ConnectionURL');
  1388. var jdbcDriver = siteObj.findProperty('name', 'javax.jdo.option.ConnectionDriverName');
  1389. var hiveDb = this.get('globalConfigs').findProperty('name', 'hive_database').value;
  1390. var hiveHost = this.get('globalConfigs').findProperty('name', 'hive_hostname').value;
  1391. var hiveDbName = this.get('globalConfigs').findProperty('name', 'hive_database_name').value;
  1392. switch (hiveDb) {
  1393. case 'New MySQL Database':
  1394. jdbcUrl.value = "jdbc:mysql://"+ hiveHost + "/" + hiveDbName + "?createDatabaseIfNotExist=true";
  1395. jdbcDriver.value = "com.mysql.jdbc.Driver";
  1396. break;
  1397. case 'Existing MySQL Database':
  1398. jdbcUrl.value = "jdbc:mysql://"+ hiveHost + "/" + hiveDbName + "?createDatabaseIfNotExist=true";
  1399. jdbcDriver.value = "com.mysql.jdbc.Driver";
  1400. break;
  1401. case 'Existing Oracle Database':
  1402. jdbcUrl.value = "jdbc:oracle:thin:@//"+ hiveHost + ":1521/" + hiveDbName;
  1403. jdbcDriver.value = "oracle.jdbc.driver.OracleDriver";
  1404. break;
  1405. }
  1406. return siteObj;
  1407. },
  1408. /**
  1409. * Set display names of the property from the puppet/global names
  1410. * @param: displayNames: a field to be set with displayNames
  1411. * @param names: array of property puppet/global names
  1412. */
  1413. setPropertyDisplayNames: function (displayNames, names) {
  1414. var stepConfigs = this.get('stepConfigs').findProperty('serviceName', this.get('content.serviceName')).configs;
  1415. names.forEach(function (_name, index) {
  1416. if (stepConfigs.someProperty('name', _name)) {
  1417. displayNames.push(stepConfigs.findProperty('name', _name).displayName);
  1418. }
  1419. }, this);
  1420. },
  1421. /**
  1422. * Set property of the site variable
  1423. */
  1424. setSiteProperty: function (key, value, filename) {
  1425. if (filename === 'core-site.xml' && this.get('uiConfigs').filterProperty('filename', 'core-site.xml').someProperty('name', key)) {
  1426. this.get('uiConfigs').filterProperty('filename', 'core-site.xml').findProperty('name', key).value = value;
  1427. return;
  1428. }
  1429. this.get('uiConfigs').pushObject({
  1430. "id": "site property",
  1431. "name": key,
  1432. "value": value,
  1433. "filename": filename
  1434. });
  1435. },
  1436. /**
  1437. * return either specific url for request if testMode is false or testUrl
  1438. * @param testUrl
  1439. * @param url
  1440. * @return {*}
  1441. */
  1442. getUrl: function (testUrl, url) {
  1443. return (App.testMode) ? testUrl : App.apiPrefix + '/clusters/' + App.router.getClusterName() + url;
  1444. },
  1445. /**
  1446. * Adds host name of master component to global config;
  1447. */
  1448. addHostNamesToGlobalConfig: function () {
  1449. var serviceName = this.get('content.serviceName');
  1450. var globalConfigs = this.get('globalConfigs');
  1451. var serviceConfigs = this.get('serviceConfigs').findProperty('serviceName', serviceName).configs;
  1452. //namenode_host is required to derive "fs.default.name" a property of core-site
  1453. var nameNodeHost = this.get('serviceConfigs').findProperty('serviceName', 'HDFS').configs.findProperty('name', 'namenode_host');
  1454. try {
  1455. nameNodeHost.defaultValue = App.Service.find('HDFS').get('hostComponents').findProperty('componentName', 'NAMENODE').get('host.hostName');
  1456. globalConfigs.push(nameNodeHost);
  1457. } catch (err) {
  1458. console.log("No NameNode Host available. This is expected if you're using HCFS rather than HDFS.");
  1459. }
  1460. //zooKeeperserver_host
  1461. var zooKeperHost = this.get('serviceConfigs').findProperty('serviceName', 'ZOOKEEPER').configs.findProperty('name', 'zookeeperserver_hosts');
  1462. if (serviceName === 'ZOOKEEPER' || serviceName === 'HBASE' || serviceName === 'WEBHCAT') {
  1463. zooKeperHost.defaultValue = App.Service.find('ZOOKEEPER').get('hostComponents').filterProperty('componentName', 'ZOOKEEPER_SERVER').mapProperty('host.hostName');
  1464. globalConfigs.push(zooKeperHost);
  1465. }
  1466. switch (serviceName) {
  1467. case 'HDFS':
  1468. var sNameNodeHost = serviceConfigs.findProperty('name', 'snamenode_host');
  1469. sNameNodeHost.defaultValue = this.get('content.hostComponents').findProperty('componentName', 'SECONDARY_NAMENODE').get('host.hostName');
  1470. globalConfigs.push(sNameNodeHost);
  1471. break;
  1472. case 'MAPREDUCE':
  1473. var jobTrackerHost = serviceConfigs.findProperty('name', 'jobtracker_host');
  1474. jobTrackerHost.defaultValue = this.get('content.hostComponents').findProperty('componentName', 'JOBTRACKER').get('host.hostName');
  1475. globalConfigs.push(jobTrackerHost);
  1476. break;
  1477. case 'HIVE':
  1478. var hiveMetastoreHost = serviceConfigs.findProperty('name', 'hivemetastore_host');
  1479. hiveMetastoreHost.defaultValue = this.get('content.hostComponents').findProperty('componentName', 'HIVE_SERVER').get('host.hostName');
  1480. globalConfigs.push(hiveMetastoreHost);
  1481. var hiveDb = globalConfigs.findProperty('name', 'hive_database').value;
  1482. if (['Existing MySQL Database', 'Existing Oracle Database'].contains(hiveDb)) {
  1483. globalConfigs.findProperty('name', 'hive_hostname').isVisible = true;
  1484. }
  1485. break;
  1486. case 'OOZIE':
  1487. var oozieServerHost = serviceConfigs.findProperty('name', 'oozieserver_host');
  1488. oozieServerHost.defaultValue = this.get('content.hostComponents').findProperty('componentName', 'OOZIE_SERVER').get('host.hostName');
  1489. globalConfigs.push(oozieServerHost);
  1490. var oozieDb = globalConfigs.findProperty('name', 'oozie_database').value;
  1491. if (['Existing MySQL Database', 'Existing Oracle Database'].contains(oozieDb)) {
  1492. globalConfigs.findProperty('name', 'oozie_hostname').isVisible = true;
  1493. }
  1494. break;
  1495. case 'HBASE':
  1496. var hbaseMasterHost = serviceConfigs.findProperty('name', 'hbasemaster_host');
  1497. hbaseMasterHost.defaultValue = this.get('content.hostComponents').filterProperty('componentName', 'HBASE_MASTER').mapProperty('host.hostName');
  1498. globalConfigs.push(hbaseMasterHost);
  1499. break;
  1500. case 'HUE':
  1501. var hueServerHost = serviceConfigs.findProperty('name', 'hueserver_host');
  1502. hueServerHost.defaultValue = this.get('content.hostComponents').findProperty('componentName', 'HUE_SERVER').get('host.hostName');
  1503. globalConfigs.push(hueServerHost);
  1504. break;
  1505. case 'WEBHCAT':
  1506. var webhcatMasterHost = serviceConfigs.findProperty('name', 'webhcatserver_host');
  1507. webhcatMasterHost.defaultValue = this.get('content.hostComponents').filterProperty('componentName', 'WEBHCAT_SERVER').mapProperty('host.hostName');
  1508. globalConfigs.push(webhcatMasterHost);
  1509. break;
  1510. }
  1511. },
  1512. /**
  1513. * Provides service component name and display-name information for
  1514. * the current selected service.
  1515. */
  1516. getCurrentServiceComponents: function () {
  1517. var service = this.get('content');
  1518. var components = service.get('hostComponents');
  1519. var validComponents = Ember.A([]);
  1520. var seenComponents = {};
  1521. components.forEach(function(component){
  1522. var cn = component.get('componentName');
  1523. var cdn = component.get('displayName');
  1524. if(!seenComponents[cn]){
  1525. validComponents.push(Ember.Object.create({
  1526. componentName: cn,
  1527. displayName: cdn,
  1528. selected: false
  1529. }));
  1530. seenComponents[cn] = cn;
  1531. }
  1532. });
  1533. return validComponents;
  1534. }.property('content'),
  1535. getAllHosts: function () {
  1536. return App.router.get('mainHostController.content');
  1537. }.property('App.router.mainHostController.content'),
  1538. doCancel: function () {
  1539. this.loadStep();
  1540. }
  1541. });