step7_controller.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  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 numberUtils = require('utils/number_utils');
  20. /**
  21. * By Step 7, we have the following information stored in App.db and set on this
  22. * controller by the router.
  23. *
  24. * selectedServices: App.db.selectedServices (the services that the user selected in Step 4)
  25. * masterComponentHosts: App.db.masterComponentHosts (master-components-to-hosts mapping the user selected in Step 5)
  26. * slaveComponentHosts: App.db.slaveComponentHosts (slave-components-to-hosts mapping the user selected in Step 6)
  27. *
  28. */
  29. App.WizardStep7Controller = Em.Controller.extend({
  30. name: 'wizardStep7Controller',
  31. stepConfigs: [], //contains all field properties that are viewed in this step
  32. selectedService: null,
  33. slaveHostToGroup: null,
  34. secureConfigs: require('data/secure_mapping'),
  35. miscModalVisible: false, //If miscConfigChange Modal is shown
  36. gangliaAvailableSpace: null,
  37. gangliaMoutDir:'/',
  38. overrideToAdd: null,
  39. isInstaller: true,
  40. configGroups: [],
  41. groupsToDelete: [],
  42. selectedConfigGroup: null,
  43. serviceConfigsData: require('data/service_configs'),
  44. isSubmitDisabled: function () {
  45. return (!this.stepConfigs.filterProperty('showConfig', true).everyProperty('errorCount', 0) || this.get("miscModalVisible"));
  46. }.property('stepConfigs.@each.errorCount', 'miscModalVisible'),
  47. selectedServiceNames: function () {
  48. return this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).mapProperty('serviceName');
  49. }.property('content.services').cacheable(),
  50. allInstalledServiceNames: function () {
  51. return this.get('content.services').filterProperty('isSelected', true).mapProperty('serviceName');
  52. }.property('content.services').cacheable(),
  53. masterComponentHosts: function () {
  54. return this.get('content.masterComponentHosts');
  55. }.property('content.masterComponentHosts'),
  56. slaveComponentHosts: function () {
  57. return this.get('content.slaveGroupProperties');
  58. }.property('content.slaveGroupProperties', 'content.slaveComponentHosts'),
  59. customData: [],
  60. clearStep: function () {
  61. this.get('stepConfigs').clear();
  62. this.set('filter', '');
  63. this.get('filterColumns').setEach('selected', false);
  64. },
  65. /**
  66. * Load config groups for installed services
  67. */
  68. loadInstalledServicesConfigGroups: function (servicesNames) {
  69. if (servicesNames.indexOf('MISC') > -1)
  70. servicesNames.splice(servicesNames.indexOf('MISC'), 1);
  71. servicesNames.forEach(function(serviceName) {
  72. App.ajax.send({
  73. name: 'config.tags_and_groups',
  74. sender: this,
  75. data: {
  76. serviceName: serviceName,
  77. serviceConfigsDef: App.config.get('preDefinedServiceConfigs').findProperty('serviceName', serviceName)
  78. },
  79. success: 'loadServiceTagsSuccess'
  80. });
  81. }, this);
  82. },
  83. /**
  84. * Load config groups success callback
  85. */
  86. loadServiceTagsSuccess: function (data, opt, params) {
  87. var serviceConfigsDef = params.serviceConfigsDef;
  88. var serviceName = params.serviceName;
  89. var service = this.get('stepConfigs').findProperty('serviceName', serviceName);
  90. console.debug("loadServiceConfigs(): data=", data);
  91. // Create default configuration group
  92. var defaultConfigGroupHosts = App.Host.find().mapProperty('hostName');
  93. var selectedConfigGroup;
  94. var siteToTagMap = {};
  95. for (var site in data.Clusters.desired_configs) {
  96. if (serviceConfigsDef.sites.indexOf(site) > -1) {
  97. siteToTagMap[site] = data.Clusters.desired_configs[site].tag;
  98. }
  99. }
  100. this.loadedClusterSiteToTagMap = siteToTagMap;
  101. //parse loaded config groups
  102. if (App.supports.hostOverrides) {
  103. var configGroups = [];
  104. if (data.config_groups.length) {
  105. data.config_groups.forEach(function (item) {
  106. item = item.ConfigGroup;
  107. if (item.tag === serviceName) {
  108. var groupHosts = item.hosts.mapProperty('host_name');
  109. var newConfigGroup = App.ConfigGroup.create({
  110. id: item.id,
  111. name: item.group_name,
  112. description: item.description,
  113. isDefault: false,
  114. parentConfigGroup: null,
  115. service: App.Service.find().findProperty('serviceName', item.tag),
  116. hosts: groupHosts,
  117. configSiteTags: []
  118. });
  119. groupHosts.forEach(function (host) {
  120. defaultConfigGroupHosts = defaultConfigGroupHosts.without(host);
  121. }, this);
  122. item.desired_configs.forEach(function (config) {
  123. newConfigGroup.configSiteTags.push(App.ConfigSiteTag.create({
  124. site: config.type,
  125. tag: config.tag
  126. }));
  127. }, this);
  128. configGroups.push(newConfigGroup);
  129. }
  130. }, this);
  131. }
  132. }
  133. var defaultConfigGroup = App.ConfigGroup.create({
  134. name: App.Service.DisplayNames[serviceName] + " Default",
  135. description: "Default cluster level " + serviceName + " configuration",
  136. isDefault: true,
  137. hosts: defaultConfigGroupHosts,
  138. parentConfigGroup: null,
  139. service: Em.Object.create({
  140. id: serviceName
  141. }),
  142. serviceName: serviceName,
  143. configSiteTags: []
  144. });
  145. if (!selectedConfigGroup) {
  146. selectedConfigGroup = defaultConfigGroup;
  147. }
  148. configGroups.sort(function(configGroupA, configGroupB){
  149. return (configGroupA.name > configGroupB.name);
  150. });
  151. configGroups.unshift(defaultConfigGroup);
  152. if (App.supports.hostOverrides) {
  153. service.set('configGroups', configGroups);
  154. var loadedGroupToOverrideSiteToTagMap = {};
  155. if (App.supports.hostOverrides) {
  156. var configGroupsWithOverrides = selectedConfigGroup.get('isDefault') ? service.get('configGroups') : [selectedConfigGroup];
  157. configGroupsWithOverrides.forEach(function (item) {
  158. var groupName = item.get('name');
  159. loadedGroupToOverrideSiteToTagMap[groupName] = {};
  160. item.get('configSiteTags').forEach(function (siteTag) {
  161. var site = siteTag.get('site');
  162. var tag = siteTag.get('tag');
  163. loadedGroupToOverrideSiteToTagMap[groupName][site] = tag;
  164. }, this);
  165. }, this);
  166. }
  167. App.config.loadServiceConfigHostsOverrides(service.get('configs'), loadedGroupToOverrideSiteToTagMap, service.get('configGroups'));
  168. var serviceConfig = App.config.createServiceConfig(serviceName);
  169. if (serviceConfig.get('serviceName') === 'HDFS') {
  170. App.config.OnNnHAHideSnn(serviceConfig);
  171. }
  172. service.set('selectedConfigGroup', selectedConfigGroup);
  173. this.loadComponentConfigs(service.get('configs'), serviceConfig, service);
  174. }
  175. service.set('configs', serviceConfig.get('configs'));
  176. },
  177. loadComponentConfigs: function (configs, componentConfig, component) {
  178. var localDB = App.router.get('mainServiceInfoConfigsController').getInfoForDefaults();
  179. var recommendedDefaults = {};
  180. var s = this.get('serviceConfigsData').findProperty('serviceName', component.get('serviceName'));
  181. var defaultGroupSelected = component.get('selectedConfigGroup.isDefault');
  182. var defaults = [];
  183. if (s.defaultsProviders) {
  184. s.defaultsProviders.forEach(function(defaultsProvider) {
  185. var d = defaultsProvider.getDefaults(localDB);
  186. defaults.push(d);
  187. for (var name in d) {
  188. recommendedDefaults[name] = d[name];
  189. }
  190. });
  191. }
  192. if (s.configsValidator) {
  193. s.configsValidator.set('recommendedDefaults', recommendedDefaults);
  194. }
  195. configs.forEach(function (_serviceConfigProperty) {
  196. console.log("config", _serviceConfigProperty);
  197. if (!_serviceConfigProperty) return;
  198. var overrides = _serviceConfigProperty.get('overrides');
  199. // we will populate the override properties below
  200. _serviceConfigProperty.set('overrides', null);
  201. if (_serviceConfigProperty.isOverridable === undefined) {
  202. _serviceConfigProperty.set('isOverridable', true);
  203. }
  204. if (_serviceConfigProperty.displayType === 'checkbox') {
  205. switch (_serviceConfigProperty.value) {
  206. case 'true':
  207. _serviceConfigProperty.set('value', true);
  208. _serviceConfigProperty.set('defaultValue', true);
  209. break;
  210. case 'false':
  211. _serviceConfigProperty.set('value', false);
  212. _serviceConfigProperty.set('defaultValue', false);
  213. break;
  214. }
  215. }
  216. var serviceConfigProperty = App.ServiceConfigProperty.create(_serviceConfigProperty);
  217. if (serviceConfigProperty.get('serviceName') === component.get('serviceName')) {
  218. if (s.configsValidator) {
  219. var validators = s.configsValidator.get('configValidators');
  220. for (var validatorName in validators) {
  221. if (serviceConfigProperty.name == validatorName) {
  222. serviceConfigProperty.set('serviceValidator', s.configsValidator);
  223. }
  224. }
  225. }
  226. serviceConfigProperty.set('isVisible', true);
  227. console.log("config result", serviceConfigProperty);
  228. } else {
  229. serviceConfigProperty.set('isVisible', false);
  230. }
  231. if (overrides != null) {
  232. overrides.forEach(function (override) {
  233. var newSCP = App.ServiceConfigProperty.create(_serviceConfigProperty);
  234. newSCP.set('value', override.value);
  235. newSCP.set('isOriginalSCP', false); // indicated this is overridden value,
  236. newSCP.set('parentSCP', _serviceConfigProperty);
  237. if (App.supports.hostOverrides && defaultGroupSelected) {
  238. var group = component.get('configGroups').findProperty('name', override.group.get('name'));
  239. // prevent cycle in proto object, clean link
  240. if (group.get('properties').length == 0)
  241. group.set('properties', Em.A([]));
  242. group.get('properties').push(newSCP);
  243. newSCP.set('group', override.group);
  244. newSCP.set('isEditable', false);
  245. }
  246. var parentOverridesArray = serviceConfigProperty.get('overrides');
  247. if (parentOverridesArray == null) {
  248. parentOverridesArray = Ember.A([]);
  249. serviceConfigProperty.set('overrides', parentOverridesArray);
  250. }
  251. serviceConfigProperty.get('overrides').pushObject(newSCP);
  252. console.debug("createOverrideProperty(): Added:", newSCP, " to main-property:", serviceConfigProperty)
  253. }, this);
  254. } else {
  255. serviceConfigProperty.set('overrides', Ember.A([]));
  256. }
  257. if (App.get('isAdmin')) {
  258. if(defaultGroupSelected && !this.get('isHostsConfigsPage')){
  259. serviceConfigProperty.set('isEditable', serviceConfigProperty.get('isReconfigurable'));
  260. } else {
  261. serviceConfigProperty.set('isEditable', false);
  262. }
  263. } else {
  264. serviceConfigProperty.set('isEditable', false);
  265. }
  266. componentConfig.get('configs').pushObject(serviceConfigProperty);
  267. serviceConfigProperty.validate();
  268. }, this);
  269. var overrideToAdd = this.get('overrideToAdd');
  270. if (overrideToAdd) {
  271. overrideToAdd = componentConfig.configs.findProperty('name', overrideToAdd.name);
  272. if (overrideToAdd) {
  273. this.addOverrideProperty(overrideToAdd);
  274. component.set('overrideToAdd', null);
  275. }
  276. }
  277. },
  278. /**
  279. * On load function
  280. */
  281. loadStep: function () {
  282. console.log("TRACE: Loading step7: Configure Services");
  283. this.clearStep();
  284. //STEP 1: Load advanced configs
  285. var advancedConfigs = this.get('content.advancedServiceConfig');
  286. //STEP 2: Load on-site configs by service from local DB
  287. var storedConfigs = this.get('content.serviceConfigProperties');
  288. //STEP 3: Merge pre-defined configs with loaded on-site configs
  289. var configs = App.config.mergePreDefinedWithStored(storedConfigs, advancedConfigs);
  290. //STEP 4: Add advanced configs
  291. App.config.addAdvancedConfigs(configs, advancedConfigs);
  292. //STEP 5: Add custom configs
  293. App.config.addCustomConfigs(configs);
  294. //put properties from capacity-scheduler.xml into one config with textarea view
  295. if(this.get('allInstalledServiceNames').contains('YARN') && !App.supports.capacitySchedulerUi){
  296. configs = App.config.fileConfigsIntoTextarea(configs, 'capacity-scheduler.xml');
  297. }
  298. this.set('groupsToDelete', this.get('wizardController').getDBProperty('groupsToDelete') || []);
  299. var localDB = {
  300. hosts: this.get('wizardController').getDBProperty('hosts'),
  301. masterComponentHosts: this.get('wizardController').getDBProperty('masterComponentHosts'),
  302. slaveComponentHosts: this.get('wizardController').getDBProperty('slaveComponentHosts')
  303. };
  304. //STEP 6: Distribute configs by service and wrap each one in App.ServiceConfigProperty (configs -> serviceConfigs)
  305. var serviceConfigs = App.config.renderConfigs(configs, storedConfigs, this.get('allInstalledServiceNames'), this.get('selectedServiceNames'), localDB);
  306. if (this.get('wizardController.name') === 'addServiceController') {
  307. serviceConfigs.setEach('showConfig', true);
  308. serviceConfigs.setEach('selected', false);
  309. this.get('selectedServiceNames').forEach(function(serviceName) {
  310. if(!serviceConfigs.findProperty('serviceName', serviceName)) return;
  311. serviceConfigs.findProperty('serviceName', serviceName).set('selected', true);
  312. });
  313. // Remove SNameNode if HA is enabled
  314. if (App.get('isHaEnabled')) {
  315. configs = serviceConfigs.findProperty('serviceName', 'HDFS').configs;
  316. var removedConfigs = configs.filterProperty('category', 'SNameNode');
  317. removedConfigs.map(function(config) {
  318. configs = configs.without(config);
  319. });
  320. serviceConfigs.findProperty('serviceName', 'HDFS').configs = configs;
  321. }
  322. }
  323. this.set('stepConfigs', serviceConfigs);
  324. if (App.supports.hostOverridesInstaller) {
  325. this.loadConfigGroups(this.get('content.configGroups'));
  326. var installedServicesConfigs = this.get('stepConfigs').filterProperty('selected', false);
  327. if (installedServicesConfigs.length > 0 && !storedConfigs)
  328. this.loadInstalledServicesConfigGroups(installedServicesConfigs.mapProperty('serviceName'));
  329. }
  330. this.activateSpecialConfigs();
  331. this.set('selectedService', this.get('stepConfigs').filterProperty('showConfig', true).objectAt(0));
  332. if (this.get('content.skipConfigStep')) {
  333. App.router.send('next');
  334. }
  335. },
  336. setGroupsToDelete: function(groups) {
  337. var groupsToDelete = this.get('groupsToDelete');
  338. groups.forEach(function(group) {
  339. if (group.get('id'))
  340. groupsToDelete.push({
  341. id: group.get('id')
  342. });
  343. });
  344. this.get('wizardController').setDBProperty('groupsToDelete', groupsToDelete);
  345. },
  346. selectedServiceObserver: function () {
  347. if (App.supports.hostOverridesInstaller && this.get('selectedService') && (this.get('selectedService.serviceName') !== 'MISC')) {
  348. var serviceGroups = this.get('selectedService.configGroups');
  349. serviceGroups.forEach(function (item, index, array) {
  350. if (item.isDefault) {
  351. array.unshift(item);
  352. array.splice(index + 1, 1);
  353. }
  354. });
  355. this.set('configGroups', serviceGroups);
  356. this.set('selectedConfigGroup', serviceGroups.findProperty('isDefault'));
  357. }
  358. }.observes('selectedService.configGroups.@each'),
  359. /**
  360. * load default groups for each service in case of initial load
  361. * @param serviceConfigGroups
  362. */
  363. loadConfigGroups: function (serviceConfigGroups) {
  364. var services = this.get('stepConfigs');
  365. var hosts = this.get('getAllHosts').mapProperty('hostName');
  366. services.forEach(function (service) {
  367. if (service.get('serviceName') === 'MISC') return;
  368. var serviceRawGroups = serviceConfigGroups.filterProperty('service.id', service.serviceName);
  369. if (!serviceRawGroups.length) {
  370. service.set('configGroups', [
  371. App.ConfigGroup.create({
  372. name: App.Service.DisplayNames[service.serviceName] + " Default",
  373. description: "Default cluster level " + service.serviceName + " configuration",
  374. isDefault: true,
  375. hosts: Em.copy(hosts),
  376. service: Em.Object.create({
  377. id: service.serviceName
  378. }),
  379. serviceName: service.serviceName
  380. })
  381. ]);
  382. } else {
  383. var defaultGroup = App.ConfigGroup.create(serviceRawGroups.findProperty('isDefault'));
  384. var serviceGroups = service.get('configGroups');
  385. serviceRawGroups.filterProperty('isDefault', false).forEach(function (configGroup) {
  386. var readyGroup = App.ConfigGroup.create(configGroup);
  387. var wrappedProperties = [];
  388. readyGroup.get('properties').forEach(function(property){
  389. wrappedProperties.pushObject(App.ServiceConfigProperty.create(property));
  390. });
  391. wrappedProperties.setEach('group', readyGroup);
  392. readyGroup.set('properties', wrappedProperties);
  393. readyGroup.set('parentConfigGroup', defaultGroup);
  394. serviceGroups.pushObject(readyGroup);
  395. });
  396. defaultGroup.set('childConfigGroups', serviceGroups);
  397. serviceGroups.pushObject(defaultGroup);
  398. }
  399. });
  400. },
  401. selectConfigGroup: function (event) {
  402. this.set('selectedConfigGroup', event.context);
  403. },
  404. /**
  405. * rebuild list of configs switch of config group:
  406. * on default - display all configs from default group and configs from non-default groups as disabled
  407. * on non-default - display all from default group as disabled and configs from selected non-default group
  408. */
  409. switchConfigGroupConfigs: function () {
  410. var serviceConfigs = this.get('selectedService.configs');
  411. var selectedGroup = this.get('selectedConfigGroup');
  412. var overrideToAdd = this.get('overrideToAdd');
  413. if(!selectedGroup) return;
  414. var displayedConfigGroups = (selectedGroup.get('isDefault')) ?
  415. this.get('selectedService.configGroups').filterProperty('isDefault', false) :
  416. [this.get('selectedConfigGroup')];
  417. var overrides = [];
  418. displayedConfigGroups.forEach(function (group) {
  419. overrides.pushObjects(group.get('properties'));
  420. });
  421. serviceConfigs.forEach(function (config) {
  422. var configOverrides = overrides.filterProperty('name', config.get('name'));
  423. config.set('isEditable', selectedGroup.get('isDefault'));
  424. if (overrideToAdd && overrideToAdd.get('name') === config.get('name')) {
  425. configOverrides.push(this.addOverrideProperty(config));
  426. this.set('overrideToAdd', null);
  427. }
  428. configOverrides.setEach('isEditable', !selectedGroup.get('isDefault'));
  429. configOverrides.setEach('parentSCP', config);
  430. config.set('overrides', configOverrides);
  431. }, this);
  432. }.observes('selectedConfigGroup'),
  433. /**
  434. * create overriden property and push it into Config group
  435. * @param serviceConfigProperty
  436. * @return {*}
  437. */
  438. addOverrideProperty: function (serviceConfigProperty) {
  439. var overrides = serviceConfigProperty.get('overrides') || [];
  440. var newSCP = App.ServiceConfigProperty.create(serviceConfigProperty);
  441. var group = this.get('selectedService.configGroups').findProperty('name', this.get('selectedConfigGroup.name'));
  442. newSCP.set('group', group);
  443. newSCP.set('value', '');
  444. newSCP.set('isOriginalSCP', false); // indicated this is overridden value,
  445. newSCP.set('parentSCP', serviceConfigProperty);
  446. newSCP.set('isEditable', true);
  447. group.get('properties').pushObject(newSCP);
  448. overrides.pushObject(newSCP);
  449. return newSCP;
  450. },
  451. manageConfigurationGroup: function () {
  452. App.router.get('mainServiceInfoConfigsController').manageConfigurationGroups(this);
  453. },
  454. /**
  455. * Filter text will be located here
  456. */
  457. filter: '',
  458. /**
  459. * Dropdown menu items in filter combobox
  460. */
  461. filterColumns: function () {
  462. var result = [];
  463. for (var i = 1; i < 2; i++) {
  464. result.push(Ember.Object.create({
  465. name: this.t('common.combobox.dropdown.' + i),
  466. selected: false
  467. }));
  468. }
  469. return result;
  470. }.property(),
  471. /**
  472. * make some configs visible depending on active services
  473. */
  474. activateSpecialConfigs: function () {
  475. var miscConfigs = this.get('stepConfigs').findProperty('serviceName', 'MISC').configs;
  476. miscConfigs = App.config.miscConfigVisibleProperty(miscConfigs, this.get('selectedServiceNames'));
  477. },
  478. /**
  479. * @param: An array of display names
  480. */
  481. setDisplayMessage: function (siteProperty, displayNames) {
  482. var displayMsg = null;
  483. if (displayNames && displayNames.length) {
  484. if (displayNames.length === 1) {
  485. displayMsg = siteProperty + ' ' + Em.I18n.t('as') + ' ' + displayNames[0];
  486. } else {
  487. var name = null;
  488. displayNames.forEach(function (_name, index) {
  489. if (index === 0) {
  490. name = _name;
  491. } else if (index === displayNames.length - 1) {
  492. name = name + ' ' + Em.I18n.t('and') + ' ' + _name;
  493. } else {
  494. name = name + ', ' + _name;
  495. }
  496. }, this);
  497. displayMsg = siteProperty + ' ' + Em.I18n.t('as') + ' ' + name;
  498. }
  499. } else {
  500. displayMsg = siteProperty;
  501. }
  502. return displayMsg;
  503. },
  504. /**
  505. * Set display names of the property tfrom he puppet/global names
  506. * @param displayNames: a field to be set with displayNames
  507. * @param names: array of property puppet/global names
  508. * @param configProperties: array of config properties of the respective service to the name param
  509. */
  510. setPropertyDisplayNames: function (displayNames, names, configProperties) {
  511. names.forEach(function (_name, index) {
  512. if (configProperties.someProperty('name', _name)) {
  513. displayNames.push(configProperties.findProperty('name', _name).displayName);
  514. }
  515. }, this);
  516. },
  517. /**
  518. * Display Error Message with service name, its custom configuration name and displaynames on the page
  519. * @param customConfig: array with custom configuration, serviceName and displayNames relative to custom configuration
  520. */
  521. showCustomConfigErrMsg: function (customConfig) {
  522. App.ModalPopup.show({
  523. header: Em.I18n.t('installer.step7.ConfigErrMsg.header'),
  524. primary: Em.I18n.t('ok'),
  525. secondary: null,
  526. bodyClass: Ember.View.extend({
  527. message: Em.I18n.t('installer.step7.ConfigErrMsg.message'),
  528. siteProperties: customConfig,
  529. getDisplayMessage: function () {
  530. }.property('customConfig.@each.siteProperties.@each.siteProperty'),
  531. customConfig: customConfig,
  532. templateName: require('templates/wizard/step7_custom_config_error')
  533. })
  534. });
  535. },
  536. submit: function () {
  537. if (!this.get('isSubmitDisabled')) {
  538. App.router.send('next');
  539. }
  540. },
  541. /**
  542. * Provides service component name and display-name information for
  543. * the current selected service.
  544. */
  545. getCurrentServiceComponents: function () {
  546. var selectedServiceName = this.get('selectedService.serviceName');
  547. var masterComponents = this.get('content.masterComponentHosts');
  548. var slaveComponents = this.get('content.slaveComponentHosts');
  549. var scMaps = require('data/service_components');
  550. var validComponents = Ember.A([]);
  551. var seenComponents = {};
  552. masterComponents.forEach(function(component){
  553. var cn = component.component
  554. var cdn = component.display_name;
  555. if(component.serviceId===selectedServiceName && !seenComponents[cn]){
  556. validComponents.pushObject(Ember.Object.create({
  557. componentName: cn,
  558. displayName: cdn,
  559. selected: false
  560. }));
  561. seenComponents[cn] = cn;
  562. }
  563. });
  564. slaveComponents.forEach(function(component){
  565. var cn = component.componentName
  566. var cdn = component.displayName;
  567. var componentDef = scMaps.findProperty('component_name', cn);
  568. if(componentDef!=null && selectedServiceName===componentDef.service_name && !seenComponents[cn]){
  569. validComponents.pushObject(Ember.Object.create({
  570. componentName: cn,
  571. displayName: cdn,
  572. selected: false
  573. }));
  574. seenComponents[cn] = cn;
  575. }
  576. });
  577. return validComponents;
  578. }.property('content'),
  579. getAllHosts: function () {
  580. if (App.Host.find().content.length > 0) {
  581. return App.Host.find();
  582. }
  583. var hosts = this.get('content.hosts');
  584. var masterComponents = this.get('content.masterComponentHosts');
  585. var slaveComponents = this.get('content.slaveComponentHosts');
  586. masterComponents.forEach(function (component) {
  587. App.HostComponent.createRecord({
  588. id: component.component + '_' + component.hostName,
  589. componentName: component.component,
  590. host_id: component.hostName
  591. });
  592. if (!hosts[component.hostName].hostComponents) {
  593. hosts[component.hostName].hostComponents = [];
  594. }
  595. hosts[component.hostName].hostComponents.push(component.component + '_' + component.hostName);
  596. });
  597. slaveComponents.forEach(function (component) {
  598. component.hosts.forEach(function (host) {
  599. App.HostComponent.createRecord({
  600. id: component.componentName + '_' + host.hostName,
  601. componentName: component.componentName,
  602. host_id: host.hostName
  603. });
  604. if (!hosts[host.hostName].hostComponents) {
  605. hosts[host.hostName].hostComponents = [];
  606. }
  607. hosts[host.hostName].hostComponents.push(component.componentName + '_' + host.hostName);
  608. });
  609. });
  610. for (var hostName in hosts) {
  611. var host = hosts[hostName];
  612. var disksOverallCapacity = 0;
  613. var diskFree = 0;
  614. host.disk_info.forEach(function(disk) {
  615. disksOverallCapacity += parseFloat(disk.size);
  616. diskFree += parseFloat(disk.available);
  617. });
  618. App.store.load(App.Host,
  619. {
  620. id: host.name,
  621. ip: host.ip,
  622. os_type: host.os_type,
  623. os_arch: host.os_arch,
  624. host_name: host.name,
  625. public_host_name: host.name,
  626. cpu: host.cpu,
  627. memory: host.memory,
  628. disk_info: host.disk_info,
  629. disk_total: disksOverallCapacity / (1024 * 1024),
  630. disk_free: diskFree / (1024 * 1024),
  631. host_components: host.hostComponents
  632. }
  633. )
  634. }
  635. return App.Host.find();
  636. }.property('content.hosts')
  637. });