This is an automated email from the ASF dual-hosted git repository.

mradhakrishnan pushed a commit to branch branch-feature-AMBARI-14714-configs
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to 
refs/heads/branch-feature-AMBARI-14714-configs by this push:
     new fa5469a  Revert "Revert "Merge branch-feature-AMBARI-14714-configs to 
branch-feature-AMBARI-14714""
fa5469a is described below

commit fa5469aff0e7d8e1217717aa4a5a369861beb936
Author: Madhuvanthi Radhakrishnan <mradhakrish...@hortonworks.com>
AuthorDate: Thu Apr 19 15:47:52 2018 -0700

    Revert "Revert "Merge branch-feature-AMBARI-14714-configs to 
branch-feature-AMBARI-14714""
    
    This reverts commit 228236c4a71b151fe157afdfa0c5b3ccf0c6a602.
---
 ambari-web/app/controllers/wizard.js               |   2 +-
 .../app/controllers/wizard/step8_controller.js     | 102 ++++++++---------
 .../app/controllers/wizard/step9_controller.js     |   4 +-
 .../app/mixins/common/configs/configs_saver.js     |   3 +-
 ambari-web/app/utils/ajax/ajax.js                  |   9 +-
 ambari-web/test/controllers/wizard/step8_test.js   |  35 ++----
 .../mixins/common/configs/configs_saver_test.js    | 124 +++++++++++----------
 7 files changed, 136 insertions(+), 143 deletions(-)

