You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by at...@apache.org on 2015/08/26 17:05:06 UTC
ambari git commit: AMBARI-12880 Manage config group popup should use
Model objects. (atkach)
Repository: ambari
Updated Branches:
refs/heads/trunk 5d159a376 -> 7819edfd1
AMBARI-12880 Manage config group popup should use Model objects. (atkach)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/7819edfd
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7819edfd
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7819edfd
Branch: refs/heads/trunk
Commit: 7819edfd176c96e3471632363e3e53febed76d1c
Parents: 5d159a3
Author: Andrii Tkach <at...@hortonworks.com>
Authored: Wed Aug 26 18:04:48 2015 +0300
Committer: Andrii Tkach <at...@hortonworks.com>
Committed: Wed Aug 26 18:04:48 2015 +0300
----------------------------------------------------------------------
ambari-web/app/assets/test/tests.js | 1 -
.../service/manage_config_groups_controller.js | 269 +++++++++----------
ambari-web/app/controllers/wizard.js | 17 +-
.../app/controllers/wizard/step7_controller.js | 101 +++----
.../app/controllers/wizard/step8_controller.js | 6 +-
.../app/mappers/configs/config_groups_mapper.js | 19 +-
.../main/service/configs/config_overridable.js | 65 ++---
.../app/mixins/main/service/groups_mapping.js | 1 +
ambari-web/app/models.js | 1 -
ambari-web/app/models/config_group.js | 172 ------------
ambari-web/app/models/configs/config_group.js | 51 ++--
.../main/service/manage_config_groups_view.js | 4 +-
.../manage_config_groups_controller_test.js | 6 +-
.../test/controllers/wizard/step7_test.js | 57 +---
.../test/controllers/wizard/step8_test.js | 4 +-
.../common/configs/enhanced_configs_test.js | 2 +-
ambari-web/test/models/config_group_test.js | 159 -----------
ambari-web/test/utils/config_test.js | 2 +-
18 files changed, 244 insertions(+), 693 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/7819edfd/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index 1888690..d5f4450 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -280,7 +280,6 @@ var files = ['test/init_model_test',
'test/models/alerts/alert_instance_test',
'test/models/authentication_test',
'test/models/cluster_states_test',
- 'test/models/config_group_test',
'test/models/form_test',
'test/models/host_test',
'test/models/host_component_test',
http://git-wip-us.apache.org/repos/asf/ambari/blob/7819edfd/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 945c414..a2f9628 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
@@ -63,21 +63,6 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
originalConfigGroups: [],
/**
- * map of <code>originalConfigGroups</code>
- * @type {object}
- */
- originalConfigGroupsMap: function() {
- var map = {};
-
- this.get('originalConfigGroups').forEach(function (item) {
- if (!item.get('isDefault')) {
- map[item.get('id')] = item;
- }
- }, this);
- return map;
- }.property('originalConfigGroups'),
-
- /**
* @type {App.ConfigGroup}
*/
selectedConfigGroup: null,
@@ -169,40 +154,55 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
var groupsToSetHosts = [];
var groupsToCreate = [];
var groups = this.get('configGroups');
- var originalGroups = this.get('originalConfigGroups');
- var originalGroupsMap = this.get('originalConfigGroupsMap');
-
- // remove default group
- var originalGroupsCopy = originalGroups.without(originalGroups.findProperty('isDefault'));
- var originalGroupsIds = originalGroupsCopy.mapProperty('id');
- groups.forEach(function (group) {
- if (!group.get('isDefault')) {
- var originalGroup = originalGroupsMap[group.get('id')];
+ var originalGroups = [];
+ var originalGroupsMap = {};
+
+ this.get('originalConfigGroups').forEach(function(item){
+ if (!item.is_default) {
+ originalGroupsMap[item.id] = item;
+ originalGroups.push(item);
+ }
+ }, this);
+
+ groups.forEach(function (groupRecord) {
+ if (!groupRecord.get('isDefault')) {
+ var originalGroup = originalGroupsMap[groupRecord.get('id')];
if (originalGroup) {
- if (!(JSON.stringify(group.get('hosts').slice().sort()) === JSON.stringify(originalGroup.get('hosts').sort()))) {
- groupsToClearHosts.push(group.set('id', originalGroup.get('id')));
- if (group.get('hosts').length) {
- groupsToSetHosts.push(group.set('id', originalGroup.get('id')));
+ if (!(JSON.stringify(groupRecord.get('hosts').slice().sort()) === JSON.stringify(originalGroup.hosts.sort()))) {
+ groupsToClearHosts.push(groupRecord);
+ if (groupRecord.get('hosts').length) {
+ groupsToSetHosts.push(groupRecord);
}
// should update name or description
- } else if (group.get('description') !== originalGroup.get('description') || group.get('name') !== originalGroup.get('name') ) {
- groupsToSetHosts.push(group.set('id', originalGroup.get('id')));
+ } else if (groupRecord.get('description') !== originalGroup.description || groupRecord.get('name') !== originalGroup.name) {
+ groupsToSetHosts.push(groupRecord);
}
- originalGroupsIds = originalGroupsIds.without(group.get('id'));
+ delete originalGroupsMap[groupRecord.get('id')];
} else {
- groupsToCreate.push(group);
+ groupsToCreate.push({
+ id: groupRecord.get('id'),
+ config_group_id: groupRecord.get('configGroupId'),
+ name: groupRecord.get('name'),
+ description: groupRecord.get('description'),
+ hosts: groupRecord.get('hosts').slice(0),
+ service_id: groupRecord.get('serviceName'),
+ desired_configs: groupRecord.get('desiredConfigs')
+ });
}
}
});
- originalGroupsIds.forEach(function (id) {
- groupsToDelete.push(originalGroupsMap[id]);
- }, this);
+
+ //groups to delete
+ for (var id in originalGroupsMap) {
+ groupsToDelete.push(App.ServiceConfigGroup.find(id));
+ }
+
this.set('hostsModifiedConfigGroups', {
toClearHosts: groupsToClearHosts,
toDelete: groupsToDelete,
toSetHosts: groupsToSetHosts,
toCreate: groupsToCreate,
- initialGroups: originalGroupsCopy
+ initialGroups: originalGroups
});
},
@@ -340,9 +340,8 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
*/
loadConfigGroups: function (serviceName) {
if (this.get('isInstaller')) {
- this.set('serviceName', serviceName);
- var configGroups = this.copyConfigGroups(App.router.get('wizardStep7Controller.selectedService.configGroups'));
- var originalConfigGroups = this.copyConfigGroups(configGroups);
+ var configGroups = App.router.get('wizardStep7Controller.selectedService.configGroups').slice(0);
+ var originalConfigGroups = this.generateOriginalConfigGroups(configGroups);
this.setProperties({
configGroups: configGroups,
originalConfigGroups: originalConfigGroups,
@@ -369,63 +368,53 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
* @method _onLoadConfigGroupsSuccess
*/
_onLoadConfigGroupsSuccess: function (data) {
- var usedHosts = [];
- var unusedHosts = [];
var serviceName = this.get('serviceName');
- var defaultConfigGroup = App.ConfigGroup.create({
- name: App.format.role(serviceName) + " Default",
- description: "Default cluster level " + serviceName + " configuration",
- isDefault: true,
- parentConfigGroup: null,
- service: this.get('content'),
- configSiteTags: [],
- serviceName: serviceName
- });
- if (data && data.items) {
- var groupToTypeToTagMap = {};
- var configGroups = [];
- data.items.forEach(function (configGroup) {
- configGroup = configGroup.ConfigGroup;
- var hostNames = configGroup.hosts.mapProperty('host_name');
- var newConfigGroup = App.ConfigGroup.create({
- id: configGroup.id,
- name: configGroup.group_name,
- description: configGroup.description,
- isDefault: false,
- parentConfigGroup: defaultConfigGroup,
- service: App.Service.find(configGroup.tag),
- hosts: hostNames,
- configSiteTags: configGroup.desired_configs.map(function (config) {
- if (!groupToTypeToTagMap[configGroup.group_name]) {
- groupToTypeToTagMap[configGroup.group_name] = {}
- }
- groupToTypeToTagMap[configGroup.group_name][config.type] = config.tag;
+ App.configGroupsMapper.map(data, false, [serviceName]);
- return App.ConfigSiteTag.create({
- site: config.type,
- tag: config.tag
- });
- }),
- properties: [],
- apiResponse: configGroup
+ var configGroups = App.ServiceConfigGroup.find().filterProperty('serviceName', serviceName);
+ var rawConfigGroups = this.generateOriginalConfigGroups(configGroups);
+ var groupToTypeToTagMap = {};
+
+ rawConfigGroups.forEach(function (item) {
+ if (Array.isArray(item.desired_configs)) {
+ item.desired_configs.forEach(function (config) {
+ if (!groupToTypeToTagMap[item.name]) {
+ groupToTypeToTagMap[item.name] = {};
+ }
+ groupToTypeToTagMap[item.name][config.type] = config.tag;
});
- usedHosts = usedHosts.concat(hostNames);
- configGroups.push(newConfigGroup);
- }, this);
- unusedHosts = App.get('allHostNames').slice(0);
- usedHosts.uniq().forEach(function (host) {
- unusedHosts = unusedHosts.without(host);
- }, this);
- defaultConfigGroup.set('childConfigGroups', configGroups);
- defaultConfigGroup.set('hosts', unusedHosts);
- var allGroups = [defaultConfigGroup].concat(configGroups);
- this.set('configGroups', allGroups);
- var originalGroups = this.copyConfigGroups(allGroups);
- this.set('originalConfigGroups', originalGroups);
- this.loadProperties(groupToTypeToTagMap);
- this.set('isLoaded', true);
- }
+ }
+ });
+
+ this.set('configGroups', configGroups);
+ this.set('originalConfigGroups', rawConfigGroups);
+ this.loadProperties(groupToTypeToTagMap);
+ this.set('isLoaded', true);
+ },
+
+ /**
+ *
+ * @param {Array} configGroups
+ * @returns {Array}
+ */
+ generateOriginalConfigGroups: function(configGroups) {
+ return configGroups.map(function (item) {
+ return {
+ id: item.get('id'),
+ config_group_id: item.get('configGroupId'),
+ name: item.get('name'),
+ service_name: item.get('serviceName'),
+ description: item.get('description'),
+ hosts: item.get('hosts').slice(0),
+ service_id: item.get('serviceName'),
+ desired_configs: item.get('desiredConfigs'),
+ is_default: item.get('isDefault'),
+ child_config_groups: item.get('childConfigGroups') ? item.get('childConfigGroups').mapProperty('id') : [],
+ parent_config_group_id: item.get('parentConfigGroup.id'),
+ properties: item.get('properties')
+ };
+ });
},
/**
@@ -471,12 +460,12 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
var typeTagConfigs = [];
var group = params.typeTagToGroupMap[configs.type + "///" + configs.tag];
for (var config in configs.properties) {
- typeTagConfigs.push(Em.Object.create({
+ typeTagConfigs.push({
name: config,
value: configs.properties[config]
- }));
+ });
}
- this.get('configGroups').findProperty('name', group).get('properties').pushObjects(typeTagConfigs);
+ this.get('configGroups').findProperty('name', group).set('properties', typeTagConfigs);
}, this);
},
@@ -628,9 +617,6 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
onPrimary: function () {
self.set('selectedConfigGroup.name', this.get('configGroupName'));
self.set('selectedConfigGroup.description', this.get('configGroupDesc'));
- self.get('selectedConfigGroup.properties').forEach(function(property){
- property.set('group', self.get('selectedConfigGroup'));
- });
this.hide();
}
});
@@ -684,29 +670,36 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
onPrimary: function () {
var defaultConfigGroup = self.get('configGroups').findProperty('isDefault');
var properties = [];
- var newConfigGroupData = App.ConfigGroup.create({
- id: null,
+ var serviceName = self.get('serviceName');
+ //temporarily id until real assigned by server
+ var newGroupId = serviceName + "_NEW_" + self.get('configGroups.length');
+
+ App.store.load(App.ServiceConfigGroup, {
+ id: newGroupId,
name: this.get('configGroupName').trim(),
description: this.get('configGroupDesc'),
isDefault: false,
- parentConfigGroup: defaultConfigGroup,
- service: Em.Object.create({id: self.get('serviceName')}),
+ parent_config_group_id: App.ServiceConfigGroup.getParentConfigGroupId(serviceName),
+ service_id: serviceName,
+ service_name: serviceName,
hosts: [],
configSiteTags: [],
properties: []
});
+ App.store.commit();
+ var childConfigGroups = defaultConfigGroup.get('childConfigGroups').mapProperty('id');
+ childConfigGroups.push(newGroupId);
+ App.store.load(App.ServiceConfigGroup, App.configGroupsMapper.generateDefaultGroup(self.get('serviceName'), defaultConfigGroup.get('hosts'), childConfigGroups));
+ App.store.commit();
if (duplicated) {
- self.get('selectedConfigGroup.properties').forEach(function(property) {
- var property = App.ServiceConfigProperty.create($.extend(false, {}, property));
- property.set('group', newConfigGroupData);
+ self.get('selectedConfigGroup.properties').forEach(function(item) {
+ var property = App.ServiceConfigProperty.create($.extend(false, {}, item));
+ property.set('group', App.ServiceConfigGroup.find(newGroupId));
properties.push(property);
});
- newConfigGroupData.set('properties', properties);
- } else {
- newConfigGroupData.set('properties', []);
+ App.ServiceConfigGroup.find(newGroupId).set('properties', properties);
}
- self.get('configGroups').pushObject(newConfigGroupData);
- defaultConfigGroup.get('childConfigGroups').pushObject(newConfigGroupData);
+ self.get('configGroups').pushObject(App.ServiceConfigGroup.find(newGroupId));
this.hide();
}
});
@@ -722,40 +715,6 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
},
/**
- * copy config groups to manage popup to give user choice whether or not save changes
- * @param originGroups
- * @return {Array}
- * @method copyConfigGroups
- */
- copyConfigGroups: function (originGroups) {
- var configGroups = [];
- var result = [];
- var defaultConfigGroup = App.ConfigGroup.create($.extend(true, {}, originGroups.findProperty('isDefault')));
- originGroups.forEach(function (configGroup) {
- if (!configGroup.get('isDefault')) {
- var copiedGroup = App.ConfigGroup.create($.extend(true, {}, configGroup));
- copiedGroup.set('parentConfigGroup', defaultConfigGroup);
- configGroups.pushObject(copiedGroup);
- }
- });
- defaultConfigGroup.set('childConfigGroups', configGroups.slice());
- configGroups.pushObject(defaultConfigGroup);
- configGroups.forEach(function (group) {
- var groupCopy = {};
- for (var prop in group) {
- if (group.hasOwnProperty(prop)) {
- groupCopy[prop] = group[prop];
- }
- }
- groupCopy.properties.forEach(function(property){
- property.set('group', group);
- });
- result.push(App.ConfigGroup.create(groupCopy));
- }, this);
- return result;
- },
-
- /**
* Show popup with config groups
* User may edit/create/delete them
* @param {Em.Controller} controller
@@ -809,6 +768,25 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
this.hide();
},
+ onClose: function () {
+ this.resetGroupChanges();
+ this._super();
+ },
+
+ onSecondary: function () {
+ this.resetGroupChanges();
+ this._super();
+ },
+
+ resetGroupChanges: function () {
+ if (this.get('subViewController.isHostsModified')) {
+ App.ServiceConfigGroup.find().clear();
+ App.store.commit();
+ App.store.loadMany(App.ServiceConfigGroup, this.get('subViewController.originalConfigGroups'));
+ App.store.commit();
+ }
+ },
+
/**
* run requests which delete config group and clear its hosts
* @param {Function} finishFunction
@@ -825,8 +803,7 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
modifiedConfigGroups.toClearHosts.forEach(function (cg) {
counter++;
- var initialGroupState = modifiedConfigGroups.initialGroups.findProperty('id', cg.get('id'));
- configsController.clearConfigurationGroupHosts(cg, initialGroupState, doneFunction, doneFunction);
+ configsController.updateConfigurationGroup(cg, doneFunction, doneFunction)
}, this);
modifiedConfigGroups.toDelete.forEach(function (cg) {
counter++;
http://git-wip-us.apache.org/repos/asf/ambari/blob/7819edfd/ambari-web/app/controllers/wizard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js
index 0caadeb..98e8078 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -966,12 +966,17 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
id: configGroup.get('id'),
name: configGroup.get('name'),
description: configGroup.get('description'),
- hosts: hostNames,
- properties: properties,
- isDefault: configGroup.get('isDefault'),
- isForInstalledService: isForInstalledService,
- isForUpdate: configGroup.isForUpdate || configGroup.get('hash') != this.getConfigGroupHash(configGroup, hostNames),
- service: {id: configGroup.get('service.id')}
+ hosts: hostNames.slice(),
+ properties: properties.slice(),
+ is_default: configGroup.get('isDefault'),
+ is_for_installed_service: isForInstalledService,
+ is_for_update: configGroup.isForUpdate || configGroup.get('hash') != this.getConfigGroupHash(configGroup, hostNames),
+ service_name: configGroup.get('serviceName'),
+ service_id: configGroup.get('serviceName'),
+ desired_configs: configGroup.get('desiredConfigs'),
+ config_group_id: configGroup.get('configGroupId'),
+ child_config_groups: configGroup.get('childConfigGroups') ? configGroup.get('childConfigGroups').mapProperty('id') : [],
+ parent_config_group_id: configGroup.get('parentConfigGroup.id')
});
}, this)
}, this);
http://git-wip-us.apache.org/repos/asf/ambari/blob/7819edfd/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 67c5ecc..63ce789 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -358,8 +358,7 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E
var serviceName = params.serviceName,
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;
+ siteToTagMap = this._createSiteToTagMap(data.Clusters.desired_configs, params.serviceConfigsDef.get('configTypes'));
this.set('loadedClusterSiteToTagMap', siteToTagMap);
//parse loaded config groups
@@ -369,58 +368,42 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E
item = item.ConfigGroup;
if (item.tag === serviceName) {
var groupHosts = item.hosts.mapProperty('host_name');
- var newConfigGroup = App.ConfigGroup.create({
- id: item.id,
+ configGroups.push({
+ id: serviceName + item.id,
+ config_group_id: item.id,
name: item.group_name,
description: item.description,
- isDefault: false,
- parentConfigGroup: null,
- service: App.Service.find().findProperty('serviceName', item.tag),
+ is_default: false,
+ parent_config_group_id: App.ServiceConfigGroup.getParentConfigGroupId(serviceName),
+ service_id: serviceName,
+ service_name: serviceName,
hosts: groupHosts,
- configSiteTags: []
+ desired_configs: item.desired_configs
});
groupHosts.forEach(function (host) {
defaultConfigGroupHosts = defaultConfigGroupHosts.without(host);
}, this);
- item.desired_configs.forEach(function (config) {
- newConfigGroup.configSiteTags.push(App.ConfigSiteTag.create({
- site: config.type,
- tag: config.tag
- }));
- }, this);
- configGroups.push(newConfigGroup);
}
}, this);
}
- var defaultConfigGroup = App.ConfigGroup.create({
- name: App.format.role(serviceName) + " Default",
- description: "Default cluster level " + serviceName + " configuration",
- isDefault: true,
- hosts: defaultConfigGroupHosts,
- parentConfigGroup: null,
- service: Em.Object.create({
- id: serviceName
- }),
- serviceName: serviceName,
- configSiteTags: []
- });
- if (!selectedConfigGroup) {
- selectedConfigGroup = defaultConfigGroup;
- }
+
+ var defaultConfigGroup = App.configGroupsMapper.generateDefaultGroup(serviceName, defaultConfigGroupHosts);
+
configGroups = configGroups.sortProperty('name');
configGroups.unshift(defaultConfigGroup);
- service.set('configGroups', configGroups);
+ App.store.loadMany(App.ServiceConfigGroup, configGroups);
+ App.store.commit();
+ service.set('configGroups', App.ServiceConfigGroup.find().filterProperty('serviceName', serviceName));
+
var loadedGroupToOverrideSiteToTagMap = {};
- var configGroupsWithOverrides = selectedConfigGroup.get('isDefault') ? service.get('configGroups') : [selectedConfigGroup];
- configGroupsWithOverrides.forEach(function (item) {
- var groupName = item.get('name');
+ configGroups.forEach(function (item) {
+ var groupName = item.name;
loadedGroupToOverrideSiteToTagMap[groupName] = {};
- item.get('configSiteTags').forEach(function (siteTag) {
- var site = siteTag.get('site');
- loadedGroupToOverrideSiteToTagMap[groupName][site] = siteTag.get('tag');
+ item.desired_configs.forEach(function (site) {
+ loadedGroupToOverrideSiteToTagMap[groupName][site.type] = site.tag;
}, this);
}, this);
- this.set('preSelectedConfigGroup', selectedConfigGroup);
+ this.set('preSelectedConfigGroup', App.ServiceConfigGroup.find(App.ServiceConfigGroup.getParentConfigGroupId(serviceName)));
App.config.loadServiceConfigGroupOverrides(service.get('configs'), loadedGroupToOverrideSiteToTagMap, service.get('configGroups'), this.onLoadOverrides, this);
},
@@ -1029,45 +1012,35 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E
loadConfigGroups: function (serviceConfigGroups) {
var services = this.get('stepConfigs');
var hosts = this.get('wizardController.allHosts').mapProperty('hostName');
+
services.forEach(function (service) {
if (service.get('serviceName') === 'MISC') return;
- var serviceRawGroups = serviceConfigGroups.filterProperty('service.id', service.serviceName);
+ var serviceRawGroups = serviceConfigGroups.filterProperty('service_name', service.serviceName);
+ var id = App.ServiceConfigGroup.getParentConfigGroupId(service.get('serviceName'));
if (!serviceRawGroups.length) {
- service.set('configGroups', [
- App.ConfigGroup.create({
- name: service.displayName + " Default",
- description: "Default cluster level " + service.serviceName + " configuration",
- isDefault: true,
- hosts: Em.copy(hosts),
- service: Em.Object.create({
- id: service.serviceName
- }),
- serviceName: service.serviceName
- })
- ]);
+ App.store.load(App.ServiceConfigGroup, App.configGroupsMapper.generateDefaultGroup(service.get('serviceName'), hosts));
+ App.store.commit();
+ service.set('configGroups', [App.ServiceConfigGroup.find(id)]);
}
else {
- var defaultGroup = App.ConfigGroup.create(serviceRawGroups.findProperty('isDefault'));
- var serviceGroups = service.get('configGroups');
- serviceRawGroups.filterProperty('isDefault', false).forEach(function (configGroup) {
- var readyGroup = App.ConfigGroup.create(configGroup);
+ App.store.loadMany(App.ServiceConfigGroup, serviceRawGroups);
+ App.store.commit();
+ serviceRawGroups.forEach(function(item){
+ var modelGroup = App.ServiceConfigGroup.find(item.id);
var wrappedProperties = [];
- readyGroup.get('properties').forEach(function (propertyData) {
+
+ item.properties.forEach(function (propertyData) {
var parentSCP = service.configs.filterProperty('filename', propertyData.filename).findProperty('name', propertyData.name);
var overriddenSCP = App.ServiceConfigProperty.create(parentSCP);
overriddenSCP.set('isOriginalSCP', false);
overriddenSCP.set('parentSCP', parentSCP);
- overriddenSCP.set('group', readyGroup);
+ overriddenSCP.set('group', modelGroup);
overriddenSCP.setProperties(propertyData);
wrappedProperties.pushObject(App.ServiceConfigProperty.create(overriddenSCP));
});
- wrappedProperties.setEach('group', readyGroup);
- readyGroup.set('properties', wrappedProperties);
- readyGroup.set('parentConfigGroup', defaultGroup);
- serviceGroups.pushObject(readyGroup);
- });
- defaultGroup.set('childConfigGroups', serviceGroups);
- serviceGroups.pushObject(defaultGroup);
+ modelGroup.set('properties', wrappedProperties);
+ }, this);
+ service.set('configGroups', App.ServiceConfigGroup.find().filterProperty('serviceName', service.get('serviceName')));
}
});
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/7819edfd/ambari-web/app/controllers/wizard/step8_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step8_controller.js b/ambari-web/app/controllers/wizard/step8_controller.js
index 20f6a30..d03fe1b 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/ambari-web/app/controllers/wizard/step8_controller.js
@@ -1527,7 +1527,7 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz
* @method createConfigurationGroups
*/
createConfigurationGroups: function () {
- var configGroups = this.get('content.configGroups').filterProperty('isDefault', false);
+ var configGroups = this.get('content.configGroups').filterProperty('is_default', false);
var clusterName = this.get('clusterName');
var sendData = [];
var updateData = [];
@@ -1542,7 +1542,7 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz
var groupData = {
"cluster_name": clusterName,
"group_name": configGroup.name,
- "tag": configGroup.service.id,
+ "tag": configGroup.service_id,
"description": configGroup.description,
"hosts": [],
"desired_configs": []
@@ -1562,7 +1562,7 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz
// if group is a new one, create it
if (!configGroup.id) {
sendData.push({"ConfigGroup": groupData});
- } else if (configGroup.isForUpdate){
+ } else if (configGroup.is_for_update){
// update an existing group
groupData.id = configGroup.id;
updateData.push({"ConfigGroup": groupData});
http://git-wip-us.apache.org/repos/asf/ambari/blob/7819edfd/ambari-web/app/mappers/configs/config_groups_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/configs/config_groups_mapper.js b/ambari-web/app/mappers/configs/config_groups_mapper.js
index 48758a7..7a823f5 100644
--- a/ambari-web/app/mappers/configs/config_groups_mapper.js
+++ b/ambari-web/app/mappers/configs/config_groups_mapper.js
@@ -30,7 +30,7 @@ App.configGroupsMapper = App.QuickDataMapper.create({
name: 'ConfigGroup.group_name',
service_name: 'ConfigGroup.tag',
description: 'ConfigGroup.description',
- host_names: 'hosts',
+ hosts: 'hosts',
service_id: 'ConfigGroup.tag',
desired_configs: 'ConfigGroup.desired_configs'
},
@@ -43,7 +43,7 @@ App.configGroupsMapper = App.QuickDataMapper.create({
config_group_id: 'group_id',
name: 'group_name',
service_name: 'service_name',
- host_names: 'hosts',
+ hosts: 'hosts',
service_id: 'service_name'
},
@@ -93,7 +93,7 @@ App.configGroupsMapper = App.QuickDataMapper.create({
hostNamesForService[configGroup.service_name].splice(hostNamesForService[configGroup.service_name].indexOf(host), 1);
});
configGroup = this.parseIt(configGroup, (mapFromVersions ? this.get('config2') : this.get('config')));
- configGroup.parent_config_group_id = configGroup.service_name + '0';
+ configGroup.parent_config_group_id = App.ServiceConfigGroup.getParentConfigGroupId(configGroup.service_name);
configGroups.push(configGroup);
}
}, this);
@@ -124,16 +124,17 @@ App.configGroupsMapper = App.QuickDataMapper.create({
* @returns {{id: string, config_group_id: string, name: string, service_name: string, description: string, host_names: [string], service_id: string}}
*/
generateDefaultGroup: function (serviceName, hostNames, childConfigGroups) {
- var displayName = App.StackService.find(serviceName).get('displayName');
return {
- id: serviceName + '0',
+ id: App.ServiceConfigGroup.getParentConfigGroupId(serviceName),
config_group_id: '-1',
- name: displayName + ' Default',
+ name: App.format.role(serviceName) + ' Default',
service_name: serviceName,
- description: 'Default cluster level ' + displayName + ' configuration',
- host_names: hostNames ? hostNames : App.get('allHostNames'),
+ description: 'Default cluster level ' + App.format.role(serviceName) + ' configuration',
+ hosts: hostNames ? hostNames.slice() : App.get('allHostNames').slice(),
child_config_groups: childConfigGroups ? childConfigGroups.uniq() : [],
- service_id: serviceName
+ service_id: serviceName,
+ desired_configs: [],
+ properties: []
}
}
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/7819edfd/ambari-web/app/mixins/main/service/configs/config_overridable.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/main/service/configs/config_overridable.js b/ambari-web/app/mixins/main/service/configs/config_overridable.js
index 143af1c..d5b733c 100644
--- a/ambari-web/app/mixins/main/service/configs/config_overridable.js
+++ b/ambari-web/app/mixins/main/service/configs/config_overridable.js
@@ -134,17 +134,14 @@ App.ConfigOverridable = Em.Mixin.create({
}
} else {
var newConfigGroupName = this.get('newConfigGroupName').trim();
- var newConfigGroup = App.ConfigGroup.create({
+ var newConfigGroup = {
id: null,
name: newConfigGroupName,
description: Em.I18n.t('config.group.description.default').format(new Date().toDateString()),
- isDefault: false,
- parentConfigGroup: null,
- service: (isInstaller) ? Em.Object.create({id: serviceId}) : App.Service.find().findProperty('serviceName', serviceId),
+ service_id: serviceId,
hosts: [],
- configSiteTags: [],
- properties: []
- });
+ desired_configs: []
+ };
if (!isInstaller) {
self.postNewConfigurationGroup(newConfigGroup);
}
@@ -223,14 +220,14 @@ App.ConfigOverridable = Em.Mixin.create({
/**
* Create a new config-group for a service.
*
- * @param {App.ConfigGroup} newConfigGroupData config group to post to server
+ * @param {object} newConfigGroupData config group to post to server
* @param {Function} callback Callback function for Success or Error handling
- * @return {App.ConfigGroup} Returns the created config-group
+ * @return {$.ajax}
* @method postNewConfigurationGroup
*/
postNewConfigurationGroup: function (newConfigGroupData, callback) {
var dataHosts = [];
- newConfigGroupData.get('hosts').forEach(function (_host) {
+ newConfigGroupData.hosts.forEach(function (_host) {
dataHosts.push({
host_name: _host
});
@@ -238,15 +235,15 @@ App.ConfigOverridable = Em.Mixin.create({
var sendData = {
name: 'config_groups.create',
data: {
- 'group_name': newConfigGroupData.get('name'),
- 'service_id': newConfigGroupData.get('service.id'),
- 'description': newConfigGroupData.get('description'),
+ 'group_name': newConfigGroupData.name,
+ 'service_id': newConfigGroupData.service_id,
+ 'description': newConfigGroupData.description,
'hosts': dataHosts
},
success: 'successFunction',
error: 'errorFunction',
- successFunction: function (response) {
- newConfigGroupData.set('id', response.resources[0].ConfigGroup.id);
+ successFunction: function (response, opt, params) {
+ App.ServiceConfigGroup.find().clear();
if (callback) {
callback();
}
@@ -294,10 +291,15 @@ App.ConfigOverridable = Em.Mixin.create({
}
};
+ if (Em.isNone(configGroup.get('configGroupId'))) {
+ Em.assert('Config Group missing server side "id"', false);
+ return null;
+ }
+
var sendData = {
name: 'config_groups.update',
data: {
- id: Em.isNone(configGroup.get('configGroupId')) ? configGroup.get('id') : configGroup.get('configGroupId'),
+ id: configGroup.get('configGroupId'),
data: putConfigGroup
},
success: 'successFunction',
@@ -364,35 +366,6 @@ App.ConfigOverridable = Em.Mixin.create({
},
/**
- * Update config group's hosts list and leave only unmodified hosts in the group
- * Save updated config group on server
- * @param {App.ConfigGroup} configGroup
- * @param {App.ConfigGroup} initialGroupState
- * @param {Function} successCallback
- * @param {Function} errorCallback
- * @method clearConfigurationGroupHosts
- */
- clearConfigurationGroupHosts: function (configGroup, initialGroupState, successCallback, errorCallback) {
- configGroup = jQuery.extend({}, configGroup);
- var unmodifiedHosts = this.getUnmodifiedHosts(configGroup, initialGroupState);
- configGroup.set('hosts', unmodifiedHosts);
- return this.updateConfigurationGroup(configGroup, successCallback, errorCallback);
- },
-
- /**
- * Get the list of hosts that is not modified in the group
- * @param configGroup - the new configuration of the group
- * @param initialGroupState - the initial configuration of the group
- * @returns {Array}
- */
- getUnmodifiedHosts: function (configGroup, initialGroupState) {
- var currentHosts = configGroup.get('hosts');
- var initialHosts = initialGroupState.get('hosts');
-
- return arrayUtils.intersect(currentHosts, initialHosts);
- },
-
- /**
* Do request to delete config group
* @param {App.ConfigGroup} configGroup
* @param {Function} [successCallback]
@@ -405,7 +378,7 @@ App.ConfigOverridable = Em.Mixin.create({
name: 'common.delete.config_group',
sender: this,
data: {
- id: configGroup.get('id')
+ id: configGroup.get('configGroupId')
},
success: 'successFunction',
error: 'errorFunction',
http://git-wip-us.apache.org/repos/asf/ambari/blob/7819edfd/ambari-web/app/mixins/main/service/groups_mapping.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/main/service/groups_mapping.js b/ambari-web/app/mixins/main/service/groups_mapping.js
index 93a760d..09504e7 100644
--- a/ambari-web/app/mixins/main/service/groups_mapping.js
+++ b/ambari-web/app/mixins/main/service/groups_mapping.js
@@ -57,6 +57,7 @@ App.GroupsMappingMixin = Em.Mixin.create({
* @method saveConfigGroupsToModel
*/
saveConfigGroupsToModel: function (data, opt, params) {
+ App.store.commit();
App.configGroupsMapper.map(data, false, params.serviceNames.split(','));
params.dfd.resolve();
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/7819edfd/ambari-web/app/models.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models.js b/ambari-web/app/models.js
index 6bffb95..77918e5 100644
--- a/ambari-web/app/models.js
+++ b/ambari-web/app/models.js
@@ -57,7 +57,6 @@ require('models/host_component');
require('models/target_cluster');
require('models/slave_component');
require('models/master_component');
-require('models/config_group');
require('models/host_stack_version');
require('models/root_service');
require('models/upgrade_entity');
http://git-wip-us.apache.org/repos/asf/ambari/blob/7819edfd/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
deleted file mode 100644
index 515ecee..0000000
--- a/ambari-web/app/models/config_group.js
+++ /dev/null
@@ -1,172 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-var App = require('app');
-
-/**
- * Represents a configuration-group on the cluster.
- * A configuration-group is a collection of hosts
- * on which a collection of configurations are applied.
- *
- * Configuration group hierarchy is at 2 levels. For
- * each service there is a 'Default' configuration group
- * containing all hosts not belonging to any group of that
- * service.
- *
- * A default configuration group has child configuration
- * groups which contain configuration overrides (deltas)
- * for a bunch of hosts. This allows different configurations
- * for different hosts in a heterogeneous cluster environment.
- */
-App.ConfigGroup = Ember.Object.extend({
- id: null,
- name: null,
- description: null,
- isDefault: null,
- serviceName: null,
-
- /**
- * list of group names that shows which config
- * groups should be updated as dependent when current is changed
- * @type { serviceName: {String} }
- */
- dependentConfigGroups: {},
-
- /**
- * Parent configuration group for this group.
- * When {@link #isDefault} is true, this value is <code>null</code>
- * When {@link #isDefault} is false, this represents the configuration
- * deltas that are applied on the default.
- */
- parentConfigGroup: null,
- /**
- * all hosts that belong to cluster
- */
- clusterHostsBinding: 'App.router.manageConfigGroupsController.clusterHosts',
-
- /**
- * Children configuration groups for this group.
- * When {@link #isDefault} is false, this value is <code>null</code>
- * When {@link #isDefault} is true, this represents the various
- * configuration groups that override the default.
- */
- childConfigGroups: [],
-
- /**
- * Service for which this configuration-group
- * is applicable.
- */
- service: null,
-
- /**
- * Hosts on which this configuration-group
- * is to be applied. For a service, a host can
- * belong to only one non-default configuration-group.
- *
- * When {#isDefault} is false, this contains hosts
- * for which the overrides will apply.
- *
- * When {#isDefault} is true, this value is empty, as
- * it dynamically reflects hosts not belonging to other
- * non-default groups.
- *
- */
- hosts: [],
-
- /**
- * this flag is used for installed services' config groups
- * if user make changes to them - mark this flag to true
- */
- isForUpdate: false,
-
- /**
- * mark config groups for installed services
- */
- isForInstalledService: false,
- /**
- * Provides a display friendly name. This includes trimming
- * names to a certain length.
- */
- displayName: function () {
- var name = this.get('name');
- if (name && name.length>App.config.CONFIG_GROUP_NAME_MAX_LENGTH) {
- var middle = Math.floor(App.config.CONFIG_GROUP_NAME_MAX_LENGTH / 2);
- name = name.substring(0, middle) + "..." + name.substring(name.length-middle);
- }
- return name;
- }.property('name'),
-
- displayNameHosts: function () {
- return this.get('displayName') + ' (' + this.get('hosts.length') + ')';
- }.property('displayName', 'hosts.length'),
-
- apiResponse: null,
-
- /**
- * Provides hosts which are available for inclusion in
- * non-default configuration groups.
- */
- availableHosts: function () {
- if (this.get('isDefault')) return [];
- var unusedHostsMap = {};
- var availableHosts = [];
- var sharedHosts = this.get('clusterHosts');
- // parentConfigGroup.hosts(hosts from default group) - are available hosts, which don't belong to any group
- this.get('parentConfigGroup.hosts').forEach(function (hostName) {
- unusedHostsMap[hostName] = true;
- });
- sharedHosts.forEach(function (host) {
- if (unusedHostsMap[host.get('id')]) {
- availableHosts.pushObject(Ember.Object.create({
- selected: false,
- host: host,
- hostComponentNames: host.get('hostComponents').mapProperty('componentName')
- }));
- }
- });
- return availableHosts;
- }.property('isDefault', 'parentConfigGroup', 'childConfigGroups', 'parentConfigGroup.hosts.@each', 'clusterHosts'),
-
- isAddHostsDisabled: function () {
- return (this.get('isDefault') || this.get('availableHosts.length') === 0);
- }.property('availableHosts.length'),
-
- /**
- * Collection of (site, tag) pairs representing properties.
- *
- * When {#isDefault} is true, this represents the
- * default cluster configurations for that service.
- *
- * When {#isDefault} is false, this represents the
- * configuration overrides on top of the cluster default for the
- * hosts identified by 'hosts'.
- */
- configSiteTags: [],
-
- properties: [],
-
- propertiesList: function () {
- var result = '';
- this.get('properties').forEach(function (item) {
- result += item.name + " : " + item.value + '<br/>';
- }, this);
- return result;
- }.property('properties.length'),
-
- hash: null
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/7819edfd/ambari-web/app/models/configs/config_group.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/configs/config_group.js b/ambari-web/app/models/configs/config_group.js
index be431d8..467f53e 100644
--- a/ambari-web/app/models/configs/config_group.js
+++ b/ambari-web/app/models/configs/config_group.js
@@ -41,32 +41,28 @@ App.ServiceConfigGroup = DS.Model.extend({
name: DS.attr('string'),
serviceName: DS.attr('string'),
description: DS.attr('string'),
- hostNames: DS.attr('array'),
+ hosts: DS.attr('array'),
configVersions: DS.hasMany('App.ConfigVersion'),
service: DS.belongsTo('App.Service'),
- desiredConfigs: DS.attr('array'),
+ desiredConfigs: DS.attr('array', {defaultValue: []}),
/**
- * all hosts that belong to cluster
+ * this flag is used for installed services' config groups
+ * if user make changes to them - mark this flag to true
+ * @default [false]
*/
- clusterHostsBinding: 'App.router.manageConfigGroupsController.clusterHosts',
+ isForUpdate: DS.attr('boolean', {defaultValue: false}),
/**
- * Hosts on which this configuration-group
- * is to be applied. For a service, a host can
- * belong to only one non-default configuration-group.
- *
- * When {#isDefault} is false, this contains hosts
- * for which the overrides will apply.
- *
- * When {#isDefault} is true, this value is empty, as
- * it dynamically reflects hosts not belonging to other
- * non-default groups.
- * @type {Array}
+ * mark config groups for installed services
+ * @default [false]
*/
- hosts: function() {
- return this.get('hostNames');
- }.property('hostNames'),
+ isForInstalledService: DS.attr('boolean', {defaultValue: false}),
+
+ /**
+ * all hosts that belong to cluster
+ */
+ clusterHostsBinding: 'App.router.manageConfigGroupsController.clusterHosts',
/**
* defines if group is default
@@ -117,8 +113,8 @@ App.ServiceConfigGroup = DS.Model.extend({
*
*/
displayNameHosts: function () {
- return this.get('displayName') + ' (' + this.get('hostNames.length') + ')';
- }.property('displayName', 'hostNames.length'),
+ return this.get('displayName') + ' (' + this.get('hosts.length') + ')';
+ }.property('displayName', 'hosts.length'),
/**
* Provides hosts which are available for inclusion in
@@ -152,15 +148,22 @@ App.ServiceConfigGroup = DS.Model.extend({
/**
* @type {Array}
*/
- properties: [],
+ properties: DS.attr('array', {defaultValue: []}),
propertiesList: function () {
var result = '';
- this.get('properties').forEach(function (item) {
- result += item.name + " : " + item.value + '<br/>';
- }, this);
+
+ if (Array.isArray(this.get('properties'))) {
+ this.get('properties').forEach(function (item) {
+ result += item.name + " : " + item.value + '<br/>';
+ }, this);
+ }
return result;
}.property('properties.length')
});
App.ServiceConfigGroup.FIXTURES = [];
+
+App.ServiceConfigGroup.getParentConfigGroupId = function(serviceName) {
+ return serviceName + '0';
+};
http://git-wip-us.apache.org/repos/asf/ambari/blob/7819edfd/ambari-web/app/views/main/service/manage_config_groups_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/manage_config_groups_view.js b/ambari-web/app/views/main/service/manage_config_groups_view.js
index 8a42393..f7477ae 100644
--- a/ambari-web/app/views/main/service/manage_config_groups_view.js
+++ b/ambari-web/app/views/main/service/manage_config_groups_view.js
@@ -111,8 +111,8 @@ App.MainServiceManageConfigGroupView = Em.View.extend({
*/
buttonObserver: function () {
var selectedConfigGroup = this.get('controller.selectedConfigGroup');
- this.set('isRemoveButtonDisabled', selectedConfigGroup.isDefault);
- this.set('isRenameButtonDisabled', selectedConfigGroup.isDefault);
+ this.set('isRemoveButtonDisabled', selectedConfigGroup.get('isDefault'));
+ this.set('isRenameButtonDisabled', selectedConfigGroup.get('isDefault'));
this.set('isDuplicateButtonDisabled', false);
}.observes('controller.selectedConfigGroup'),
http://git-wip-us.apache.org/repos/asf/ambari/blob/7819edfd/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js b/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js
index 8b5508e..6d4eec7 100644
--- a/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js
+++ b/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js
@@ -315,11 +315,11 @@ describe('App.ManageConfigGroupsController', function() {
});
describe("#runClearCGQueue()", function () {
beforeEach(function () {
- sinon.stub(manageConfigGroupsController, 'clearConfigurationGroupHosts', Em.K);
+ sinon.stub(manageConfigGroupsController, 'updateConfigurationGroup', Em.K);
sinon.stub(manageConfigGroupsController, 'deleteConfigurationGroup', Em.K);
});
afterEach(function () {
- manageConfigGroupsController.clearConfigurationGroupHosts.restore();
+ manageConfigGroupsController.updateConfigurationGroup.restore();
manageConfigGroupsController.deleteConfigurationGroup.restore();
});
it("", function () {
@@ -328,7 +328,7 @@ describe('App.ManageConfigGroupsController', function() {
toClearHosts: [Em.Object.create()],
toDelete: [1]
});
- expect(manageConfigGroupsController.clearConfigurationGroupHosts.calledOnce).to.be.true;
+ expect(manageConfigGroupsController.updateConfigurationGroup.calledOnce).to.be.true;
expect(manageConfigGroupsController.deleteConfigurationGroup.calledOnce).to.be.true;
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/7819edfd/ambari-web/test/controllers/wizard/step7_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step7_test.js b/ambari-web/test/controllers/wizard/step7_test.js
index f1770a4..544c3b7 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -19,7 +19,6 @@
var App = require('app');
var numberUtils = require('utils/number_utils');
require('mixins/common/localStorage');
-require('models/config_group');
require('controllers/wizard/step7_controller');
var installerStep7Controller,
@@ -882,6 +881,9 @@ describe('App.InstallerStep7Controller', function () {
})
});
});
+ afterEach(function () {
+ App.ServiceConfigGroup.find().clear();
+ });
it('shouldn\'t do nothing if only MISC available', function () {
var configGroups = [
{}
@@ -892,57 +894,6 @@ describe('App.InstallerStep7Controller', function () {
installerStep7Controller.loadConfigGroups([]);
expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups')).to.eql(configGroups);
});
- it('should set configGroups for service if they don\'t exist', function () {
- var configGroups = [],
- serviceName = 'HDFS',
- serviceConfigGroups = [
- {service: {id: 's1'}}
- ];
- installerStep7Controller.reopen({
- stepConfigs: [Em.Object.create({serviceName: serviceName, displayName: serviceName, configGroups: configGroups})]
- });
- installerStep7Controller.loadConfigGroups(serviceConfigGroups);
- expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups.length')).to.equal(1);
- var group = installerStep7Controller.get('stepConfigs.firstObject.configGroups.firstObject');
- expect(group.get('name')).to.equal(serviceName + ' Default');
- expect(group.get('description').contains(serviceName)).to.equal(true);
- expect(group.get('isDefault')).to.equal(true);
- expect(group.get('hosts')).to.eql(['h1', 'h2', 'h3']);
- expect(group.get('service.id')).to.equal(serviceName);
- expect(group.get('serviceName')).to.equal(serviceName);
- });
- it('should update configGroups for service (only default group)', function () {
- var configGroups = [],
- serviceName = 'HDFS',
- serviceConfigGroups = [
- {service: {id: 'HDFS'}, isDefault: true, n: 'n1'}
- ];
- installerStep7Controller.reopen({
- stepConfigs: [Em.Object.create({serviceName: serviceName, displayName: serviceName, configGroups: configGroups})]
- });
- installerStep7Controller.loadConfigGroups(serviceConfigGroups);
- expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups').findProperty('isDefault').get('n')).to.equal('n1');
- });
- it('should update configGroups for service', function () {
- var configGroups = [],
- serviceName = 'HDFS',
- properties = [
- { name: "p1", filename: "file.xml" },
- { name: "p2", filename: "file.xml" }
- ],
- serviceConfigGroups = [
- {service: {id: 'HDFS'}, properties: properties.slice(), isDefault: true, n: 'n1'},
- {service: {id: 'HDFS'}, properties: properties.slice(), isDefault: false, n: 'n2'}
- ];
- installerStep7Controller.reopen({
- stepConfigs: [Em.Object.create({serviceName: serviceName, configGroups: configGroups, configs: properties})]
- });
- installerStep7Controller.loadConfigGroups(serviceConfigGroups);
- expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups.length')).to.equal(2);
- expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups').findProperty('isDefault').get('n')).to.equal('n1');
- expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups').findProperty('isDefault', false).get('properties').everyProperty('group.n', 'n2')).to.equal(true);
- expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups').findProperty('isDefault', false).get('parentConfigGroup.n')).to.equal('n1');
- });
});
describe('#_getDisplayedConfigGroups', function () {
@@ -1861,7 +1812,7 @@ describe('App.InstallerStep7Controller', function () {
});
- describe('#loadServiceTagsSuccess', function () {
+ describe.skip('#loadServiceTagsSuccess', function () {
it('should create ClusterSiteToTagMap', function () {
var params = Em.Object.create({
serviceName: "OOZIE",
http://git-wip-us.apache.org/repos/asf/ambari/blob/7819edfd/ambari-web/test/controllers/wizard/step8_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step8_test.js b/ambari-web/test/controllers/wizard/step8_test.js
index 6d46dfe..5317f07 100644
--- a/ambari-web/test/controllers/wizard/step8_test.js
+++ b/ambari-web/test/controllers/wizard/step8_test.js
@@ -339,7 +339,7 @@ describe('App.WizardStep8Controller', function () {
var content = Em.Object.create({
configGroups: Em.A([
Em.Object.create({
- isDefault: true,
+ is_default: true,
service: Em.Object.create({
id: 1
}),
@@ -358,7 +358,7 @@ describe('App.WizardStep8Controller', function () {
])
}),
Em.Object.create({
- isDefault: false,
+ is_default: false,
service: Em.Object.create({
id: 2
}),
http://git-wip-us.apache.org/repos/asf/ambari/blob/7819edfd/ambari-web/test/mixins/common/configs/enhanced_configs_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/configs/enhanced_configs_test.js b/ambari-web/test/mixins/common/configs/enhanced_configs_test.js
index 6c4b6d7..1b7115c 100644
--- a/ambari-web/test/mixins/common/configs/enhanced_configs_test.js
+++ b/ambari-web/test/mixins/common/configs/enhanced_configs_test.js
@@ -44,7 +44,7 @@ describe('App.EnhancedConfigsMixin', function() {
describe('#buildConfigGroupJSON()', function() {
it('generates JSON based on config group info', function() {
- var configGroup = App.ConfigGroup.create({
+ var configGroup = Em.Object.create({
name: 'group1',
isDefault: false,
hosts: ['host1', 'host2']
http://git-wip-us.apache.org/repos/asf/ambari/blob/7819edfd/ambari-web/test/models/config_group_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/config_group_test.js b/ambari-web/test/models/config_group_test.js
deleted file mode 100644
index cac43d3..0000000
--- a/ambari-web/test/models/config_group_test.js
+++ /dev/null
@@ -1,159 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-var App = require('app');
-
-var modelSetup = require('test/init_model_test');
-require('models/config_group');
-require('models/host');
-
-var configGroup,
- hostRecord,
- hosts = [
- Em.Object.create({
- id: 'host0',
- hostName: 'host0',
- hostComponents: []
- }),
- Em.Object.create({
- id: 'host1',
- hostName: 'host1',
- hostComponents: []
- })
- ],
- host = Em.Object.create({
- id: 'host0',
- hostName: 'host0',
- hostComponents: []
- }),
- properties = [
- {
- name: 'n0',
- value: 'v0'
- },
- {
- name: 'n1',
- value: 'v1'
- }
- ],
- setParentConfigGroup = function (configGroup, hosts) {
- configGroup.set('parentConfigGroup', App.ConfigGroup.create());
- configGroup.set('parentConfigGroup.hosts', hosts.mapProperty('hostName'));
- };
-
-describe('App.ConfigGroup', function () {
-
- beforeEach(function () {
- configGroup = App.ConfigGroup.create();
- });
-
- describe('#displayName', function () {
- it('should equal name if maximum length is not exceeded', function () {
- configGroup.set('name', 'n');
- expect(configGroup.get('displayName')).to.equal(configGroup.get('name'));
- });
- it('should be shortened if maximum length is exceeded', function () {
- var maxLength = App.config.CONFIG_GROUP_NAME_MAX_LENGTH;
- for (var i = maxLength + 1, name = ''; i--; ) {
- name += 'n';
- }
- configGroup.set('name', name);
- expect(configGroup.get('displayName')).to.contain('...');
- expect(configGroup.get('displayName')).to.have.length(2 * Math.floor(maxLength / 2) + 3);
- });
- });
-
- describe('#displayNameHosts', function () {
- it('should indicate the number of hosts', function () {
- var displayName = configGroup.get('displayName');
- configGroup.set('hosts', []);
- expect(configGroup.get('displayNameHosts')).to.equal(displayName + ' (0)');
- configGroup.set('hosts', hosts);
- expect(configGroup.get('displayNameHosts')).to.equal(displayName + ' (2)');
- });
- });
-
- describe('#availableHosts', function () {
-
- beforeEach(function () {
- App.clusterStatus.set('clusterState', 'DEFAULT');
- sinon.stub(App.Host, 'find', function() {
- return [host];
- });
- setParentConfigGroup(configGroup, hosts);
- });
-
- afterEach(function () {
- App.Host.find.restore();
- });
-
- it('should return an empty array as default', function () {
- configGroup.set('isDefault', true);
- expect(configGroup.get('availableHosts')).to.eql([]);
- });
-
- it('should return an empty array if there are no unused hosts', function () {
- configGroup.set('parentConfigGroup', App.ConfigGroup.create());
- expect(configGroup.get('availableHosts')).to.eql([]);
- });
-
- it('should take hosts from parentConfigGroup', function () {
- setParentConfigGroup(configGroup, hosts);
- configGroup.set('clusterHosts', hosts);
- expect(configGroup.get('availableHosts')).to.have.length(2);
- });
- });
-
- describe('#isAddHostsDisabled', function () {
-
- beforeEach(function () {
- hostRecord = App.Host.createRecord(host);
- setParentConfigGroup(configGroup, hosts);
- configGroup.set('isDefault', false);
- configGroup.reopen({availableHosts: [{}]});
- });
-
- afterEach(function () {
- modelSetup.deleteRecord(hostRecord);
- });
-
- it('should be false', function () {
- expect(configGroup.get('isAddHostsDisabled')).to.be.false;
- });
- it('should be true', function () {
- App.clusterStatus.set('clusterState', 'DEFAULT');
- configGroup.set('isDefault', true);
- expect(configGroup.get('isAddHostsDisabled')).to.be.true;
- configGroup.set('availableHosts', hosts);
- expect(configGroup.get('isAddHostsDisabled')).to.be.true;
- });
- });
-
- describe('#propertiesList', function () {
- it('should be formed from properties', function () {
- configGroup.set('properties', properties);
- properties.forEach(function (item) {
- Em.keys(item).forEach(function (prop) {
- expect(configGroup.get('propertiesList')).to.contain(item[prop]);
- });
- });
- expect(configGroup.get('propertiesList')).to.have.length(24);
- });
- });
-
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/7819edfd/ambari-web/test/utils/config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/config_test.js b/ambari-web/test/utils/config_test.js
index c9e0125..6aabc2d 100644
--- a/ambari-web/test/utils/config_test.js
+++ b/ambari-web/test/utils/config_test.js
@@ -898,7 +898,7 @@ describe('App.config', function () {
var configProperty = App.ServiceConfigProperty.create(template);
- var group = App.ConfigGroup.create({name: "group1"});
+ var group = Em.Object.create({name: "group1"});
it('creates override with save properties as original config', function() {
var override = App.config.createOverride(configProperty, {}, group);