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

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


The following commit(s) were added to refs/heads/branch-feature-AMBARI-14714 by 
this push:
     new 905b780  [AMBARI-23191] Use service config API (#691)
905b780 is described below

commit 905b78051996ee3cd7ce24fa3c94717b26bfda2c
Author: Jason Golieb <j...@golieb.net>
AuthorDate: Tue Mar 20 13:27:45 2018 -0400

    [AMBARI-23191] Use service config API (#691)
    
    * Add newline to avoid audit failures
    
    * Fixed bug with clearing host recommendations when selected services are 
changed.
    
    * Implemented use of service config API in installer.
    
    * Revised unit test.
---
 .../server/orm/entities/RepoDefinitionEntity.java  |  2 +-
 .../app/controllers/wizard/step8_controller.js     | 36 +++++++++-------------
 ambari-web/app/routes/installer.js                 |  6 ++--
 ambari-web/app/utils/ajax/ajax.js                  | 12 ++++++++
 ambari-web/test/controllers/wizard/step8_test.js   | 34 +++++++++-----------
 5 files changed, 46 insertions(+), 44 deletions(-)

diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RepoDefinitionEntity.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RepoDefinitionEntity.java
index edcc1f1..f308fd2 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RepoDefinitionEntity.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RepoDefinitionEntity.java
@@ -241,4 +241,4 @@ public class RepoDefinitionEntity {
       repositoryDefinition.setTags(repositoryInfo.getTags());
       return repositoryDefinition;
     }
-  }
\ No newline at end of file
+  }
diff --git a/ambari-web/app/controllers/wizard/step8_controller.js 
b/ambari-web/app/controllers/wizard/step8_controller.js
index a780700..e4da276 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/ambari-web/app/controllers/wizard/step8_controller.js
@@ -1568,39 +1568,33 @@ App.WizardStep8Controller = 
App.WizardStepController.extend(App.AddSecurityConfi
    */
   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;
-            })
+        //TODO: Remove this delete call when the API supports 
service_config_version_note
+        serviceConfigData.forEach(scd => {
+          delete scd.service_config_version_note;
+        })
+
+        this.addRequestToAjaxQueue({
+          name: 'common.service.create.configs',
+          data: {
+            serviceName: service.get('serviceName'),
+            serviceGroupName: 
`${service.get('stackName')}-${service.get('stackVersion')}`,
+            data: serviceConfigData
           }
-        }));
+        });    
       }
     }, this);
-
-    this.addRequestToAjaxQueue({
-      name: 'common.across.services.configurations',
-      data: {
-        data: '[' + allConfigData.toString() + ']'
-      }
-    });
   },
 
   /**
diff --git a/ambari-web/app/routes/installer.js 
b/ambari-web/app/routes/installer.js
index ffa392f..2082052 100644
--- a/ambari-web/app/routes/installer.js
+++ b/ambari-web/app/routes/installer.js
@@ -303,16 +303,16 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
         controller.save('selectedServices');
         controller.save('selectedMpacks');
         controller.save('advancedMode');
-        var wizardStep6Controller = router.get('wizardStep6Controller');
+        var wizardSelectMpacksController = 
router.get('wizardSelectMpacksController');
         // Clear subsequent settings if user changed service selections
-        if (!wizardStep6Controller.get('isSaved')) {
+        if (!wizardSelectMpacksController.get('isSaved')) {
           router.get('wizardStep5Controller').clearRecommendations();
           controller.setDBProperty('recommendations', undefined);
           controller.set('content.masterComponentHosts', undefined);
           controller.setDBProperty('masterComponentHosts', undefined);
           controller.clearEnhancedConfigs();
           controller.setDBProperty('slaveComponentHosts', undefined);
-          wizardStep6Controller.set('isClientsSet', false);
+          router.get('wizardStep6Controller').set('isClientsSet', false);
         }
         controller.setStepSaved('selectMpacks');
         const downloadConfig = controller.get('content.downloadConfig');
diff --git a/ambari-web/app/utils/ajax/ajax.js 
b/ambari-web/app/utils/ajax/ajax.js
index 674d792..f00f08a 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -228,6 +228,7 @@ var urls = {
     }
   },
 
+  //This is now legacy and should be replaced by common.service.create.configs 
below
   'common.across.services.configurations': {
     'type': 'PUT',
     'real':'/clusters/{clusterName}',
@@ -240,6 +241,17 @@ var urls = {
     }
   },
 
+  'common.service.create.configs': {
+    'type': 'POST',
+    
'real':'/clusters/{clusterName}/servicegroups/{serviceGroupName}/services/{serviceName}/configurations',
+    'format': function(data) {
+      return {
+        apiPrefix: 'api/v2',
+        data: JSON.stringify(data.data)
+      }
+    }
+  },
+
   'common.request.polling': {
     'real': 
'/clusters/{clusterName}/requests/{requestId}?fields=tasks/Tasks/request_id,tasks/Tasks/command,tasks/Tasks/command_detail,tasks/Tasks/ops_display_name,tasks/Tasks/start_time,tasks/Tasks/end_time,tasks/Tasks/exit_code,tasks/Tasks/host_name,tasks/Tasks/id,tasks/Tasks/role,tasks/Tasks/status,tasks/Tasks/structured_out,Requests/*&tasks/Tasks/stage_id={stageId}',
     'mock': '/data/background_operations/host_upgrade_tasks.json'
diff --git a/ambari-web/test/controllers/wizard/step8_test.js 
b/ambari-web/test/controllers/wizard/step8_test.js
index 597265d..896a731 100644
--- a/ambari-web/test/controllers/wizard/step8_test.js
+++ b/ambari-web/test/controllers/wizard/step8_test.js
@@ -1302,30 +1302,26 @@ describe('App.WizardStep8Controller', function () {
     describe('#applyConfigurationsToCluster', function() {
       it('should call addRequestToAjaxQueue', function() {
         var serviceConfigTags = [
-            {
-              type: 'hdfs',
-              tag: 'tag1',
-              properties: {
-                'prop1': 'value1'
-              }
-            }
-          ],
-          data = '['+JSON.stringify({
-            Clusters: {
-              desired_config: [serviceConfigTags[0]]
+          {
+            type: 'hdfs',
+            properties: {
+              'prop1': 'value1'
             }
-          })+']';
+          }
+        ];
+
         installerStep8Controller.reopen({
           installedServices: [
-              Em.Object.create({
-                isSelected: true,
-                isInstalled: false,
-                configTypesRendered: {hdfs:'tag1'}
-              })
-            ], selectedServices: []
+            Em.Object.create({
+              isSelected: true,
+              isInstalled: false,
+              configTypesRendered: { hdfs: 'tag1' }
+            })
+          ],
+          selectedServices: []
         });
         
installerStep8Controller.applyConfigurationsToCluster(serviceConfigTags);
-        
expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.equal(data);
+        
expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.deep.equal(serviceConfigTags);
       });
     });
 

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

Reply via email to