diff --git a/ambari-web/app/controllers/wizard.js 
b/ambari-web/app/controllers/wizard.js
index f8f37d4..84ee966 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -529,7 +529,7 @@ App.WizardController = 
Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
     const serviceGroups = this.get('content.serviceGroups');
     
     const installPromises = serviceGroups.map(sg => {
-      data.serviceGroup = sg;
+      data.serviceGroupName = sg;
 
       return App.ajax.send({
         name: isRetry ? 'common.host_components.update' : 
'common.services.update',
diff --git a/ambari-web/app/controllers/wizard/step8_controller.js 
b/ambari-web/app/controllers/wizard/step8_controller.js
index 2ca005e..9a894eb 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/ambari-web/app/controllers/wizard/step8_controller.js
@@ -1051,7 +1051,7 @@ App.WizardStep8Controller = 
App.WizardStepController.extend(App.AddSecurityConfi
       this.addRequestToAjaxQueue({
         name: 'wizard.step8.create_selected_services',
         data: {
-          serviceGroup: service.ServiceInfo.service_group_name,
+          serviceGroupName: service.ServiceInfo.service_group_name,
           data: JSON.stringify(service)
         }
       });
@@ -1131,13 +1131,13 @@ App.WizardStep8Controller = 
App.WizardStepController.extend(App.AddSecurityConfi
    * @param componentsData
    * @param serviceName
    */
-  addRequestToCreateComponent: function (componentsData, serviceName, 
serviceGroup) {
+  addRequestToCreateComponent: function (componentsData, serviceName, 
serviceGroupName) {
     this.addRequestToAjaxQueue({
       name: 'wizard.step8.create_components',
       data: {
         data: JSON.stringify(componentsData),
         serviceName: serviceName,
-        serviceGroup: serviceGroup
+        serviceGroupName: serviceGroupName
       }
     });
   },
@@ -1529,72 +1529,66 @@ App.WizardStep8Controller = 
App.WizardStepController.extend(App.AddSecurityConfi
    */
   createServiceConfigurations: function () {
     this.get('selectedServices').forEach(function (service) {
-      Object.keys(service.get('configTypes')).forEach(function (type) {
-        if (!this.get('serviceConfigTags').someProperty('type', type)) {
-          var configs = this.get('configs').filterProperty('filename', 
App.config.getOriginalFileName(type));
-          var serviceConfigNote = this.getServiceConfigNote(type, 
service.get('displayName'));
-          
this.get('serviceConfigTags').pushObject(this.createDesiredConfig(type, 
configs, serviceConfigNote));
+      let serviceConfigs = {
+        serviceName: service.get('serviceName'),
+        serviceGroupName: service.get('stackName'), //TODO - mpacks: for now
+        data: {
+          "ServiceConfigVersion": {
+            "service_config_version_note": this.getServiceConfigNote('', 
service.get('displayName')),
+            "stack_id": 
`${service.get('stackName')}-${service.get('stackVersion')}`
+          },
+          "configurations": []
         }
+      };
+
+      Object.keys(service.get('configTypesRendered')).forEach(function 
(typeName) {
+        const type = service.get('configTypes')[typeName]; //just ensure that 
the type is in both lists; they contain the same data if so
+        if (type) {
+          const configs = this.get('configs').filterProperty('filename', 
App.config.getOriginalFileName(typeName));
+          
serviceConfigs.data.configurations.push(this.createDesiredConfig(typeName, 
configs, null, true));
+        }  
       }, this);
+
+      if (serviceConfigs.data.configurations.length > 0) {
+        
this.get('serviceConfigTags').pushObject(Em.Object.create(serviceConfigs));
+      }  
     }, this);
+    
     this.createNotification();
   },
 
   /**
+   * Send <code>serviceConfigTags</code> to server
+   * Queued request
+   * One request for each service config data item,
+   * each of which corresponds to a single service instance
+   * @param serviceConfigData
+   * @method applyConfigurationsToCluster
+   */
+  applyConfigurationsToCluster: function (serviceConfigData) {
+    serviceConfigData.forEach(function (serviceConfig) {
+      this.addRequestToAjaxQueue({
+        name: 'common.service.create.configs',
+        data: {
+          serviceName: serviceConfig.get('serviceName'),
+          serviceGroupName: serviceConfig.get('serviceGroupName'),
+          data: serviceConfig.get('data')
+        }
+      });
+    }, this);
+  },  
+
+  /**
    * Get config version message
    *
    * @param type
    * @param serviceDisplayName
    * @returns {*}
-   */
+   */ 
   getServiceConfigNote: function(type, serviceDisplayName) {
     return this.get('isAddService') && type === 'core-site' ?
       Em.I18n.t('dashboard.configHistory.table.notes.addService') : 
Em.I18n.t('dashboard.configHistory.table.notes.default').format(serviceDisplayName);
-  },
-
-  /**
-   * Send <code>serviceConfigTags</code> to server
-   * Queued request
-   * One request for each service config tag
-   * @param serviceConfigTags
-   * @method applyConfigurationsToCluster
-   */
-  applyConfigurationsToCluster: function (serviceConfigTags) {
-    var allServices = 
this.get('installedServices').concat(this.get('selectedServices'));
-    var allConfigData = [];
-    allServices.forEach(function (service) {
-      var serviceConfigData = [];
-      Object.keys(service.get('configTypesRendered')).forEach(function (type) {
-        var serviceConfigTag = serviceConfigTags.findProperty('type', type);
-        if (serviceConfigTag) {
-          serviceConfigData.pushObject(serviceConfigTag);
-        }
-      }, this);
-      if (serviceConfigData.length) {
-        allConfigData.pushObject(JSON.stringify({
-          Clusters: {
-            desired_config: serviceConfigData.map(function(item) {
-              var props = {};
-              Em.keys(item.properties).forEach(function(propName) {
-                if (item.properties[propName] !== null) {
-                  props[propName] = item.properties[propName];
-                }
-              });
-              item.properties = props;
-              return item;
-            })
-          }
-        }));
-      }
-    }, this);
-
-    this.addRequestToAjaxQueue({
-      name: 'common.across.services.configurations',
-      data: {
-        data: '[' + allConfigData.toString() + ']'
-      }
-    });
-  },
+  },    
 
   /**
    * Create and update config groups
diff --git a/ambari-web/app/controllers/wizard/step9_controller.js 
b/ambari-web/app/controllers/wizard/step9_controller.js
index b918a75..1785a94 100644
--- a/ambari-web/app/controllers/wizard/step9_controller.js
+++ b/ambari-web/app/controllers/wizard/step9_controller.js
@@ -522,7 +522,7 @@ App.WizardStep9Controller = 
App.WizardStepController.extend(App.ReloadPopupMixin
 
         serviceGroups = this.get('content.serviceGroups');
         promises = serviceGroups.map(sg => {
-          data.serviceGroup = sg;
+          data.serviceGroupName = sg;
 
           return App.ajax.send({
             name: 'common.services.update',
@@ -544,7 +544,7 @@ App.WizardStep9Controller = 
App.WizardStepController.extend(App.ReloadPopupMixin
 
         serviceGroups = this.get('content.serviceGroups');
         promises = serviceGroups.map(sg => {
-          data.serviceGroup = sg;
+          data.serviceGroupName = sg;
 
           return App.ajax.send({
             name: 'common.services.update',
diff --git a/ambari-web/app/mixins/common/configs/configs_saver.js 
b/ambari-web/app/mixins/common/configs/configs_saver.js
index c2245fb..c700c16 100644
--- a/ambari-web/app/mixins/common/configs/configs_saver.js
+++ b/ambari-web/app/mixins/common/configs/configs_saver.js
@@ -458,6 +458,7 @@ App.ConfigsSaverMixin = Em.Mixin.create({
     Em.assert('type should be defined', type);
     var desired_config = {
       "type": type,
+      "tag": "v1", //REMOVE
       "properties": {}
     };
     if (!ignoreVersionNote) {
@@ -487,7 +488,7 @@ App.ConfigsSaverMixin = Em.Mixin.create({
     if (Object.keys(attributes.final).length || 
Object.keys(attributes.password).length) {
       desired_config.properties_attributes = attributes;
     }
-    return desired_config;
+    return { "Config": desired_config };
   },
 
   /**
diff --git a/ambari-web/app/utils/ajax/ajax.js 
b/ambari-web/app/utils/ajax/ajax.js
index 8b1522b..fb54510 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -57,7 +57,7 @@ var urls = {
   },
 
   'common.services.update' : {
-    'real': 
'/clusters/{clusterName}/servicegroups/{serviceGroup}/services?{urlParams}',
+    'real': 
'/clusters/{clusterName}/servicegroups/{serviceGroupName}/services?{urlParams}',
     'mock': '/data/wizard/deploy/poll_1.json',
     'format': function (data) {
       return {
@@ -247,10 +247,9 @@ var urls = {
 
   'common.service.create.configs': {
     'type': 'POST',
-    
'real':'/clusters/{clusterName}/servicegroups/{serviceGroup}/services/{serviceName}/configurations',
+    'real': 
'/clusters/{clusterName}/servicegroups/{serviceGroupName}/services/{serviceName}/configurations/service_config_versions',
     'format': function(data) {
       return {
-        apiPrefix: 'api/v2',
         data: JSON.stringify(data.data)
       }
     }
@@ -2096,7 +2095,7 @@ var urls = {
 
   'wizard.step8.create_selected_services': {
     'type': 'POST',
-    'real': '/clusters/{cluster}/servicegroups/{serviceGroup}/services',
+    'real': '/clusters/{cluster}/servicegroups/{serviceGroupName}/services',
     'mock': '/data/stacks/HDP-2.1/recommendations.json',
     'format': function (data) {
       return {
@@ -2107,7 +2106,7 @@ var urls = {
   },
 
   'wizard.step8.create_components': {
-    'real': 
'/clusters/{cluster}/servicegroups/{serviceGroup}/services/{serviceName}/components',
+    'real': 
'/clusters/{cluster}/servicegroups/{serviceGroupName}/services/{serviceName}/components',
     'mock': '',
     'format': function (data) {
       return {
diff --git a/ambari-web/test/controllers/wizard/step8_test.js 
b/ambari-web/test/controllers/wizard/step8_test.js
index 089746c..6d3832d 100644
--- a/ambari-web/test/controllers/wizard/step8_test.js
+++ b/ambari-web/test/controllers/wizard/step8_test.js
@@ -1302,31 +1302,20 @@ describe('App.WizardStep8Controller', function () {
 
     describe('#applyConfigurationsToCluster', function() {
       it('should call addRequestToAjaxQueue', function() {
-        var serviceConfigTags = [
-            {
-              type: 'hdfs',
-              tag: 'tag1',
-              properties: {
-                'prop1': 'value1'
-              }
+        var serviceConfig = {
+          serviceName: "service",
+          serviceGroupName: "serviceGroup",
+          data: {
+            properties: {
+              prop1: "val1"
             }
-          ],
-          data = '['+JSON.stringify({
-            Clusters: {
-              desired_config: [serviceConfigTags[0]]
-            }
-          })+']';
-        installerStep8Controller.reopen({
-          installedServices: [
-              Em.Object.create({
-                isSelected: true,
-                isInstalled: false,
-                configTypesRendered: {hdfs:'tag1'}
-              })
-            ], selectedServices: []
-        });
+          }
+        }
+        
+        var serviceConfigTags = [Em.Object.create(serviceConfig)];
+
         
installerStep8Controller.applyConfigurationsToCluster(serviceConfigTags);
-        
expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.equal(data);
+        
expect(JSON.stringify(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data)).to.deep.equal(JSON.stringify(serviceConfig));
       });
     });
 
diff --git a/ambari-web/test/mixins/common/configs/configs_saver_test.js 
b/ambari-web/test/mixins/common/configs/configs_saver_test.js
index ff238c1..1d8f9d7 100644
--- a/ambari-web/test/mixins/common/configs/configs_saver_test.js
+++ b/ambari-web/test/mixins/common/configs/configs_saver_test.js
@@ -137,38 +137,46 @@ describe('App.ConfigsSaverMixin', function() {
 
     it('generates config without properties', function() {
       expect(mixin.createDesiredConfig('type1')).to.eql({
-        "type": 'type1',
-        "properties": {},
-        "service_config_version_note": ""
+        "Config": {
+          "type": 'type1',
+          "properties": {},
+          "service_config_version_note": ""
+        }
       })
     });
 
     it('generates config with properties', function() {
       expect(mixin.createDesiredConfig('type1', [Em.Object.create({name: 'p1', 
value: 'v1', isRequiredByAgent: true}), Em.Object.create({name: 'p2', value: 
'v2', isRequiredByAgent: true})], "note")).to.eql({
-        "type": 'type1',
-        "properties": {
-          "p1": 'v1',
-          "p2": 'v2'
-        },
-        "service_config_version_note": 'note'
+        "Config": {
+          "type": 'type1',
+          "properties": {
+            "p1": 'v1',
+            "p2": 'v2'
+          },
+          "service_config_version_note": 'note'
+        }
       })
     });
 
     it('generates config with properties and skip isRequiredByAgent', 
function() {
       expect(mixin.createDesiredConfig('type1', [Em.Object.create({name: 'p1', 
value: 'v1', isRequiredByAgent: true}), Em.Object.create({name: 'p2', value: 
'v2', isRequiredByAgent: false})], "note")).to.eql({
-        "type": 'type1',
-        "properties": {
-          p1: 'v1'
-        },
-        "service_config_version_note": 'note'
+        "Config": {
+          "type": 'type1',
+          "properties": {
+            p1: 'v1'
+          },
+          "service_config_version_note": 'note'
+        }
       })
     });
 
     it('generates config with properties and skip 
service_config_version_note', function() {
       expect(mixin.createDesiredConfig('type1', [Em.Object.create({name: 'p1', 
value: 'v1', isRequiredByAgent: true})], "note", true)).to.eql({
-        "type": 'type1',
-        "properties": {
-          p1: 'v1'
+        "Config": {
+          "type": 'type1',
+          "properties": {
+            p1: 'v1'
+          }
         }
       })
     });
@@ -183,47 +191,49 @@ describe('App.ConfigsSaverMixin', function() {
           Em.Object.create({name: 'p6', value: 'v6', isRequiredByAgent: true, 
propertyType: ["TEXT", "VALUE_FROM_PROPERTY_FILE"]}),
           Em.Object.create({name: 'p7', value: 'v7', isRequiredByAgent: true, 
propertyType: ["PASSWORD"]})
         ], "note")).to.eql({
-        "type": 'type1',
-        "properties": {
-          p1: 'v1',
-          p2: 'v2',
-          p3: 'v3',
-          p4: 'v4',
-          p5: 'v5',
-          p6: 'v6',
-          p7: 'v7'
-        },
-        "properties_attributes": {
-          final: {
-            'p1': "true"
-          },
-          password: {
-            "p3": "true",
-            "p4": "true",
-            "p7": "true"
-          },
-          user: {
-            "p3": "true"
-          },
-          group: {
-            "p3": "true"
-          },
-          text: {
-            "p4": "true",
-            "p6": "true"
-          },
-          additional_user_property: {
-            "p4": "true"
-          },
-          not_managed_hdfs_path: {
-            "p5": "true"
-          },
-          value_from_property_file: {
-            "p6": "true"
+          "Config": {
+            "type": 'type1',
+            "properties": {
+              p1: 'v1',
+              p2: 'v2',
+              p3: 'v3',
+              p4: 'v4',
+              p5: 'v5',
+              p6: 'v6',
+              p7: 'v7'
+            },
+            "properties_attributes": {
+              final: {
+                'p1': "true"
+              },
+              password: {
+                "p3": "true",
+                "p4": "true",
+                "p7": "true"
+              },
+              user: {
+                "p3": "true"
+              },
+              group: {
+                "p3": "true"
+              },
+              text: {
+                "p4": "true",
+                "p6": "true"
+              },
+              additional_user_property: {
+                "p4": "true"
+              },
+              not_managed_hdfs_path: {
+                "p5": "true"
+              },
+              value_from_property_file: {
+                "p6": "true"
+              }
+            },
+            "service_config_version_note": 'note'
           }
-        },
-        "service_config_version_note": 'note'
-      })
+        })
     })
   });
 

-- 
To stop receiving notification emails like this one, please contact
mradhakrish...@apache.org.

Reply via email to