Browse Source

AMBARI-3889 Post config groups to server on Deploy. (atkach)

atkach 11 years ago
parent
commit
029c1df7d1

+ 2 - 1
ambari-web/app/controllers/main/service/manage_config_groups_controller.js

@@ -604,7 +604,8 @@ App.InstallerManageConfigGroupsController = App.ManageConfigGroupsController.ext
           parentConfigGroup: defaultConfigGroup,
           service: Em.Object.create({id: self.get('serviceName')}),
           hosts: [],
-          configSiteTags: []
+          configSiteTags: [],
+          properties: []
         });
         self.get('loadedHostsToGroupMap')[newConfigGroupData.get('name')] = [];
         self.get('configGroups').pushObject(newConfigGroupData);

+ 2 - 1
ambari-web/app/controllers/wizard.js

@@ -741,7 +741,8 @@ App.WizardController = Em.Controller.extend({
         configGroup.get('properties').forEach(function (property) {
           properties.push({
             name: property.get('name'),
-            value: property.get('value')
+            value: property.get('value'),
+            filename: property.get('filename')
           })
         });
         //configGroup copied into plain JS object to avoid Converting circular structure to JSON

+ 1 - 0
ambari-web/app/controllers/wizard/step7_controller.js

@@ -215,6 +215,7 @@ App.WizardStep7Controller = Em.Controller.extend({
         this.set('overrideToAdd', null);
       }
       configOverrides.setEach('isEditable', !selectedGroup.get('isDefault'));
+      configOverrides.setEach('parentSCP', config);
       config.set('overrides', configOverrides);
     }, this);
   }.observes('selectedConfigGroup'),

+ 40 - 0
ambari-web/app/controllers/wizard/step8_controller.js

@@ -884,6 +884,9 @@ App.WizardStep8Controller = Em.Controller.extend({
     this.createConfigurations();
     this.createComponents();
     this.registerHostsToCluster();
+    if (App.supports.hostOverridesInstaller) {
+      this.createConfigurationGroups();
+    }
     this.createAllHostComponents();
     this.createHostOverrideConfigurations();
 
@@ -1389,6 +1392,43 @@ App.WizardStep8Controller = Em.Controller.extend({
     });
   },
 
+  createConfigurationGroups: function () {
+    var configGroups = this.get('content.configGroups').filterProperty('isDefault', false);
+    var clusterName = this.get('clusterName');
+    var sendData = [];
+    var serviceConfigController = App.router.get('mainServiceInfoConfigsController');
+    configGroups.forEach(function (configGroup) {
+      var groupConfigs = [];
+      var groupData = {
+        "cluster_name": clusterName,
+        "group_name": configGroup.name,
+        "tag": configGroup.service.id,
+        "description": configGroup.description,
+        "hosts": [],
+        "desired_configs": []
+      };
+      configGroup.hosts.forEach(function (hostName) {
+        groupData.hosts.push({"host_name": hostName});
+      });
+      //wrap properties into Em.Object to make them compatible with buildGroupDesiredConfigs method
+      configGroup.properties.forEach(function (property) {
+        groupConfigs.push(Em.Object.create(property));
+      });
+      groupData.desired_configs = serviceConfigController.buildGroupDesiredConfigs.call(serviceConfigController, groupConfigs);
+      sendData.push({"ConfigGroup": groupData});
+    }, this);
+    this.applyConfigurationGroups(sendData);
+  },
+
+  applyConfigurationGroups: function (sendData) {
+    var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/config_groups';
+    this.ajax({
+      type: 'POST',
+      url: url,
+      data: JSON.stringify(sendData)
+    });
+  },
+
   createGlobalSiteObj: function () {
     var globalSiteProperties = {};
     var globalSiteObj = this.get('globals');