|
@@ -820,44 +820,32 @@ App.WizardStep8Controller = Em.Controller.extend({
|
|
|
* Update configurations for installed services.
|
|
|
* Do separated PUT-request for each siteName for each service
|
|
|
*
|
|
|
- * @param {Array} configsToUpdate - configs need to update
|
|
|
- * Format:
|
|
|
- * <code>
|
|
|
- * [
|
|
|
- * {serviceName: 's1', id: 'site property', filename: 'f1.xml', name: 'n1', value: 'v1'},
|
|
|
- * {serviceName: 's2', id: 'site property', filename: 'f1.xml', name: 'n2', value: 'v2'},
|
|
|
- * {serviceName: 's2', id: '', filename: 'f2.xml', name: 'n3', value: 'v3'}
|
|
|
- * ]
|
|
|
- * </code>
|
|
|
+ * @param {Array} fileNamesToUpdate - file names that should be updated
|
|
|
* @method updateConfigurations
|
|
|
*/
|
|
|
- updateConfigurations: function (configsToUpdate) {
|
|
|
+ updateConfigurations: function (fileNamesToUpdate) {
|
|
|
var configurationController = App.router.get('mainServiceInfoConfigsController');
|
|
|
- var configs = configsToUpdate.filter(function(config) {
|
|
|
- return !!config.filename && !/^(core)/.test(config.filename) && config.filename.indexOf('env')==-1;
|
|
|
- });
|
|
|
- var serviceNames = configs.mapProperty('serviceName').uniq();
|
|
|
+ var configs = this.get('configs').slice(0);
|
|
|
var configsMap = [];
|
|
|
|
|
|
- serviceNames.forEach(function (serviceName) {
|
|
|
- var serviceConfigs = configs.filterProperty('serviceName', serviceName);
|
|
|
+ fileNamesToUpdate.forEach(function(fileName){
|
|
|
+ if (!fileName || /^(core)/.test(fileName)) return;
|
|
|
var tagName = 'version' + (new Date).getTime();
|
|
|
- serviceConfigs.forEach(function(config) {
|
|
|
- config.value = App.config.trimProperty(config, false);
|
|
|
+ var configsToSave = configs.filterProperty('filename', fileName);
|
|
|
+ configsToSave.forEach(function(item) {
|
|
|
+ item.value = App.config.trimProperty(item, false);
|
|
|
});
|
|
|
- serviceConfigs.mapProperty('filename').uniq().forEach(function (siteName) {
|
|
|
- configsMap.push(configurationController.createSiteObj(siteName.replace(".xml", ""), tagName, serviceConfigs.filterProperty('filename', siteName)));
|
|
|
- });
|
|
|
- });
|
|
|
+ configsMap.push(configurationController.createSiteObj(fileName.replace(".xml", ""), tagName, configsToSave));
|
|
|
+ }, this);
|
|
|
|
|
|
if (!configsMap.length) return;
|
|
|
- var configData = configsMap.map(function (_serviceConfig) {
|
|
|
+ var configData = configsMap.map(function (siteConfigObject) {
|
|
|
return JSON.stringify({
|
|
|
Clusters: {
|
|
|
desired_config: {
|
|
|
- type: _serviceConfig.type,
|
|
|
- tag: _serviceConfig.tag,
|
|
|
- properties: _serviceConfig.properties
|
|
|
+ type: siteConfigObject.type,
|
|
|
+ tag: siteConfigObject.tag,
|
|
|
+ properties: siteConfigObject.properties
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -987,8 +975,8 @@ App.WizardStep8Controller = Em.Controller.extend({
|
|
|
this.createCluster();
|
|
|
this.createSelectedServices();
|
|
|
if (this.get('content.controllerName') !== 'addHostController') {
|
|
|
- if (this.get('wizardController').getDBProperty('configsToUpdate') && this.get('wizardController').getDBProperty('configsToUpdate').length) {
|
|
|
- this.updateConfigurations(this.get('wizardController').getDBProperty('configsToUpdate'));
|
|
|
+ if (this.get('wizardController').getDBProperty('fileNamesToUpdate') && this.get('wizardController').getDBProperty('fileNamesToUpdate').length) {
|
|
|
+ this.updateConfigurations(this.get('wizardController').getDBProperty('fileNamesToUpdate'));
|
|
|
}
|
|
|
this.createConfigurations();
|
|
|
this.applyConfigurationsToCluster();
|
|
@@ -1362,6 +1350,30 @@ App.WizardStep8Controller = Em.Controller.extend({
|
|
|
});
|
|
|
},
|
|
|
|
|
|
+ /**
|
|
|
+ * Compare generated config object with current configs that were filled
|
|
|
+ * on "Customize Services" page.
|
|
|
+ *
|
|
|
+ * @param {Object} properties - generated by createSiteObj|createCoreSiteObj
|
|
|
+ * @param {Array} configs - current configs to compare
|
|
|
+ * @return {Boolean}
|
|
|
+ * @method isConfigsChanged
|
|
|
+ **/
|
|
|
+ isConfigsChanged: function (properties, configs) {
|
|
|
+ var isChanged = false;
|
|
|
+ for (var property in properties) {
|
|
|
+ var config = configs.findProperty('name', property);
|
|
|
+ // if config not found then it's looks like a new config
|
|
|
+ if (!config) {
|
|
|
+ isChanged = true;
|
|
|
+ } else {
|
|
|
+ if (!config.hasInitialValue || config.isNotDefaultValue) {
|
|
|
+ isChanged = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return isChanged;
|
|
|
+ },
|
|
|
/**
|
|
|
* Create config objects for cluster and services
|
|
|
* @method createConfigurations
|
|
@@ -1380,9 +1392,9 @@ App.WizardStep8Controller = Em.Controller.extend({
|
|
|
if (this.get('content.controllerName') == 'addServiceController') {
|
|
|
tag = 'version' + (new Date).getTime();
|
|
|
coreSiteObject.tag = tag;
|
|
|
- this.get('serviceConfigTags').pushObject(coreSiteObject);
|
|
|
- //for Add Service save config of new and installed services either
|
|
|
- selectedServices = selectedServices.concat(this.get('installedServices'));
|
|
|
+ var coreSiteConfigs = this.get('configs').filterProperty('filename','core-site.xml');
|
|
|
+ if (this.isConfigsChanged(coreSiteObject.properties, coreSiteConfigs))
|
|
|
+ this.get('serviceConfigTags').pushObject(coreSiteObject);
|
|
|
}
|
|
|
|
|
|
var objMap = {
|