incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jai...@apache.org
Subject svn commit: r1459397 - in /incubator/ambari/trunk: ./ ambari-web/app/ ambari-web/app/controllers/main/ ambari-web/app/controllers/main/admin/security/ ambari-web/app/controllers/main/admin/security/add/ ambari-web/app/data/ ambari-web/app/routes/
Date Thu, 21 Mar 2013 16:53:47 GMT
Author: jaimin
Date: Thu Mar 21 16:53:46 2013
New Revision: 1459397

URL: http://svn.apache.org/r1459397
Log:
AMBARI-1672. Security Wizard - integrate with cluster-level config API. (jaimin)

Modified:
    incubator/ambari/trunk/CHANGES.txt
    incubator/ambari/trunk/ambari-web/app/controllers/main/admin.js
    incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step3.js
    incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/disable.js
    incubator/ambari/trunk/ambari-web/app/data/secure_configs.js
    incubator/ambari/trunk/ambari-web/app/messages.js
    incubator/ambari/trunk/ambari-web/app/routes/main.js

Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1459397&r1=1459396&r2=1459397&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Thu Mar 21 16:53:46 2013
@@ -145,6 +145,8 @@ Trunk (unreleased changes):
 
  IMPROVEMENTS
 
+ AMBARI-1672. Security Wizard - integrate with cluster-level config API. (jaimin)
+
  AMBARI-1669. Security Wizard UI tweaks. (jaimin)
 
  AMBARI-1630. Expose HUE config parameters through Ambari Web. (yusaku)

Modified: incubator/ambari/trunk/ambari-web/app/controllers/main/admin.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/admin.js?rev=1459397&r1=1459396&r2=1459397&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/main/admin.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/main/admin.js Thu Mar 21 16:53:46 2013
@@ -35,7 +35,7 @@ App.MainAdminController = Em.Controller.
         dfd.resolve();
       }, 50);
     } else {
-      this.getHDFSDetailsFromServer(dfd);
+      this.getSecurityStatusFromServer(dfd);
     }
     return dfd.promise();
   },
@@ -43,9 +43,9 @@ App.MainAdminController = Em.Controller.
   /**
    * return true if security status is loaded and false otherwise
    */
