Repository: ambari Updated Branches: refs/heads/trunk b098be07b -> e2853962c
AMBARI-7473: (EC2)'Manage Configuration Groups' window and 'Select Configuration Group Hosts' window contains not same host names (Buzhor Denys via alexantonenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/e2853962 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e2853962 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e2853962 Branch: refs/heads/trunk Commit: e2853962c5e0256303b95653a40ff04154caf61b Parents: b098be0 Author: Alex Antonenko <[email protected]> Authored: Fri Sep 26 20:11:07 2014 +0300 Committer: Alex Antonenko <[email protected]> Committed: Fri Sep 26 20:11:07 2014 +0300 ---------------------------------------------------------------------- .../service/manage_config_groups_controller.js | 57 ++++++++++++++++++-- ambari-web/app/controllers/wizard.js | 1 + .../app/controllers/wizard/step7_controller.js | 14 ++++- ambari-web/app/models/config_group.js | 5 ++ .../manage_configuration_groups_popup.hbs | 2 +- 5 files changed, 72 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/e2853962/ambari-web/app/controllers/main/service/manage_config_groups_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/service/manage_config_groups_controller.js b/ambari-web/app/controllers/main/service/manage_config_groups_controller.js index 76b7005..56c77f4 100644 --- a/ambari-web/app/controllers/main/service/manage_config_groups_controller.js +++ b/ambari-web/app/controllers/main/service/manage_config_groups_controller.js @@ -176,6 +176,7 @@ App.ManageConfigGroupsController = Em.Controller.extend({ data.items.forEach(function (configGroup) { configGroup = configGroup.ConfigGroup; var hostNames = configGroup.hosts.mapProperty('host_name'); + var publicHostNames = this.hostsToPublic(hostNames); var newConfigGroup = App.ConfigGroup.create({ id: configGroup.id, name: configGroup.group_name, @@ -184,6 +185,7 @@ App.ManageConfigGroupsController = Em.Controller.extend({ parentConfigGroup: defaultConfigGroup, service: App.Service.find().findProperty('serviceName', configGroup.tag), hosts: hostNames, + publicHosts: publicHostNames, configSiteTags: [], properties: [], apiResponse: configGroup @@ -208,6 +210,7 @@ App.ManageConfigGroupsController = Em.Controller.extend({ }, this); defaultConfigGroup.set('childConfigGroups', configGroups); defaultConfigGroup.set('hosts', unusedHosts); + defaultConfigGroup.set('publicHosts', this.hostsToPublic(unusedHosts)); var allGroups = [defaultConfigGroup].concat(configGroups); this.set('configGroups', allGroups); var originalGroups = this.copyConfigGroups(allGroups); @@ -216,6 +219,43 @@ App.ManageConfigGroupsController = Em.Controller.extend({ this.set('isLoaded', true); } }, + /** + * Get public_host_name by host_name. + * + * @param {Array|String} hostsList + * @return {Array|String} + **/ + hostsToPublic: function(hostsList) { + return this.convertHostNames(hostsList, true); + }, + /** + * Get host_name by public_host_name + * + * @param {Array|String} hostsList + * @return {Array|String} + **/ + publicToHostName: function(hostsList) { + return this.convertHostNames(hostsList, false); + }, + /*** + * Switch between public_host_name and host_name + * + * @param {Array|String} hostsList + * @param {Boolean} toPublic + * @return {Array|String} + **/ + convertHostNames: function(hostsList, toPublic) { + var allHosts = this.get('clusterHosts'); + var convertTarget = !!toPublic ? + { from: 'hostName', to: 'publicHostName' } : { from: 'publicHostName', to: 'hostName'}; + if (this.get('isInstaller')) { + allHosts = App.router.get(!!this.get('isAddService') ? 'addServiceController' : 'installerController').get('allHosts'); + } + if (typeof hostsList == 'string') return allHosts.findProperty(convertTarget.from, hostsList).get(convertTarget.to); + return hostsList.map(function(hostName) { + return allHosts.findProperty(convertTarget.from, hostName).get(convertTarget.to); + }, this); + }, onLoadConfigGroupsError: function () { console.error('Unable to load config groups for service.'); @@ -286,12 +326,16 @@ App.ManageConfigGroupsController = Em.Controller.extend({ var group = this.get('selectedConfigGroup'); if (selectedHosts) { var defaultHosts = group.get('parentConfigGroup.hosts').slice(); + var defaultPublicHosts = group.get('parentConfigGroup.publicHosts').slice(); var configGroupHosts = group.get('hosts'); selectedHosts.forEach(function (hostName) { configGroupHosts.pushObject(hostName); + group.get('publicHosts').pushObject(this.hostsToPublic(hostName)); defaultHosts.removeObject(hostName); - }); + defaultPublicHosts.removeObject(this.hostsToPublic(hostName)); + }, this); group.set('parentConfigGroup.hosts', defaultHosts); + group.set('parentConfigGroup.publicHosts', this.hostsToPublic(defaultHosts)); } }, @@ -304,11 +348,15 @@ App.ManageConfigGroupsController = Em.Controller.extend({ } var groupHosts = this.get('selectedConfigGroup.hosts'); var defaultGroupHosts = this.get('selectedConfigGroup.parentConfigGroup.hosts').slice(); + var defaultGroupPublicHosts = this.get('selectedConfigGroup.parentConfigGroup.publicHosts').slice(); this.get('selectedHosts').slice().forEach(function (hostName) { - defaultGroupHosts.pushObject(hostName); - groupHosts.removeObject(hostName); - }); + defaultGroupHosts.pushObject(this.publicToHostName(hostName)); + defaultGroupPublicHosts.pushObject(hostName); + groupHosts.removeObject(this.publicToHostName(hostName)); + this.get('selectedConfigGroup.publicHosts').removeObject(hostName); + }, this); this.set('selectedConfigGroup.parentConfigGroup.hosts', defaultGroupHosts); + this.set('selectedConfigGroup.parentConfigGroup.publicHosts', this.hostsToPublic(defaultGroupHosts)); this.set('selectedHosts', []); }, @@ -450,6 +498,7 @@ App.ManageConfigGroupsController = Em.Controller.extend({ parentConfigGroup: defaultConfigGroup, service: Em.Object.create({id: self.get('serviceName')}), hosts: [], + publicHosts: [], configSiteTags: [], properties: [] }); http://git-wip-us.apache.org/repos/asf/ambari/blob/e2853962/ambari-web/app/controllers/wizard.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js index 7815b4e..7cc52aa 100644 --- a/ambari-web/app/controllers/wizard.js +++ b/ambari-web/app/controllers/wizard.js @@ -909,6 +909,7 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, { name: configGroup.get('name'), description: configGroup.get('description'), hosts: hostNames, + publicHosts: configGroup.get('hosts').map(function(hostName) {return App.router.get('manageConfigGroupsController').hostsToPublic(hostName); }), properties: properties, isDefault: configGroup.get('isDefault'), isForInstalledService: isForInstalledService, http://git-wip-us.apache.org/repos/asf/ambari/blob/e2853962/ambari-web/app/controllers/wizard/step7_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js index 15e6d9f..ec78120 100644 --- a/ambari-web/app/controllers/wizard/step7_controller.js +++ b/ambari-web/app/controllers/wizard/step7_controller.js @@ -318,8 +318,8 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, { service = this.get('stepConfigs').findProperty('serviceName', serviceName), defaultConfigGroupHosts = this.get('wizardController.allHosts').mapProperty('hostName'), siteToTagMap = this._createSiteToTagMap(data.Clusters.desired_configs, params.serviceConfigsDef.get('configTypes')), - selectedConfigGroup; - + selectedConfigGroup, + manageCGController = App.router.get('manageConfigGroupsController'); this.set('loadedClusterSiteToTagMap', siteToTagMap); //parse loaded config groups @@ -338,6 +338,7 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, { parentConfigGroup: null, service: App.Service.find().findProperty('serviceName', item.tag), hosts: groupHosts, + publicHosts: manageCGController.hostsToPublic(groupHosts), configSiteTags: [] }); groupHosts.forEach(function (host) { @@ -359,6 +360,7 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, { description: "Default cluster level " + serviceName + " configuration", isDefault: true, hosts: defaultConfigGroupHosts, + publicHosts: manageCGController.hostsToPublic(defaultConfigGroupHosts), parentConfigGroup: null, service: Em.Object.create({ id: serviceName @@ -1013,6 +1015,8 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, { loadConfigGroups: function (serviceConfigGroups) { var services = this.get('stepConfigs'); var hosts = this.get('wizardController.allHosts').mapProperty('hostName'); + var manageCGController = App.router.get('manageConfigGroupsController'); + this.setupManageConfigGroupsController(); services.forEach(function (service) { if (service.get('serviceName') === 'MISC') return; var serviceRawGroups = serviceConfigGroups.filterProperty('service.id', service.serviceName); @@ -1023,6 +1027,7 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, { description: "Default cluster level " + service.serviceName + " configuration", isDefault: true, hosts: Em.copy(hosts), + publicHosts: Em.copy(manageCGController.hostsToPublic(hosts)), service: Em.Object.create({ id: service.serviceName }), @@ -1056,6 +1061,11 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, { }); }, + setupManageConfigGroupsController: function() { + var manageCGController = App.router.get('manageConfigGroupsController'); + manageCGController.set('isInstaller', true); + manageCGController.set('isAddService', this.get('wizardController.name') === 'addServiceController'); + }, /** * Click-handler on config-group to make it selected * @param {object} event http://git-wip-us.apache.org/repos/asf/ambari/blob/e2853962/ambari-web/app/models/config_group.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/config_group.js b/ambari-web/app/models/config_group.js index edb3d34..7285a7c 100644 --- a/ambari-web/app/models/config_group.js +++ b/ambari-web/app/models/config_group.js @@ -82,6 +82,11 @@ App.ConfigGroup = Ember.Object.extend({ hosts: [], /** + * Public host names related by host_name. + */ + publicHosts: [], + + /** * this flag is used for installed services' config groups * if user make changes to them - mark this flag to true */ http://git-wip-us.apache.org/repos/asf/ambari/blob/e2853962/ambari-web/app/templates/main/service/manage_configuration_groups_popup.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/service/manage_configuration_groups_popup.hbs b/ambari-web/app/templates/main/service/manage_configuration_groups_popup.hbs index c99622f..f8a10f5 100644 --- a/ambari-web/app/templates/main/service/manage_configuration_groups_popup.hbs +++ b/ambari-web/app/templates/main/service/manage_configuration_groups_popup.hbs @@ -54,7 +54,7 @@ <div class="row-fluid"> <div class="span12 pull-right"> {{view Em.Select - contentBinding="selectedConfigGroup.hosts" + contentBinding="selectedConfigGroup.publicHosts" multiple="multiple" class="group-select" selectionBinding="selectedHosts"
