Преглед изворни кода

AMBARI-9680 Modify flow for checking and authenticating admin principal to make it more robust (Move Master, HA Wizard, and Add Component.). (ababiichuk)

aBabiichuk пре 10 година
родитељ
комит
e154a14269

+ 3 - 1
ambari-web/app/controllers/main/admin/highAvailability/nameNode/step4_controller.js

@@ -61,7 +61,9 @@ App.HighAvailabilityWizardStep4Controller = Em.Controller.extend({
 
 
   done: function () {
   done: function () {
     if (this.get('isNextEnabled')) {
     if (this.get('isNextEnabled')) {
-      App.router.send('next');
+      App.get('router.mainAdminKerberosController').getKDCSessionState(function() {
+        App.router.send("next");
+      });
     }
     }
   }
   }
 
 

+ 7 - 1
ambari-web/app/controllers/main/admin/highAvailability/nameNode/step8_controller.js

@@ -20,7 +20,13 @@ var App = require('app');
 
 
 App.HighAvailabilityWizardStep8Controller = Em.Controller.extend({
 App.HighAvailabilityWizardStep8Controller = Em.Controller.extend({
 
 
-  name:"highAvailabilityWizardStep8Controller"
+  name:"highAvailabilityWizardStep8Controller",
+
+  done: function () {
+    App.get('router.mainAdminKerberosController').getKDCSessionState(function() {
+      App.router.send("next");
+    });
+  }
 
 
 });
 });
 
 

+ 8 - 0
ambari-web/app/controllers/main/admin/highAvailability/resourceManager/step3_controller.js

@@ -131,6 +131,14 @@ App.RMHighAvailabilityWizardStep3Controller = Em.Controller.extend({
       serviceConfigProperty.set('isEditable', serviceConfigProperty.get('isReconfigurable'));
       serviceConfigProperty.set('isEditable', serviceConfigProperty.get('isReconfigurable'));
       serviceConfigProperty.validate();
       serviceConfigProperty.validate();
     }, this);
     }, this);
+  },
+
+  submit: function () {
+    if (!this.get('isSubmitDisabled')) {
+      App.get('router.mainAdminKerberosController').getKDCSessionState(function() {
+        App.router.send("next");
+      });
+    }
   }
   }
 });
 });
 
 

+ 12 - 8
ambari-web/app/controllers/main/admin/kerberos.js

