You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by on...@apache.org on 2015/02/15 12:53:25 UTC

ambari git commit: AMBARI-9646. Kerberos: Regen confirmation dialog with "missing" option. (onechiporenko)

Repository: ambari
Updated Branches:
  refs/heads/trunk a2b3b4c52 -> 7d002b155


AMBARI-9646. Kerberos: Regen confirmation dialog with "missing" option. (onechiporenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/7d002b15
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7d002b15
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7d002b15

Branch: refs/heads/trunk
Commit: 7d002b1550db508f4e6561522e0f176491732500
Parents: a2b3b4c
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Sun Feb 15 13:47:46 2015 +0200
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Sun Feb 15 13:47:46 2015 +0200

----------------------------------------------------------------------
 .../app/controllers/main/admin/kerberos.js      | 43 +++++++++++++++++---
 ambari-web/app/messages.js                      |  3 ++
 .../kerberos/regenerate_keytabs_popup_body.hbs  | 22 ++++++++++
 ambari-web/app/utils/ajax/ajax.js               |  2 +-
 .../controllers/main/admin/kerberos_test.js     | 20 +++++++--
 5 files changed, 80 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/7d002b15/ambari-web/app/controllers/main/admin/kerberos.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/kerberos.js b/ambari-web/app/controllers/main/admin/kerberos.js
index d8bee3d..e283df3 100644
--- a/ambari-web/app/controllers/main/admin/kerberos.js
+++ b/ambari-web/app/controllers/main/admin/kerberos.js
@@ -61,15 +61,46 @@ App.MainAdminKerberosController = App.KerberosWizardStep4Controller.extend({
 
   /**
    * Show confirmation popup and after confirmation send request to regenerate keytabs
+   * @method regenerateKeytabs
+   * @return {App.ModalPopup}
    */
   regenerateKeytabs: function () {
     var self = this;
-    return App.showConfirmationPopup(function(){
-      App.ajax.send({
-        name: "admin.kerberos_security.regenerate_keytabs",
-        sender: self,
-        success: "regenerateKeytabsSuccess"
-      });
+
+    return App.ModalPopup.show({
+
+      /**
+       * True - regenerate keytabs only for missing hosts and components, false - regenerate for all hosts and components
+       * @type {boolean}
+       */
+      regenerateKeytabsOnlyForMissing: false,
+
+      header: Em.I18n.t('admin.kerberos.button.regenerateKeytabs'),
+
+      bodyClass: Em.View.extend({
+        templateName: require('templates/main/admin/kerberos/regenerate_keytabs_popup_body')
+      }),
+
+      onPrimary: function () {
+        this._super();
+        self.regenerateKeytabsRequest(this.get('regenerateKeytabsOnlyForMissing'));
+      }
+    });
+  },
+
+  /**
+   * Send request to regenerate keytabs
+   * @param {boolean} missingOnly determines type of regeneration - missing|all
+   * @returns {$.ajax}
+   */
+  regenerateKeytabsRequest: function (missingOnly) {
+    return App.ajax.send({
+      name: "admin.kerberos_security.regenerate_keytabs",
+      sender: this,
+      data: {
+        type: missingOnly ? 'missing' : 'all'
+      },
+      success: "regenerateKeytabsSuccess"
     });
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/7d002b15/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 74ab371..1ef0e55 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -982,6 +982,9 @@ Em.I18n.translations = {
   'admin.kerberos.wizard.step7.notice.failed': 'Some services failed to start and execute tests successfully. Click Retry to attempt again or click Complete to dismiss the wizard and fix manually.',
   'admin.kerberos.wizard.step7.task0.title' : 'Start and Test Services',
 
+  'admin.kerberos.regenerate_keytabs.popup.body': 'You are about to regenerate keytabs for the hosts in the cluster. This will stop all the services in your cluster and regenerate the Kerberos keytabs. <strong>Are you sure you wish to proceed with keytab regeneration?</strong>',
+  'admin.kerberos.regenerate_keytabs.checkbox.label': ' Only regenerate keytabs for missing hosts and components',
+
   'admin.kerberos.disable.step1.task0.title': 'Stop Services',
   'admin.kerberos.disable.step1.task1.title': 'Remove Kerberos',
   'admin.kerberos.disable.step1.task2.title': 'Start Services',

http://git-wip-us.apache.org/repos/asf/ambari/blob/7d002b15/ambari-web/app/templates/main/admin/kerberos/regenerate_keytabs_popup_body.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/admin/kerberos/regenerate_keytabs_popup_body.hbs b/ambari-web/app/templates/main/admin/kerberos/regenerate_keytabs_popup_body.hbs
new file mode 100644
index 0000000..3a0cedf
--- /dev/null
+++ b/ambari-web/app/templates/main/admin/kerberos/regenerate_keytabs_popup_body.hbs
@@ -0,0 +1,22 @@
+{{!
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+}}
+
+<p class="alert alert-warning">{{t admin.kerberos.regenerate_keytabs.popup.body}}</p>
+<p>
+  <label>{{view Em.Checkbox classNames="checkbox" checkedBinding="view.parentView.regenerateKeytabsOnlyForMissing"}} {{t admin.kerberos.regenerate_keytabs.checkbox.label}}</label>
+</p>

http://git-wip-us.apache.org/repos/asf/ambari/blob/7d002b15/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index bfbc2dd..5f70bd2 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -1488,7 +1488,7 @@ var urls = {
   },
 
   'admin.kerberos_security.regenerate_keytabs': {
-    'real': '/clusters/{clusterName}?regenerate_keytabs=true',
+    'real': '/clusters/{clusterName}?regenerate_keytabs={type}',
     'mock': '',
     'type': 'PUT',
     'format': function (data) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/7d002b15/ambari-web/test/controllers/main/admin/kerberos_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/kerberos_test.js b/ambari-web/test/controllers/main/admin/kerberos_test.js
index 6cbfe67..ec80ca2 100644
--- a/ambari-web/test/controllers/main/admin/kerberos_test.js
+++ b/ambari-web/test/controllers/main/admin/kerberos_test.js
@@ -98,19 +98,33 @@ describe('App.MainAdminKerberosController', function() {
   describe('#regenerateKeytabs()', function () {
 
     beforeEach(function () {
-      sinon.spy(App, "showConfirmationPopup");
+      sinon.spy(App.ModalPopup, "show");
       sinon.stub(App.ajax, 'send', Em.K);
     });
     afterEach(function () {
-      App.showConfirmationPopup.restore();
+      App.ModalPopup.show.restore();
       App.ajax.send.restore();
     });
 
     it('confirm popup should be displayed', function () {
       var popup = controller.regenerateKeytabs();
-      expect(App.showConfirmationPopup.calledOnce).to.be.true;
+      expect(App.ModalPopup.show.calledOnce).to.be.true;
       popup.onPrimary();
       expect(App.ajax.send.calledOnce).to.be.true;
     });
+
+    it('user checked regeneration only for missing host/components', function () {
+      var popup = controller.regenerateKeytabs();
+      popup.set('regenerateKeytabsOnlyForMissing', true);
+      popup.onPrimary();
+      expect(App.ajax.send.args[0][0].data.type).to.equal('missing');
+    });
+
+    it('user didn\'t check regeneration only for missing host/components', function () {
+      var popup = controller.regenerateKeytabs();
+      popup.onPrimary();
+      expect(App.ajax.send.args[0][0].data.type).to.equal('all');
+    });
+
   });
 });