Browse Source

AMBARI-2337. Security Wizard: navigation not locked down, causes artifacts, and other unwanted side effects. (jaimin via yusaku)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/trunk@1491327 13f79535-47bb-0310-9956-ffa450edef68
Yusaku Sako 12 năm trước cách đây
mục cha
commit
aa9a84806c

+ 1 - 1
ambari-web/app/controllers/main/admin/security.js

@@ -111,7 +111,7 @@ App.MainAdminSecurityController = Em.Controller.extend({
   getServiceConfigsFromServerSuccessCallback: function (data) {
     console.log("TRACE: In success function for the GET getServiceConfigsFromServer call");
     var configs = data.items.findProperty('tag', this.get('tag')).properties;
-    if (configs && configs['security_enabled'] === 'true') {
+    if (configs && (configs['security_enabled'] === 'true'  ||configs['security_enabled'] === true)) {
       this.set('securityEnabled', true);
     }
     else {

+ 1 - 18
ambari-web/app/controllers/main/admin/security/add/addSecurity_controller.js

@@ -27,15 +27,7 @@ App.AddSecurityController = App.WizardController.extend({
   content: Em.Object.create({
     services: [],
     serviceConfigProperties: null,
-    controllerName: 'addSecurityController',
-
-    saveCurrentStage: function (stage) {
-      App.db.setSecurityStage(stage);
-    },
-
-    loadCurrentStage: function () {
-      return App.db.getSecurityStage();
-    }
+    controllerName: 'addSecurityController'
   }),
 
   /**
@@ -45,7 +37,6 @@ App.AddSecurityController = App.WizardController.extend({
     var step = this.get('currentStep');
     switch (step) {
       case '3':
-        this.loadStages();
       case '2':
         this.loadServiceConfigs();
       case '1':
@@ -59,14 +50,6 @@ App.AddSecurityController = App.WizardController.extend({
     }
   },
 
-  /**
-   * loads the status of stages of step3 from localDb
-   */
-
-  loadStages: function () {
-
-  },
-
   /**
    * Loads all installed services
    */

+ 12 - 13
ambari-web/app/controllers/main/admin/security/add/step3.js

@@ -20,7 +20,7 @@ var App = require('app');
 App.MainAdminSecurityAddStep3Controller = Em.Controller.extend({
 
   name: 'mainAdminSecurityAddStep3Controller',
-  configMapping: require('data/secure_mapping'),
+  secureMapping: require('data/secure_mapping'),
   stages: [],
   configs: [],
   noOfWaitingAjaxCalls: 0,
@@ -63,10 +63,11 @@ App.MainAdminSecurityAddStep3Controller = Em.Controller.extend({
   },
 
   loadStep: function () {
+    this.set('secureMapping',require('data/secure_mapping').slice(0));
     var stages = App.db.getSecurityDeployStages();
     this.prepareSecureConfigs();
+    this.clearStep();
     if (stages === undefined) {
-      this.clearStep();
       this.loadStages();
       this.addInfoToStages();
     } else {
@@ -91,32 +92,31 @@ App.MainAdminSecurityAddStep3Controller = Em.Controller.extend({
   enableSubmit: function () {
     if (this.get('stages').someProperty('isError', true) || this.get('stages').everyProperty('isSuccess', true)) {
       this.set('isSubmitDisabled', false);
-      App.router.get('addSecurityController').setStepsEnable();
     }
   }.observes('stages.@each.isCompleted'),
 
   updateServices: function () {
     this.services.clear();
     var services = this.get("services");
-    this.get("stages").forEach(function (stages) {
+    this.get("stages").forEach(function (stage) {
       var newService = Ember.Object.create({
-        name: stages.label,
+        name: stage.label,
         hosts: []
       });
-      if (stages && stages.get("polledData")) {
-        var hostNames = stages.get("polledData").mapProperty('Tasks.host_name').uniq();
+      if (stage && stage.get("polledData")) {
+        var hostNames = stage.get("polledData").mapProperty('Tasks.host_name').uniq();
         hostNames.forEach(function (name) {
           newService.hosts.push({
             name: name,
             publicName: name,
-            logTasks: stages.polledData.filterProperty("Tasks.host_name", name)
+            logTasks: stage.polledData.filterProperty("Tasks.host_name", name)
           });
         });
         services.push(newService);
       }
     });
     this.set('serviceTimestamp', new Date().getTime());
-  }.observes("stages.@each.polledData"),
+  }.observes('stages.@each.polledData'),
 
   loadStages: function () {
     this.get('stages').pushObjects([
@@ -193,7 +193,7 @@ App.MainAdminSecurityAddStep3Controller = Em.Controller.extend({
 
   loadUiSideConfigs: function () {
     var uiConfig = [];
-    var configs = this.get('configMapping').filterProperty('foreignKey', null);
+    var configs = this.get('secureMapping').filterProperty('foreignKey', null);
     configs.forEach(function (_config) {
       var value = this.getGlobConfigValue(_config.templateName, _config.value, _config.name);
       uiConfig.pushObject({
@@ -212,7 +212,7 @@ App.MainAdminSecurityAddStep3Controller = Em.Controller.extend({
       var globalProperty = this.get('globalProperties').findProperty('name', name);
       newValue = globalProperty.value;
       var isInstanceName = this.get('globalProperties').findProperty('name', 'instance_name');
-      if (isInstanceName) {
+      if (isInstanceName === true || isInstanceName === 'true') {
         if (/primary_name?$/.test(globalProperty.name) && property !== 'hadoop.security.auth_to_local' && property !== 'oozie.authentication.kerberos.name.rules') {
           if (this.get('isOozieSelected') && (property === 'oozie.service.HadoopAccessorService.kerberos.principal' || property === 'oozie.authentication.kerberos.principal')) {
             var oozieServerName = App.Service.find('OOZIE').get('hostComponents').findProperty('componentName', 'OOZIE_SERVER').get('host.hostName');
@@ -257,7 +257,7 @@ App.MainAdminSecurityAddStep3Controller = Em.Controller.extend({
       } else {
         /*
          console.log("ERROR: The variable name is: " + templateName[index]);
-         console.log("ERROR: mapped config from configMapping file has no corresponding variable in " +
+         console.log("ERROR: mapped config from secureMapping file has no corresponding variable in " +
          "content.serviceConfigProperties. Two possible reasons for the error could be: 1) The service is not selected. " +
          "and/OR 2) The service_config metadata file has no corresponding global var for the site property variable");
          */
@@ -378,7 +378,6 @@ App.MainAdminSecurityAddStep3Controller = Em.Controller.extend({
     this.set('noOfWaitingAjaxCalls', this.get('noOfWaitingAjaxCalls') - 1);
     if (this.get('noOfWaitingAjaxCalls') == 0) {
       App.router.get('mainAdminSecurityController').setAddSecurityWizardStatus(null);
-      App.router.get('addSecurityController').setCurrentStep(1);
       var currentStage = this.get('stages').findProperty('stage', 'stage3');
       currentStage.set('isSuccess', true);
     }

+ 23 - 22
ambari-web/app/controllers/main/admin/security/disable.js

@@ -42,14 +42,14 @@ App.MainAdminSecurityDisableController = Em.Controller.extend({
 
   loadStep: function () {
     var stages = App.db.getSecurityDeployStages();
+    this.clearStep();
     if (stages === undefined) {
-      this.clearStep();
       this.loadStages();
       this.addInfoToStages();
     } else {
-      stages.forEach(function(_stage,index){
+      stages.forEach(function (_stage, index) {
         stages[index] = App.Poll.create(_stage);
-      },this);
+      }, this);
       if (stages.someProperty('isError', true)) {
         var failedStages = stages.filterProperty('isError', true);
         failedStages.setEach('isError', false);
@@ -61,8 +61,8 @@ App.MainAdminSecurityDisableController = Em.Controller.extend({
       }
       this.get('stages').pushObjects(stages);
     }
-   this.loadSecureServices();
-   this.moveToNextStage();
+    this.loadSecureServices();
+    this.moveToNextStage();
   },
 
 
@@ -85,7 +85,6 @@ App.MainAdminSecurityDisableController = Em.Controller.extend({
   enableSubmit: function () {
     if (this.get('stages').someProperty('isError', true) || this.get('stages').everyProperty('isSuccess', true)) {
       this.set('isSubmitDisabled', false);
-      App.router.get('addSecurityController').setStepsEnable();
     }
   }.observes('stages.@each.isCompleted'),
 
@@ -120,23 +119,25 @@ App.MainAdminSecurityDisableController = Em.Controller.extend({
   updateServices: function () {
     this.services.clear();
     var services = this.get("services");
-    this.get("stages").forEach(function (stages) {
+    this.get("stages").forEach(function (stage) {
       var newService = Ember.Object.create({
-        name: stages.label,
+        name: stage.label,
         hosts: []
       });
-      var hostNames = stages.get("polledData").mapProperty('Tasks.host_name').uniq();
-      hostNames.forEach(function (name) {
-        newService.hosts.push({
-          name: name,
-          publicName: name,
-          logTasks: stages.polledData.filterProperty("Tasks.host_name", name)
+      if (stage && stage.get("polledData")) {
+        var hostNames = stage.get("polledData").mapProperty('Tasks.host_name').uniq();
+        hostNames.forEach(function (name) {
+          newService.hosts.push({
+            name: name,
+            publicName: name,
+            logTasks: stage.polledData.filterProperty("Tasks.host_name", name)
+          });
         });
-      });
-      services.push(newService);
+        services.push(newService);
+      }
     });
     this.set('serviceTimestamp', new Date().getTime());
-  }.observes("stages.@each.polledData"),
+  }.observes('stages.@each.polledData'),
 
   addInfoToStages: function () {
     this.addInfoToStage2();
@@ -303,7 +304,7 @@ App.MainAdminSecurityDisableController = Em.Controller.extend({
             delete _serviceConfigTags.configs[_config.name];
           }
         }, this);
-        _serviceConfigTags.configs.security_enabled = false;
+        _serviceConfigTags.configs.security_enabled = 'false';
       } else {
         this.get('secureMapping').filterProperty('filename', _serviceConfigTags.siteName + '.xml').forEach(function (_config) {
           var configName = _config.name;
@@ -340,9 +341,9 @@ App.MainAdminSecurityDisableController = Em.Controller.extend({
     }, this);
   },
 
-  saveStages: function() {
+  saveStages: function () {
     var stages = [];
-    this.get('stages').forEach(function(_stage){
+    this.get('stages').forEach(function (_stage) {
       var stage = {
         stage: _stage.get('stage'),
         label: _stage.get('label'),
@@ -355,8 +356,8 @@ App.MainAdminSecurityDisableController = Em.Controller.extend({
         data: _stage.get('data')
       };
       stages.pushObject(stage);
-    },this);
+    }, this);
     App.db.setSecurityDeployStages(stages);
-  }.observes('stages.@each.requestId','stages.@each.isStarted','stages.@each.isCompleted')
+  }.observes('stages.@each.requestId', 'stages.@each.isStarted', 'stages.@each.isCompleted')
 
 });

+ 1 - 1
ambari-web/app/data/HDP2/config_properties.js

@@ -403,7 +403,7 @@ module.exports =
       "name": "security_enabled",
       "displayName": "Hadoop Security",
       "description": "Enable hadoop security",
-      "defaultValue": false,
+      "defaultValue": 'false',
       "isRequired": false,
       "displayType": "checkbox",
       "isOverridable": false,

+ 1 - 1
ambari-web/app/data/config_properties.js

@@ -416,7 +416,7 @@ module.exports =
       "name": "security_enabled",
       "displayName": "Hadoop Security",
       "description": "Enable hadoop security",
-      "defaultValue": false,
+      "defaultValue": 'false',
       "isRequired": false,
       "displayType": "checkbox",
       "isOverridable": false,

+ 0 - 1
ambari-web/app/data/secure_configs.js

@@ -30,7 +30,6 @@ module.exports = [
     configCategories: [
       App.ServiceConfigCategory.create({ name: 'KERBEROS', displayName: 'General'})
     ],
-    sites: ['global'],
     configs: configProperties.filterProperty('serviceName', 'GENERAL')
   },
   {

+ 1 - 3
ambari-web/app/routes/add_security.js

@@ -50,7 +50,6 @@ module.exports = Em.Route.extend({
               mainAdminSecurityController.setAddSecurityWizardStatus(null);
               App.db.setSecurityDeployStages(undefined);
               router.get('addSecurityController').setCurrentStep(1);
-              router.get('addSecurityController.content').saveCurrentStage(2);
               router.transitionTo('adminSecurity.index');
             }
           },
@@ -100,7 +99,6 @@ module.exports = Em.Route.extend({
       var addSecurityController = router.get('addSecurityController');
       var addSecurityStep2Controller = router.get('mainAdminSecurityAddStep2Controller');
       addSecurityController.saveServiceConfigProperties(addSecurityStep2Controller);
-      addSecurityController.get('content').saveCurrentStage('2');
       App.db.setSecurityDeployStages(undefined);
       router.transitionTo('step3');
     }
@@ -113,8 +111,8 @@ module.exports = Em.Route.extend({
       var controller = router.get('addSecurityController');
       controller.dataLoading().done(function () {
         controller.setCurrentStep('3');
-        controller.setLowerStepsDisable(3);
         controller.loadAllPriorSteps();
+        controller.setLowerStepsDisable(3);
         controller.connectOutlet('mainAdminSecurityAddStep3', controller.get('content'));
       })
     },

+ 3 - 3
ambari-web/app/templates/main/admin/security/add/menu.hbs

@@ -26,9 +26,9 @@
                     <div class="well">
                         <ul class="nav nav-pills nav-stacked">
                             <li class="nav-header">{{t admin.addSecurity.header}}</li>
-                            <li {{bindAttr class="isStep1:active view.isStep1Disabled:disabled"}}><a href="javascript:void(null);"  {{action gotoStep1}}>{{t admin.security.step1.header}}</a></li>
-                            <li {{bindAttr class="isStep2:active view.isStep2Disabled:disabled"}}><a href="javascript:void(null);"  {{action gotoStep2}}>{{t admin.security.step2.header}}</a></li>
-                            <li {{bindAttr class="isStep3:active view.isStep3Disabled:disabled"}}><a href="javascript:void(null);"  {{action gotoStep3}}>{{t admin.security.step3.header}}</a></li>
+                            <li {{bindAttr class="isStep1:active view.isStep1Disabled:disabled"}}><a href="javascript:void(null);"  {{action gotoStep1 target="controller"}}>{{t admin.security.step1.header}}</a></li>
+                            <li {{bindAttr class="isStep2:active view.isStep2Disabled:disabled"}}><a href="javascript:void(null);"  {{action gotoStep2 target="controller"}}>{{t admin.security.step2.header}}</a></li>
+                            <li {{bindAttr class="isStep3:active view.isStep3Disabled:disabled"}}><a href="javascript:void(null);"  {{action gotoStep3 target="controller"}}>{{t admin.security.step3.header}}</a></li>
                         </ul>
                     </div>
                 </div>

+ 5 - 3
ambari-web/app/templates/main/service/reconfigure.hbs

@@ -22,7 +22,7 @@
       {{#view App.StageStatusView}}
       <td>
         {{#if stage.isPolling}}
-          <a  href="javascript:void(0)" {{action "showHostPopup" stage.label target="view"}}>
+          <a href="javascript:void(0)" {{action "showHostPopup" stage.label target="view"}}>
         {{/if}}
         <p {{bindAttr class="stage.hasStarted::faintText"}}>{{stage.label}}</p>
         {{#if stage.isPolling}}
@@ -34,7 +34,9 @@
           {{#if stage.isSuccess}}
             {{view App.StageSuccessView}}
           {{else}}
-            {{view App.StageFailureView}}
+            {{#if stage.isError}}
+              {{view App.StageFailureView}}
+            {{/if}}
           {{/if}}
         {{else}}
           {{#if stage.isStarted}}
@@ -50,4 +52,4 @@
       {{/view}}
     {{/each}}
   </tbody>
-</table>
+</table>