-  getHDFSDetailsFromServer: function (dfd) { //TODO: this should be obtain from cluster level
config rather than HDFS global config
+  getSecurityStatusFromServer: function (dfd) { //TODO: this should be obtain from cluster
level config rather than HDFS global config
     var self = this;
-    var url = App.apiPrefix + '/clusters/' + App.router.getClusterName() + '/services/HDFS';
+    var url = App.apiPrefix + '/clusters/' + App.router.getClusterName();
     $.ajax({
       type: 'GET',
       url: url,
@@ -55,9 +55,9 @@ App.MainAdminController = Em.Controller.
       success: function (data) {
         console.log("TRACE: The url is: " + url);
         var jsonData = jQuery.parseJSON(data);
-        var configs = jsonData.ServiceInfo.desired_configs;
+        var configs = jsonData.Clusters.desired_configs;
         if ('global' in configs) {
-          self.getServiceConfigsFromServer(dfd, 'global', configs['global']);
+          self.getServiceConfigsFromServer(dfd, 'global', configs['global'].tag);
         } else {
           if (dfd) {
             dfd.reject();

Modified: incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step3.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step3.js?rev=1459397&r1=1459396&r2=1459397&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step3.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step3.js Thu
Mar 21 16:53:46 2013
@@ -39,13 +39,13 @@ App.MainAdminSecurityAddStep3Controller 
   }.property('content.services'),
 
   serviceUsersBinding: 'App.router.mainAdminController.serviceUsers',
-  hasHostPopup:true,
-  services:[],
+  hasHostPopup: true,
+  services: [],
   serviceTimestamp: null,
 
   clearStep: function () {
     this.get('stages').clear();
-    this.set('isSubmitDisabled',true);
+    this.set('isSubmitDisabled', true);
   },
 
   loadStep: function () {
@@ -59,17 +59,17 @@ App.MainAdminSecurityAddStep3Controller 
   updateServices: function () {
     this.services.clear();
     var services = this.get("services");
-    this.get("stages").forEach(function(stages){
+    this.get("stages").forEach(function (stages) {
       var newService = Ember.Object.create({
-        name:stages.label,
-        hosts:[]
+        name: stages.label,
+        hosts: []
       });
       var hostNames = stages.get("polledData").mapProperty('Tasks.host_name').uniq();
-      hostNames.forEach(function(name){
+      hostNames.forEach(function (name) {
         newService.hosts.push({
-          name:name,
-          publicName:name,
-          logTasks:stages.polledData
+          name: name,
+          publicName: name,
+          logTasks: stages.polledData
         });
       });
       services.push(newService);
@@ -97,7 +97,7 @@ App.MainAdminSecurityAddStep3Controller 
           currentStage.set('isCompleted', true);
           this.moveToNextStage();
         } else {
-          this.loadConfigsForAllServices();
+          this.loadClusterConfigs();
         }
       }
     }
@@ -116,6 +116,16 @@ App.MainAdminSecurityAddStep3Controller 
     }
   }.observes('stages.@each.isCompleted'),
 
+  moveToNextStage: function () {
+    var nextStage = this.get('stages').findProperty('isStarted', false);
+    if (nextStage) {
+      nextStage.set('isStarted', true);
+      this.set('isSubmitDisabled', true);
+    } else {
+      this.set('isSubmitDisabled', false);
+    }
+  },
+
   addInfoToStages: function () {
     this.addInfoToStage2();
     this.addInfoToStage3();
@@ -325,45 +335,32 @@ App.MainAdminSecurityAddStep3Controller 
       serviceUsers.pushObject({id: 'puppet var', name: 'hbase_user', value: 'hbase'});
       serviceUsers.pushObject({id: 'puppet var', name: 'hive_user', value: 'hive'});
     } else {
-      App.router.get('mainAdminController').getHDFSDetailsFromServer();
+      App.router.get('mainAdminController').getSecurityStatusFromServer();
     }
   },
 
-  loadConfigsForAllServices: function () {
-    this.set('noOfWaitingAjaxCalls', this.get('content.services').length - 1);
-    this.get('content.services').forEach(function (_secureService, index) {
-      if (_secureService.serviceName !== 'GENERAL') {
-        this.getConfigDetailsFromServer(_secureService, index);
-      }
-    }, this);
-  },
-
-  getConfigDetailsFromServer: function (secureService, id) {
+  loadClusterConfigs: function () {
     var self = this;
-    var url = App.apiPrefix + '/clusters/' + App.router.getClusterName() + '/services/' +
secureService.serviceName;
+    var url = App.apiPrefix + '/clusters/' + App.router.getClusterName();
     $.ajax({
       type: 'GET',
       url: url,
       timeout: 10000,
       dataType: 'text',
       success: function (data) {
-        console.log("TRACE: In success function for the GET getServciceConfigs call");
-        console.log("TRACE: The url is: " + url);
         var jsonData = jQuery.parseJSON(data);
 
         //prepare tags to fetch all configuration for a service
-        self.setServiceTagNames(secureService.serviceName, jsonData.ServiceInfo.desired_configs);
-        self.set('noOfWaitingAjaxCalls', self.get('noOfWaitingAjaxCalls') - 1);
-
-        if (self.get('noOfWaitingAjaxCalls') == 0) {
-          self.getAllConfigsFromServer();
-        }
+        self.get('content.services').forEach(function (_secureService) {
+          if (_secureService.serviceName !== 'GENERAL') {
+            self.setServiceTagNames(_secureService, jsonData.Clusters.desired_configs);
+          }
+        });
+        self.getAllConfigurations();
       },
 
       error: function (request, ajaxOptions, error) {
         self.get('stages').findProperty('stage', 'stage3').set('isError', true);
-        console.log("TRACE: In error function for the getServciceConfigs call");
-        console.log("TRACE: value of the url is: " + url);
         console.log("TRACE: error code status is: " + request.status);
       },
 
@@ -371,115 +368,51 @@ App.MainAdminSecurityAddStep3Controller 
     });
   },
 
+
   /**
    * set tagnames for configuration of the *-site.xml
    */
-  setServiceTagNames: function (secureServiceName, configs) {
+  setServiceTagNames: function (secureService, configs) {
     console.log("TRACE: In setServiceTagNames function:");
     //var serviceConfigTags = this.get('serviceConfigTags');
     for (var index in configs) {
-      var serviceConfigObj = {
-        serviceName: secureServiceName,
-        siteName: index,
-        tagName: configs[index],
-        newTagName: null,
-        configs: {}
-      };
-      console.log("The value of serviceConfigTags[index]: " + configs[index]);
-      this.get('serviceConfigTags').pushObject(serviceConfigObj);
+      if (secureService.sites.contains(index)) {
+        var serviceConfigObj = {
+          siteName: index,
+          tagName: configs[index].tag,
+          newTagName: null,
+          configs: {}
+        };
+        console.log("The value of serviceConfigTags[index]: " + configs[index]);
+        this.get('serviceConfigTags').pushObject(serviceConfigObj);
+      }
     }
     return serviceConfigObj;
   },
 
-
-  getAllConfigsFromServer: function () {
-    this.set('noOfWaitingAjaxCalls', this.get('serviceConfigTags').length - 1);
-    this.get('serviceConfigTags').forEach(function (_serviceConfigTags) {
-      if (_serviceConfigTags.serviceName !== 'MAPREDUCE' || _serviceConfigTags.siteName !==
'core-site') {   //skip MapReduce core-site configuration
-        this.getServiceConfigsFromServer(_serviceConfigTags);
-      }
-    }, this);
-  },
-
-
-  createConfigurations: function () {
-    this.set('noOfWaitingAjaxCalls', this.get('serviceConfigTags').length - 1);
-    this.get('serviceConfigTags').forEach(function (_serviceConfigTags) {
-      if (_serviceConfigTags.serviceName !== 'MAPREDUCE' || _serviceConfigTags.siteName !==
'core-site') {   //skip MapReduce core-site configuration
-        this.createConfiguration(_serviceConfigTags);
-      }
+  applyConfigurationsToCluster: function () {
+    this.set('noOfWaitingAjaxCalls', this.get('serviceConfigTags').length);
+    this.get('serviceConfigTags').forEach(function (_serviceConfig) {
+      this.applyConfigurationToCluster({type: _serviceConfig.siteName, tag: _serviceConfig.newTagName,
properties: _serviceConfig.configs});
     }, this);
   },
 
-  createConfiguration: function (serviceConfigTags) {
+  applyConfigurationToCluster: function (data) {
     var self = this;
-    var clusterName = App.router.getClusterName();
-    var url = App.apiPrefix + '/clusters/' + clusterName + '/configurations';
-    var data = this.createConfigurationData(serviceConfigTags);
-    $.ajax({
-      type: 'POST',
-      url: url,
-      data: JSON.stringify(data),
-      dataType: 'text',
-      timeout: 5000,
-      success: function (data) {
-        var jsonData = jQuery.parseJSON(data);
-        self.set('noOfWaitingAjaxCalls', self.get('noOfWaitingAjaxCalls') - 1);
-        if (self.get('noOfWaitingAjaxCalls') == 0) {
-          self.applyConfigurationToServices();
-        }
-      },
-
-      error: function (request, ajaxOptions, error) {
-        self.get('stages').findProperty('stage', 'stage3').set('isError', true);
-        console.log('TRACE: In Error ');
-        console.log('TRACE: Error message is: ' + request.responseText);
-        console.log("TRACE: value of the url is: " + url);
-      },
-
-      statusCode: require('data/statusCodes')
-    });
-
-  },
-
-  createConfigurationData: function (serviceConfigTags) {
-    return {"type": serviceConfigTags.siteName, "tag": serviceConfigTags.newTagName, "properties":
serviceConfigTags.configs};
-  },
-
-  applyConfigurationToServices: function () {
-    this.applyHdfsCoretoMaprCore();
-    this.set('noOfWaitingAjaxCalls', this.get('content.services').length - 1);
-    this.set('noOfWaitingAjaxCalls', this.get('content.services').length - 1);
-    this.get('content.services').forEach(function (_service) {
-      if (_service.serviceName !== 'GENERAL') {
-        var data = {config: {}};
-        this.get('serviceConfigTags').filterProperty('serviceName', _service.serviceName).forEach(function
(_serviceConfig) {
-          data.config[_serviceConfig.siteName] = _serviceConfig.newTagName;
-        }, this);
-        this.applyConfToService(_service.serviceName, data);
+    var url = App.apiPrefix + '/clusters/' + App.router.getClusterName();
+    var clusterData = {
+      Clusters: {
+        desired_config: data
       }
-    }, this);
-  },
-
-  applyHdfsCoretoMaprCore: function () {
-    this.get('serviceConfigTags').filterProperty('serviceName', 'MAPREDUCE').findProperty('siteName',
'core-site').newTagName = this.get('serviceConfigTags').filterProperty('serviceName', 'HDFS').findProperty('siteName',
'core-site').newTagName;
-  },
-
-  applyConfToService: function (serviceName, data) {
-    var self = this;
-    var clusterName = App.router.getClusterName();
-    var url = App.apiPrefix + '/clusters/' + clusterName + '/services/' + serviceName;
+    };
     $.ajax({
       type: 'PUT',
       url: url,
       async: false,
       dataType: 'text',
-      data: JSON.stringify(data),
+      data: JSON.stringify(clusterData),
       timeout: 5000,
       success: function (data) {
-        var jsonData = jQuery.parseJSON(data);
-        console.log("TRACE: In success function for the applyCreatedConfToService call");
-        console.log("TRACE: value of the url is: " + url);
         self.set('noOfWaitingAjaxCalls', self.get('noOfWaitingAjaxCalls') - 1);
         if (self.get('noOfWaitingAjaxCalls') == 0) {
           var currentStage = self.get('stages').findProperty('stage', 'stage3');
@@ -487,77 +420,64 @@ App.MainAdminSecurityAddStep3Controller 
           currentStage.set('isCompleted', true);
         }
       },
-
       error: function (request, ajaxOptions, error) {
         self.get('stages').findProperty('stage', 'stage3').set('isError', true);
-        console.log('Error: In Error of apply');
-        console.log('Error: Error message is: ' + request.responseText);
       },
-
       statusCode: require('data/statusCodes')
     });
-    console.log("Exiting applyCreatedConfToService");
 
   },
 
-  moveToNextStage: function () {
-    var nextStage = this.get('stages').findProperty('isStarted', false);
-    if (nextStage) {
-      nextStage.set('isStarted', true);
-      this.set('isSubmitDisabled', true);
-    } else {
-      this.set('isSubmitDisabled', false);
-    }
-  },
 
   /**
    * gets site config properties from server and sets it for every configuration
    * @param serviceConfigTags
    */
 
-  getServiceConfigsFromServer: function (serviceConfigTags) {
+  getAllConfigurations: function () {
     var self = this;
-    var properties = {};
-    var url = App.apiPrefix + '/clusters/' + App.router.getClusterName() + '/configurations/?type='
+ serviceConfigTags.siteName + '&tag=' + serviceConfigTags.tagName;
-    $.ajax({
-      type: 'GET',
-      url: url,
-      async: true,
-      timeout: 10000,
-      dataType: 'json',
-      success: function (data) {
-        console.log("TRACE: In success function for the GET getServiceConfigsFromServer call");
-        console.log("TRACE: The url is: " + url);
-        serviceConfigTags.configs = data.items.findProperty('tag', serviceConfigTags.tagName).properties;
-        self.set('noOfWaitingAjaxCalls', self.get('noOfWaitingAjaxCalls') - 1);
-
-        if (self.get('noOfWaitingAjaxCalls') == 0) {
+    var urlParams = [];
+    this.get('serviceConfigTags').forEach(function (_tag) {
+      urlParams.push('(type=' + _tag.siteName + '&tag=' + _tag.tagName + ')');
+    }, this);
+    var url = App.apiPrefix + '/clusters/' + App.router.getClusterName() + '/configurations?'
+ urlParams.join('|');
+    if (urlParams.length > 0) {
+      $.ajax({
+        type: 'GET',
+        url: url,
+        async: true,
+        timeout: 10000,
+        dataType: 'json',
+        success: function (data) {
+          console.log("TRACE: In success function for the GET getServiceConfigsFromServer
call");
+          console.log("TRACE: The url is: " + url);
+          self.get('serviceConfigTags').forEach(function (_tag) {
+            _tag.configs = data.items.findProperty('type', _tag.siteName).properties;
+          });
           self.addSecureConfigs();
-          self.createConfigurations();
-        }
-      },
+          self.applyConfigurationsToCluster();
+        },
 
-      error: function (request, ajaxOptions, error) {
-        self.get('stages').findProperty('stage', 'stage3').set('isError', true);
-        console.log("TRACE: In error function for the getServiceConfigsFromServer call");
-        console.log("TRACE: value of the url is: " + url);
-        console.log("TRACE: error code status is: " + request.status);
-      },
+        error: function (request, ajaxOptions, error) {
+          self.get('stages').findProperty('stage', 'stage3').set('isError', true);
+          console.log("TRACE: In error function for the getServiceConfigsFromServer call");
+          console.log("TRACE: value of the url is: " + url);
+          console.log("TRACE: error code status is: " + request.status);
+        },
 
-      statusCode: require('data/statusCodes')
-    });
+        statusCode: require('data/statusCodes')
+      });
+    }
   },
 
-
   addSecureConfigs: function () {
     this.get('serviceConfigTags').forEach(function (_serviceConfigTags, index) {
+      _serviceConfigTags.newTagName = 'version' + (new Date).getTime();
       if (_serviceConfigTags.siteName === 'global') {
-        _serviceConfigTags.newTagName = 'version' + (new Date).getTime() + index;
         this.get('globalProperties').forEach(function (_globalProperty) {
           _serviceConfigTags.configs[_globalProperty.name] = _globalProperty.value;
         }, this);
       } else {
-        _serviceConfigTags.newTagName = 'version' + (new Date).getTime();
         this.get('configs').filterProperty('id', 'site property').filterProperty('filename',
_serviceConfigTags.siteName + '.xml').forEach(function (_config) {
           _serviceConfigTags.configs[_config.name] = _config.value;
         }, this);

Modified: incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/disable.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/disable.js?rev=1459397&r1=1459396&r2=1459397&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/disable.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/disable.js Thu Mar
21 16:53:46 2013
@@ -51,6 +51,16 @@ App.MainAdminSecurityDisableController =
     ]);
   },
 
+
+  moveToNextStage: function () {
+    var nextStage = this.get('stages').findProperty('isStarted', false);
+    if (nextStage) {
+      nextStage.set('isStarted', true);
+    } else {
+      this.set('isSubmitDisabled', false);
+    }
+  },
+
   startStage: function () {
     var startedStages = this.get('stages').filterProperty('isStarted', true);
     if (startedStages.length) {
@@ -63,7 +73,7 @@ App.MainAdminSecurityDisableController =
           currentStage.set('isCompleted', true);
           this.moveToNextStage();
         } else {
-          this.loadConfigsForAllServices();
+          this.loadClusterConfigs();
         }
       }
     }
@@ -116,88 +126,113 @@ App.MainAdminSecurityDisableController =
     stage4.set('data', data);
   },
 
-  loadSecureServices: function () {
-    var secureServices = require('data/secure_configs');
-    var installedServices = App.Service.find().mapProperty('serviceName');
-    //General (only non service tab) tab is always displayed
-    installedServices.forEach(function (_service) {
-      var secureService = secureServices.findProperty('serviceName', _service);
-      if (secureService) {
-        this.get('secureServices').push(secureService);
-      }
-    }, this);
-  },
-
-  /**
-   * gets site config properties from server and sets it for every configuration
-   * @param serviceConfigTags
-   */
-
-  getServiceConfigsFromServer: function (serviceConfigTags) {
+  loadClusterConfigs: function () {
     var self = this;
-    var properties = {};
-    var url = App.apiPrefix + '/clusters/' + App.router.getClusterName() + '/configurations/?type='
+ serviceConfigTags.siteName + '&tag=' + serviceConfigTags.tagName;
+    var url = App.apiPrefix + '/clusters/' + App.router.getClusterName();
     $.ajax({
       type: 'GET',
       url: url,
-      async: true,
       timeout: 10000,
-      dataType: 'json',
+      dataType: 'text',
       success: function (data) {
-        console.log("TRACE: In success function for the GET getServiceConfigsFromServer call");
-        console.log("TRACE: The url is: " + url);
-        serviceConfigTags.configs = data.items.findProperty('tag', serviceConfigTags.tagName).properties;
-        self.set('noOfWaitingAjaxCalls', self.get('noOfWaitingAjaxCalls') - 1);
-
-        if (self.get('noOfWaitingAjaxCalls') == 0) {
-          self.removeSecureConfigs();
-          self.createConfigurations();
-        }
+        var jsonData = jQuery.parseJSON(data);
+        //prepare tags to fetch all configuration for a service
+        self.get('secureServices').forEach(function (_secureService) {
+          self.setServiceTagNames(_secureService, jsonData.Clusters.desired_configs);
+        });
+        self.getAllConfigurations();
       },
 
       error: function (request, ajaxOptions, error) {
         self.get('stages').findProperty('stage', 'stage3').set('isError', true);
+        console.log("TRACE: error code status is: " + request.status);
       },
 
       statusCode: require('data/statusCodes')
     });
   },
-  loadConfigsForAllServices: function () {
-    this.set('noOfWaitingAjaxCalls', this.get('secureServices').length);
-    this.get('secureServices').forEach(function (_secureService, index) {
-      this.getConfigDetailsFromServer(_secureService, index);
+
+  getAllConfigurations: function () {
+    var self = this;
+    var urlParams = [];
+    this.get('serviceConfigTags').forEach(function (_tag) {
+      urlParams.push('(type=' + _tag.siteName + '&tag=' + _tag.tagName + ')');
+    }, this);
+    var url = App.apiPrefix + '/clusters/' + App.router.getClusterName() + '/configurations?'
+ urlParams.join('|');
+    if (urlParams.length > 0) {
+      $.ajax({
+        type: 'GET',
+        url: url,
+        async: true,
+        timeout: 10000,
+        dataType: 'json',
+        success: function (data) {
+          console.log("TRACE: In success function for the GET getServiceConfigsFromServer
call");
+          console.log("TRACE: The url is: " + url);
+          self.get('serviceConfigTags').forEach(function (_tag) {
+            _tag.configs = data.items.findProperty('type', _tag.siteName).properties;
+          });
+          self.removeSecureConfigs();
+          self.applyConfigurationsToCluster();
+        },
+
+        error: function (request, ajaxOptions, error) {
+          self.get('stages').findProperty('stage', 'stage3').set('isError', true);
+          console.log("TRACE: In error function for the getServiceConfigsFromServer call");
+          console.log("TRACE: value of the url is: " + url);
+          console.log("TRACE: error code status is: " + request.status);
+        },
+
+        statusCode: require('data/statusCodes')
+      });
+    }
+  },
+
+  loadSecureServices: function () {
+    var secureServices = require('data/secure_configs');
+    var installedServices = App.Service.find().mapProperty('serviceName');
+    //General (only non service tab) tab is always displayed
+    installedServices.forEach(function (_service) {
+      var secureService = secureServices.findProperty('serviceName', _service);
+      if (secureService) {
+        this.get('secureServices').push(secureService);
+      }
+    }, this);
+  },
+
+  applyConfigurationsToCluster: function () {
+    this.set('noOfWaitingAjaxCalls', this.get('serviceConfigTags').length);
+    this.get('serviceConfigTags').forEach(function (_serviceConfig) {
+      this.applyConfigurationToCluster({type: _serviceConfig.siteName, tag: _serviceConfig.newTagName,
properties: _serviceConfig.configs});
     }, this);
   },
 
-  getConfigDetailsFromServer: function (secureService, id) {
+  applyConfigurationToCluster: function (data) {
     var self = this;
-    var url = App.apiPrefix + '/clusters/' + App.router.getClusterName() + '/services/' +
secureService.serviceName;
+    var url = App.apiPrefix + '/clusters/' + App.router.getClusterName();
+    var clusterData = {
+      Clusters: {
+        desired_config: data
+      }
+    };
     $.ajax({
-      type: 'GET',
+      type: 'PUT',
       url: url,
-      timeout: 10000,
+      async: false,
       dataType: 'text',
+      data: JSON.stringify(clusterData),
+      timeout: 5000,
       success: function (data) {
-        console.log("TRACE: In success function for the GET getServciceConfigs call");
-        console.log("TRACE: The url is: " + url);
-        var jsonData = jQuery.parseJSON(data);
-
-        //prepare tags to fetch all configuration for a service
-        self.setServiceTagNames(secureService.serviceName, jsonData.ServiceInfo.desired_configs);
         self.set('noOfWaitingAjaxCalls', self.get('noOfWaitingAjaxCalls') - 1);
-
         if (self.get('noOfWaitingAjaxCalls') == 0) {
-          self.getAllConfigsFromServer();
+          var currentStage = self.get('stages').findProperty('stage', 'stage3');
+          currentStage.set('isSuccess', true);
+          currentStage.set('isCompleted', true);
         }
       },
-
       error: function (request, ajaxOptions, error) {
         self.get('stages').findProperty('stage', 'stage3').set('isError', true);
-        console.log("TRACE: In error function for the getServciceConfigs call");
-        console.log("TRACE: value of the url is: " + url);
-        console.log("TRACE: error code status is: " + request.status);
       },
-
       statusCode: require('data/statusCodes')
     });
   },
@@ -212,7 +247,7 @@ App.MainAdminSecurityDisableController =
       var serviceConfigObj = {
         serviceName: secureServiceName,
         siteName: index,
-        tagName: configs[index],
+        tagName: configs[index].tag,
         newTagName: null,
         configs: {}
       };
@@ -232,111 +267,10 @@ App.MainAdminSecurityDisableController =
     }, this);
   },
 
-
-  createConfigurations: function () {
-    this.set('noOfWaitingAjaxCalls', this.get('serviceConfigTags').length - 1);
-    this.get('serviceConfigTags').forEach(function (_serviceConfigTags) {
-      if (_serviceConfigTags.serviceName !== 'MAPREDUCE' || _serviceConfigTags.siteName !==
'core-site') {   //skip MapReduce core-site configuration
-        this.createConfiguration(_serviceConfigTags);
-      }
-    }, this);
-  },
-
-  createConfiguration: function (serviceConfigTags) {
-    var self = this;
-    var clusterName = App.router.getClusterName();
-    var url = App.apiPrefix + '/clusters/' + clusterName + '/configurations';
-    var data = this.createConfigurationData(serviceConfigTags);
-    $.ajax({
-      type: 'POST',
-      url: url,
-      data: JSON.stringify(data),
-      dataType: 'text',
-      timeout: 5000,
-      success: function (data) {
-        var jsonData = jQuery.parseJSON(data);
-        self.set('noOfWaitingAjaxCalls', self.get('noOfWaitingAjaxCalls') - 1);
-        if (self.get('noOfWaitingAjaxCalls') == 0) {
-          self.applyConfigurationToServices();
-        }
-      },
-
-      error: function (request, ajaxOptions, error) {
-        self.get('stages').findProperty('stage', 'stage3').set('isError', true);
-        console.log('TRACE: In Error ');
-        console.log('TRACE: Error message is: ' + request.responseText);
-        console.log("TRACE: value of the url is: " + url);
-      },
-
-      statusCode: require('data/statusCodes')
-    });
-
-  },
-
-  createConfigurationData: function (serviceConfigTags) {
-    return {"type": serviceConfigTags.siteName, "tag": serviceConfigTags.newTagName, "properties":
serviceConfigTags.configs};
-  },
-
-  applyConfigurationToServices: function () {
-    this.applyHdfsCoretoMaprCore();
-    this.set('noOfWaitingAjaxCalls', this.get('secureServices').length);
-    this.get('secureServices').forEach(function (_service) {
-      var data = {config: {}};
-      this.get('serviceConfigTags').filterProperty('serviceName', _service.serviceName).forEach(function
(_serviceConfig) {
-        data.config[_serviceConfig.siteName] = _serviceConfig.newTagName;
-      }, this);
-      this.applyConfToService(_service.serviceName, data);
-
-    }, this);
-  },
-
-  applyHdfsCoretoMaprCore: function () {
-    this.get('serviceConfigTags').filterProperty('serviceName', 'MAPREDUCE').findProperty('siteName',
'core-site').newTagName = this.get('serviceConfigTags').filterProperty('serviceName', 'HDFS').findProperty('siteName',
'core-site').newTagName;
-  },
-
-  applyConfToService: function (serviceName, data) {
-    var self = this;
-    var clusterName = App.router.getClusterName();
-    var url = App.apiPrefix + '/clusters/' + clusterName + '/services/' + serviceName;
-    $.ajax({
-      type: 'PUT',
-      url: url,
-      async: false,
-      dataType: 'text',
-      data: JSON.stringify(data),
-      timeout: 5000,
-      success: function (data) {
-        self.set('noOfWaitingAjaxCalls', self.get('noOfWaitingAjaxCalls') - 1);
-        if (self.get('noOfWaitingAjaxCalls') == 0) {
-          var currentStage = self.get('stages').findProperty('stage', 'stage3');
-          currentStage.set('isSuccess', true);
-          currentStage.set('isCompleted', true);
-        }
-      },
-
-      error: function (request, ajaxOptions, error) {
-        self.get('stages').findProperty('stage', 'stage3').set('isError', true);
-      },
-
-      statusCode: require('data/statusCodes')
-    });
-    console.log("Exiting applyCreatedConfToService");
-
-  },
-
-  moveToNextStage: function () {
-    var nextStage = this.get('stages').findProperty('isStarted', false);
-    if (nextStage) {
-      nextStage.set('isStarted', true);
-    } else {
-      this.set('isSubmitDisabled', false);
-    }
-  },
-
   removeSecureConfigs: function () {
     this.get('serviceConfigTags').forEach(function (_serviceConfigTags, index) {
+      _serviceConfigTags.newTagName = 'version' + (new Date).getTime();
       if (_serviceConfigTags.siteName === 'global') {
-        _serviceConfigTags.newTagName = 'version' + (new Date).getTime() + index;
         this.get('secureProperties').forEach(function (_config) {
           if (_config.name in _serviceConfigTags.configs) {
             delete _serviceConfigTags.configs[_config.name];
@@ -344,7 +278,6 @@ App.MainAdminSecurityDisableController =
         }, this);
         _serviceConfigTags.configs.security_enabled = false;
       } else {
-        _serviceConfigTags.newTagName = 'version' + (new Date).getTime();
         this.get('configMapping').filterProperty('filename', _serviceConfigTags.siteName
+ '.xml').forEach(function (_config) {
           if (_config.name in _serviceConfigTags.configs) {
             if (_config.name === 'dfs.datanode.address') {

Modified: incubator/ambari/trunk/ambari-web/app/data/secure_configs.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/data/secure_configs.js?rev=1459397&r1=1459396&r2=1459397&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/data/secure_configs.js (original)
+++ incubator/ambari/trunk/ambari-web/app/data/secure_configs.js Thu Mar 21 16:53:46 2013
@@ -43,6 +43,7 @@ module.exports = [
       App.ServiceConfigCategory.create({ name: 'SNameNode',displayName: 'SNameNode'}),
       App.ServiceConfigCategory.create({ name: 'DataNode', displayName: 'DataNode'})
     ],
+    sites: ['global', 'core-site', 'hdfs-site'],
     configs: configProperties.filterProperty('serviceName', 'HDFS')
   },
 
@@ -54,6 +55,7 @@ module.exports = [
       App.ServiceConfigCategory.create({ name: 'JobTracker', displayName: 'JobTracker'}),
       App.ServiceConfigCategory.create({ name: 'TaskTracker', displayName: 'TaskTracker'})
     ],
+    sites: ['mapred-site'],
     configs: configProperties.filterProperty('serviceName', 'MAPREDUCE')
   },
 
@@ -64,6 +66,7 @@ module.exports = [
     configCategories: [
       App.ServiceConfigCategory.create({ name: 'Hive Metastore', displayName: 'Hive Metastore'})
     ],
+    sites: ['hive-site'],
     configs: configProperties.filterProperty('serviceName', 'HIVE')
   },
 
@@ -74,6 +77,7 @@ module.exports = [
     configCategories: [
       App.ServiceConfigCategory.create({ name: 'WebHCat', displayName: 'WebHCat'})
     ],
+    sites: ['webhcat-site'],
     configs: configProperties.filterProperty('serviceName', 'WEBHCAT')
   },
 
@@ -85,6 +89,8 @@ module.exports = [
       App.ServiceConfigCategory.create({ name: 'HBase Master', displayName: 'HBase Master'}),
       App.ServiceConfigCategory.create({ name: 'RegionServer', displayName: 'RegionServer'})
     ],
+    sites: ['hbase-site'],
+
     configs: configProperties.filterProperty('serviceName', 'HBASE')
   },
   /*
@@ -106,6 +112,7 @@ module.exports = [
     configCategories: [
       App.ServiceConfigCategory.create({ name: 'Oozie Server'})
     ],
+    sites: ['oozie-site'],
     configs: configProperties.filterProperty('serviceName', 'OOZIE')
   }
 

Modified: incubator/ambari/trunk/ambari-web/app/messages.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/messages.js?rev=1459397&r1=1459396&r2=1459397&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/messages.js (original)
+++ incubator/ambari/trunk/ambari-web/app/messages.js Thu Mar 21 16:53:46 2013
@@ -526,7 +526,7 @@ Em.I18n.translations = {
   'admin.addSecurity.apply.stage3': '2. Saving Configurations',
   'admin.addSecurity.apply.stage4': '3. Starting Services',
   'admin.addSecurity.apply.stage5': '5. Smoke Test',
-  'admin.security.status.error' : 'Error in retrieving cluster security status from server',
+  'admin.security.status.error' : 'Error in retrieving cluster security status from Ambari
server',
   'admin.users.ldapAuthentionUsed':'LDAP Authentication is being used to authenticate users',
   'admin.users.delete.yourself.message':'You can\'t delete yourself',
   'admin.users.delete.yourself.header':'Deleting warning',

Modified: incubator/ambari/trunk/ambari-web/app/routes/main.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/routes/main.js?rev=1459397&r1=1459396&r2=1459397&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/routes/main.js (original)
+++ incubator/ambari/trunk/ambari-web/app/routes/main.js Thu Mar 21 16:53:46 2013
@@ -311,7 +311,7 @@ module.exports = Em.Route.extend({
                 this.hide();
               },
               bodyClass: Ember.View.extend({
-                template: Ember.Handlebars.compile(['<p>{{t admin.security.status.error}}</p>'])
+                template: Ember.Handlebars.compile('<p>{{t admin.security.status.error}}</p>')
               })
             });
           });



Mime
View raw message