Sfoglia il codice sorgente

AMBARI-9532. Integrate keytab regeneration API. (akovalenko)

Aleksandr Kovalenko 10 anni fa
parent
commit
21a97cc731

+ 26 - 0
ambari-web/app/controllers/main/admin/kerberos.js

@@ -59,6 +59,32 @@ App.MainAdminKerberosController = App.KerberosWizardStep4Controller.extend({
     });
   },
 
+  /**
+   * Show confirmation popup and after confirmation send request to regenerate keytabs
+   */
+  regenerateKeytabs: function () {
+    var self = this;
+    return App.showConfirmationPopup(function(){
+      App.ajax.send({
+        name: "admin.kerberos_security.regenerate_keytabs",
+        sender: self,
+        success: "regenerateKeytabsSuccess"
+      });
+    });
+  },
+
+  /**
+   * Success callback of <code>regenerateKeytabs</code>
+   * show background operations popup if appropriate option is set
+   */
+  regenerateKeytabsSuccess: function () {
+    App.router.get('applicationController').dataLoading().done(function (initValue) {
+      if (initValue) {
+        App.router.get('backgroundOperationsController').showPopup();
+      }
+    });
+  },
+
   getUpdatedSecurityStatus: function () {
     this.getSecurityStatus();
     return this.get('securityEnabled');

+ 1 - 0
ambari-web/app/messages.js

@@ -937,6 +937,7 @@ Em.I18n.translations = {
   'admin.kerberos.wizard.header':'Enable Kerberos Wizard',
   'admin.kerberos.button.enable': 'Enable Kerberos',
   'admin.kerberos.button.disable': 'Disable Kerberos',
+  'admin.kerberos.button.regenerateKeytabs': 'Regenerate Keytabs',
   'admin.kerberos.wizard.exit.warning.msg': 'Configuring Kerberos is in progress. Do you really want to exit the Enable Kerberos Wizard?',
   'admin.kerberos.wizard.exit.critical.msg': 'Configuring Kerberos is in progress. <strong>Before dismissing, you should complete the wizard.</strong> Do you really want to exit the Enable Kerberos Wizard?',
   'admin.kerberos.wizard.step1.header': 'Get Started',

+ 1 - 0
ambari-web/app/templates/main/admin/kerberos.hbs

@@ -20,6 +20,7 @@
     <div>
       <p class="text-success">{{t admin.security.enabled}}
         <a class="btn btn-padding btn-warning admin-disable-security-btn" {{bindAttr disabled="isSubmitDisabled"}} {{action notifySecurityOffPopup target="controller"}}>{{t admin.kerberos.button.disable}} </a>
+        <button class="btn btn-success"{{action regenerateKeytabs target="controller"}}><i class="icon-repeat"></i> {{t admin.kerberos.button.regenerateKeytabs}}</button>
         <br/>
       </p>
     </div>

+ 15 - 0
ambari-web/app/utils/ajax/ajax.js

@@ -1487,6 +1487,21 @@ var urls = {
     }
   },
 
+  'admin.kerberos_security.regenerate_keytabs': {
+    'real': '/clusters/{clusterName}?regenerate_keytabs=true',
+    'mock': '',
+    'type': 'PUT',
+    'format': function (data) {
+      return {
+        data: JSON.stringify({
+          "Clusters" : {
+            "security_type" : "KERBEROS"
+          }
+        })
+      }
+    }
+  },
+
   'wizard.advanced_repositories.valid_url': {
     'real': '/stacks/{stackName}/versions/{stackVersion}/operating_systems/{osType}/repositories/{repoId}',
     'mock': '',

+ 19 - 0
ambari-web/test/controllers/main/admin/kerberos_test.js

@@ -94,4 +94,23 @@ describe('App.MainAdminKerberosController', function() {
       expect(App.showClusterCheckPopup.called).to.be.false;
     });
   });
+
+  describe('#regenerateKeytabs()', function () {
+
+    beforeEach(function () {
+      sinon.spy(App, "showConfirmationPopup");
+      sinon.stub(App.ajax, 'send', Em.K);
+    });
+    afterEach(function () {
+      App.showConfirmationPopup.restore();
+      App.ajax.send.restore();
+    });
+
+    it('confirm popup should be displayed', function () {
+      var popup = controller.regenerateKeytabs();
+      expect(App.showConfirmationPopup.calledOnce).to.be.true;
+      popup.onPrimary();
+      expect(App.ajax.send.calledOnce).to.be.true;
+    });
+  });
 });