@@ -277,14 +277,18 @@ App.MainAdminKerberosController = App.KerberosWizardStep4Controller.extend({
   },
   },
 
 
   getKDCSessionState: function(callback) {
   getKDCSessionState: function(callback) {
-    App.ajax.send({
-      name: 'kerberos.session.state',
-      sender: this,
-      data: {
-        callback: callback
-      },
-      success: 'checkState'
-    })
+    if (this.get('securityEnabled')) {
+      App.ajax.send({
+        name: 'kerberos.session.state',
+        sender: this,
+        data: {
+          callback: callback
+        },
+        success: 'checkState'
+      })
+    } else {
+      callback();
+    }
   },
   },
 
 
   checkState: function(data, opt, params) {
   checkState: function(data, opt, params) {

+ 11 - 24
ambari-web/app/controllers/main/host/details.js

@@ -427,6 +427,14 @@ App.MainHostDetailsController = Em.Controller.extend({
   }.property('App.router.mainAdminSecurityController.securityEnabled'),
   }.property('App.router.mainAdminSecurityController.securityEnabled'),
 
 
 
 
+  /**
+   * add component as <code>addComponent<code> method but perform
+   * kdc sessionstate if cluster is secure;
+   * @param event
+   */
+  addComponentWithCheck: function(event) {
+    App.get('router.mainAdminKerberosController').getKDCSessionState(this.addComponent.bind(this, event));
+  },
   /**
   /**
    * Send command to server to install selected host component
    * Send command to server to install selected host component
    * @param {object} event
    * @param {object} event
@@ -462,15 +470,8 @@ App.MainHostDetailsController = Em.Controller.extend({
         this.loadConfigs("loadHiveConfigs");
         this.loadConfigs("loadHiveConfigs");
         break;
         break;
       default:
       default:
-        if (this.get('securityEnabled') && componentName !== 'CLIENTS') {
-          returnFunc = App.showConfirmationPopup(function () {
-            self.primary(component);
-          }, Em.I18n.t('hosts.host.addComponent.securityNote').format(componentName, self.get('content.hostName')));
-        }
-        else {
-          returnFunc = this.addClientComponent(component);
-        }
-    }
+        returnFunc = this.addClientComponent(component);
+      }
     return returnFunc;
     return returnFunc;
   },
   },
   /**
   /**
@@ -494,21 +495,7 @@ App.MainHostDetailsController = Em.Controller.extend({
 
 
       onPrimary: function () {
       onPrimary: function () {
         this.hide();
         this.hide();
-        if (component.get('componentName') === 'CLIENTS') {
-          // Clients component has many sub-components which
-          // need to be installed.
-          var scs = component.get('subComponentNames');
-          scs.forEach(function (sc) {
-            var c = Em.Object.create({
-              displayName: App.format.role(sc),
-              componentName: sc,
-              serviceName: sc.replace("_CLIENT", "")
-            });
-            self.primary(c);
-          });
-        } else {
-          self.primary(component);
-        }
+        self.primary(component);
       }
       }
     });
     });
   },
   },

+ 3 - 1
ambari-web/app/controllers/main/service/item.js

@@ -67,7 +67,9 @@ App.MainServiceItemController = Em.Controller.extend({
     });
     });
 
 
     self.set('add' + componentName, function() {
     self.set('add' + componentName, function() {
-      self.addComponent(componentName);
+      App.get('router.mainAdminKerberosController').getKDCSessionState(function() {
+        self.addComponent(componentName);
+      });
     });
     });
 
 
     Em.defineProperty(self, 'addDisabledTooltip-' + componentName, Em.computed('isAddDisabled-' + componentName, 'addDisabledMsg-' + componentName, function() {
     Em.defineProperty(self, 'addDisabledTooltip-' + componentName, Em.computed('isAddDisabled-' + componentName, 'addDisabledMsg-' + componentName, function() {

+ 9 - 1
ambari-web/app/controllers/main/service/reassign/step3_controller.js

@@ -18,4 +18,12 @@
 
 
 var App = require('app');
 var App = require('app');
 
 
-App.ReassignMasterWizardStep3Controller = Em.Controller.extend();
+App.ReassignMasterWizardStep3Controller = Em.Controller.extend({
+  name: 'reassignMasterWizardStep3Controller',
+
+  submit: function() {
+    App.get('router.mainAdminKerberosController').getKDCSessionState(function() {
+      App.router.send("next");
+    });
+  }
+});

+ 1 - 1
ambari-web/app/templates/main/admin/highAvailability/nameNode/step8.hbs

@@ -19,7 +19,7 @@
   <h2>{{t admin.highAvailability.wizard.step8.bodyHeader}}</h2>
   <h2>{{t admin.highAvailability.wizard.step8.bodyHeader}}</h2>
   {{{view.step8BodyText}}}
   {{{view.step8BodyText}}}
   <div class="btn-area">
   <div class="btn-area">
-    <a class="btn btn-success pull-right" {{action next}}>{{t common.next}} &rarr;</a>
+    <a class="btn btn-success pull-right" {{action done target="controller"}}>{{t common.next}} &rarr;</a>
     <span class="pull-right btn-extra-info">{{!t admin.highAvailability.wizard.step8.metaNoInit}}</span>
     <span class="pull-right btn-extra-info">{{!t admin.highAvailability.wizard.step8.metaNoInit}}</span>
   </div>
   </div>
 </div>
 </div>

+ 1 - 1
ambari-web/app/templates/main/admin/highAvailability/resourceManager/step3.hbs

@@ -55,5 +55,5 @@
 
 
 <div class="btn-area">
 <div class="btn-area">
     <a class="btn" {{action back}}>&larr; {{t common.back}}</a>
     <a class="btn" {{action back}}>&larr; {{t common.back}}</a>
-    <a class="btn btn-success pull-right" {{action next}} {{bindAttr disabled="controller.isSubmitDisabled"}}>{{t common.next}} &rarr;</a>
+    <a class="btn btn-success pull-right" {{action submit target="controller"}} {{bindAttr disabled="controller.isSubmitDisabled"}}>{{t common.next}} &rarr;</a>
 </div>
 </div>

+ 1 - 1
ambari-web/app/templates/main/host/summary.hbs

@@ -34,7 +34,7 @@
                 <ul class="dropdown-menu">
                 <ul class="dropdown-menu">
                   {{#each component in view.addableComponents}}
                   {{#each component in view.addableComponents}}
                     <li>
                     <li>
-                      <a href="javascript:void(null)" data-toggle="modal" {{action addComponent component target="controller"}}>
+                      <a href="javascript:void(null)" data-toggle="modal" {{action addComponentWithCheck component target="controller"}}>
                         {{component.displayName}}
                         {{component.displayName}}
                       </a>
                       </a>
                     </li>
                     </li>

+ 1 - 1
ambari-web/app/templates/main/service/reassign/step3.hbs

@@ -41,5 +41,5 @@
 <div class="btn-area">
 <div class="btn-area">
   <a class="btn pull-left" {{action back href="true"}}>&larr; {{t common.back}}</a>
   <a class="btn pull-left" {{action back href="true"}}>&larr; {{t common.back}}</a>
   <a class="btn btn-success pull-right"
   <a class="btn btn-success pull-right"
-     id="spinner" {{bindAttr disabled="controller.isSubmitDisabled"}} {{action next}}>{{t common.deploy}} &rarr;</a>
+     id="spinner" {{bindAttr disabled="controller.isSubmitDisabled"}} {{action submit target="controller"}}>{{t common.deploy}} &rarr;</a>
 </div>
 </div>

+ 2 - 34
ambari-web/test/controllers/main/host/details_test.js

@@ -437,19 +437,7 @@ describe('App.MainHostDetailsController', function () {
         componentName: 'ZOOKEEPER_SERVER'
         componentName: 'ZOOKEEPER_SERVER'
       }))).to.be.true;
       }))).to.be.true;
     });
     });
-    it('add slave component, securityEnabled = true', function () {
-      var event = {context: Em.Object.create({
-        componentName: 'HIVE_CLIENT'
-      })};
-      controller.set('securityEnabled', true);
-      var popup = controller.addComponent(event);
-      expect(App.showConfirmationPopup.calledOnce).to.be.true;
-      popup.onPrimary();
-      expect(controller.primary.calledWith(Em.Object.create({
-        componentName: 'HIVE_CLIENT'
-      }))).to.be.true;
-    });
-    it('add slave component, securityEnabled = false', function () {
+    it('add slave component', function () {
       var event = {context: Em.Object.create({
       var event = {context: Em.Object.create({
         componentName: 'HIVE_CLIENT'
         componentName: 'HIVE_CLIENT'
       })};
       })};
@@ -515,33 +503,13 @@ describe('App.MainHostDetailsController', function () {
       controller.primary.restore();
       controller.primary.restore();
     });
     });
 
 
-    it('not CLIENT component', function () {
+    it('any CLIENT component', function () {
       var component = Em.Object.create({'componentName': 'Comp1'});
       var component = Em.Object.create({'componentName': 'Comp1'});
       var popup = controller.addClientComponent(component);
       var popup = controller.addClientComponent(component);
       expect(App.ModalPopup.show.calledOnce).to.be.true;
       expect(App.ModalPopup.show.calledOnce).to.be.true;
       popup.onPrimary();
       popup.onPrimary();
       expect(controller.primary.calledWith(Em.Object.create({'componentName': 'Comp1'}))).to.be.true;
       expect(controller.primary.calledWith(Em.Object.create({'componentName': 'Comp1'}))).to.be.true;
     });
     });
-    it('CLIENT components, with empty subComponentNames', function () {
-      var component = Em.Object.create({
-        componentName: 'CLIENTS',
-        subComponentNames: []
-      });
-      var popup = controller.addClientComponent(component);
-      expect(App.ModalPopup.show.calledOnce).to.be.true;
-      popup.onPrimary();
-      expect(controller.primary.calledOnce).to.be.false;
-    });
-    it('CLIENT components, with two sub-component', function () {
-      var component = Em.Object.create({
-        componentName: 'CLIENTS',
-        subComponentNames: ['DATANODE', 'TASKTRACKER']
-      });
-      var popup = controller.addClientComponent(component);
-      expect(App.ModalPopup.show.calledOnce).to.be.true;
-      popup.onPrimary();
-      expect(controller.primary.calledTwice).to.be.true;
-    });
   });
   });
 
 
   describe('#primary()', function () {
   describe('#primary()', function () {