Переглянути джерело

AMBARI-9606. Kerberos Wizard: Disable Kerberos button does not work. (onechiporenko)

Oleg Nechiporenko 10 роки тому
батько
коміт
54f5c0ab46

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

@@ -57,6 +57,7 @@ require('controllers/main/admin/advanced');
 require('utils/polling');
 require('controllers/main/admin/kerberos');
 require('controllers/main/admin/kerberos/wizard_controller');
+require('controllers/main/admin/kerberos/disable_controller');
 require('controllers/main/admin/kerberos/progress_controller');
 require('controllers/main/admin/kerberos/step1_controller');
 require('controllers/main/admin/kerberos/step2_controller');

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

@@ -0,0 +1,71 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+require('controllers/main/admin/kerberos/progress_controller');
+require('controllers/main/admin/security/security_progress_controller');
+
+App.KerberosDisableController = App.KerberosProgressPageController.extend({
+
+  name: 'kerberosDisableController',
+  clusterDeployState: 'DEFAULT',
+  commands: ['stopServices', 'unkerberize', 'startServices'],
+
+  tasksMessagesPrefix: 'admin.kerberos.disable.step',
+
+  stopServices: function () {
+    App.ajax.send({
+      name: 'common.services.update',
+      data: {
+        context: "Stop services",
+        "ServiceInfo": {
+          "state": "INSTALLED"
+        }
+      },
+      sender: this,
+      success: 'startPolling',
+      error: 'onTaskError'
+    });
+  },
+
+  unkerberize: function () {
+    return App.ajax.send({
+      name: 'admin.unkerberize.cluster',
+      sender: this,
+      success: 'startPolling',
+      error: 'onTaskError'
+    });
+  },
+
+  startServices: function () {
+    App.ajax.send({
+      name: 'common.services.update',
+      sender: this,
+      data: {
+        "context": "Start services",
+        "ServiceInfo": {
+          "state": "STARTED"
+        },
+        urlParams: "params/run_smoke_test=true"
+      },
+      success: 'startPolling',
+      error: 'onTaskError'
+    });
+  }
+
+});

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

@@ -979,6 +979,13 @@ 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.disable.step1.task0.title': 'Stop Services',
+  'admin.kerberos.disable.step1.task1.title': 'Remove Kerberos',
+  'admin.kerberos.disable.step1.task2.title': 'Start Services',
+  'admin.kerberos.disable.inProgress': 'Please wait while cluster is being unkerberized',
+  'admin.kerberos.disable.notice.completed': 'Services have been successfully tested without kerberos environment.',
+  'admin.kerberos.wizard.step1.notice.inProgress': 'Please wait while cluster is being unkerberized',
+
   'admin.highAvailability':' High Availability',
   'admin.highAvailability.button.enable':'Enable NameNode HA',
   'admin.highAvailability.button.disable':'Disable NameNode HA',
@@ -1170,7 +1177,7 @@ Em.I18n.translations = {
   'admin.security.enable.popup.body': 'We will walk you through add security wizard',
   'admin.security.enable.popup.header': 'Add security',
   'admin.security.disable.popup.header': 'Remove security',
-  'admin.security.disable.popup.body': 'Kerberos security will be disabled on the cluster',
+  'admin.security.disable.popup.body': 'You are about to disable Kerberos on the cluster. This will stop all the services in your cluster and remove the Kerberos configurations. <strong>Are you sure you wish to proceed with disabling Kerberos?</strong>',
   'admin.addSecurity.header': 'Enable Security Wizard',
   'admin.security.step1.header': 'Get Started',
   'admin.security.step2.header': 'Configure Services',

+ 64 - 71
ambari-web/app/routes/main.js

@@ -365,93 +365,86 @@ module.exports = Em.Route.extend({
         router.transitionTo('adminAddSecurity');
       },
 
+      adminAddSecurity: require('routes/add_security')
+    }),
+
+    adminKerberos: Em.Route.extend({
+      route: '/kerberos',
+      index: Em.Route.extend({
+        route: '/',
+        connectOutlets: function (router, context) {
+          router.set('mainAdminController.category', "kerberos");
+          router.get('mainAdminController').connectOutlet('mainAdminKerberos');
+        }
+      }),
+      adminAddKerberos: require('routes/add_kerberos_routes'),
+
       disableSecurity: Em.Route.extend({
         route: '/disableSecurity',
         enter: function (router) {
-          //after refresh check if the wizard is open then restore it
-          if (router.get('mainAdminSecurityController').getDisableSecurityStatus() === 'RUNNING') {
-            var controller = router.get('addSecurityController');
-            // App.MainAdminSecurityDisableController uses App.Service DS model whose data needs to be loaded first
-            controller.dataLoading().done(Em.run.next(function () {
-              App.router.get('updateController').set('isWorking', false);
-              App.ModalPopup.show({
-                classNames: ['full-width-modal'],
-                header: Em.I18n.t('admin.removeSecurity.header'),
-                bodyClass: App.MainAdminSecurityDisableView.extend({
-                  controllerBinding: 'App.router.mainAdminSecurityDisableController'
-                }),
-                primary: Em.I18n.t('form.cancel'),
-                secondary: null,
-                showFooter: false,
-
-                onClose: function () {
-                  var self = this;
-                  var controller = router.get('mainAdminSecurityDisableController');
-                  if (!controller.get('isSubmitDisabled')) {
-                    self.proceedOnClose();
-                    return;
-                  }
-                  var applyingConfigCommand = controller.get('commands').findProperty('name', 'APPLY_CONFIGURATIONS');
-                  if (applyingConfigCommand && !applyingConfigCommand.get('isCompleted')) {
-                    if (applyingConfigCommand.get('isStarted')) {
-                      App.showAlertPopup(Em.I18n.t('admin.security.applying.config.header'), Em.I18n.t('admin.security.applying.config.body'));
-                    } else {
-                      App.showConfirmationPopup(function () {
-                        self.proceedOnClose();
-                      }, Em.I18n.t('admin.addSecurity.disable.onClose'));
-                    }
-                  } else {
+          App.router.get('updateController').set('isWorking', false);
+          App.ModalPopup.show({
+            classNames: ['full-width-modal'],
+            header: Em.I18n.t('admin.removeSecurity.header'),
+            bodyClass: App.KerberosDisableView.extend({
+              controllerBinding: 'App.router.kerberosDisableController'
+            }),
+            primary: Em.I18n.t('form.cancel'),
+            secondary: null,
+            showFooter: false,
+
+            onClose: function () {
+              var self = this;
+              var controller = router.get('kerberosDisableController');
+              if (!controller.get('isSubmitDisabled')) {
+                self.proceedOnClose();
+                return;
+              }
+              var applyingConfigCommand = controller.get('commands').findProperty('name', 'APPLY_CONFIGURATIONS');
+              if (applyingConfigCommand && !applyingConfigCommand.get('isCompleted')) {
+                if (applyingConfigCommand.get('isStarted')) {
+                  App.showAlertPopup(Em.I18n.t('admin.security.applying.config.header'), Em.I18n.t('admin.security.applying.config.body'));
+                } else {
+                  App.showConfirmationPopup(function () {
                     self.proceedOnClose();
-                  }
-                },
-                proceedOnClose: function () {
-                  router.get('mainAdminSecurityDisableController').clearStep();
-                  App.db.setSecurityDeployCommands(undefined);
-                  App.router.get('updateController').set('isWorking', true);
-                  router.get('mainAdminSecurityController').setDisableSecurityStatus(undefined);
-                  router.get('addServiceController').finish();
-                  App.clusterStatus.setClusterStatus({
-                    clusterName: router.get('content.cluster.name'),
-                    clusterState: 'DEFAULT'
-                  });
-                  this.hide();
-                  router.transitionTo('adminSecurity.index');
-                },
-                didInsertElement: function () {
-                  this.fitHeight();
+                  }, Em.I18n.t('admin.addSecurity.disable.onClose'));
                 }
+              } else {
+                self.proceedOnClose();
+              }
+            },
+            proceedOnClose: function () {
+              router.get('kerberosDisableController').clearStep();
+              App.db.setSecurityDeployCommands(undefined);
+              App.router.get('updateController').set('isWorking', true);
+              router.get('mainAdminKerberosController').setDisableSecurityStatus(undefined);
+              router.get('addServiceController').finish();
+              App.clusterStatus.setClusterStatus({
+                clusterName: router.get('content.cluster.name'),
+                clusterState: 'DEFAULT'
               });
-            }));
-          } else {
-            router.transitionTo('adminSecurity.index');
-          }
+              this.hide();
+              router.transitionTo('adminKerberos.index');
+            },
+            didInsertElement: function () {
+              this.fitHeight();
+            }
+          });
         },
 
         unroutePath: function () {
           return false;
         },
-
+        next: function (router, context) {
+          $("#modal").find(".close").trigger('click');
+        },
         done: function (router, context) {
-          var controller = router.get('mainAdminSecurityDisableController');
+          var controller = router.get('kerberosDisableController');
           if (!controller.get('isSubmitDisabled')) {
             $(context.currentTarget).parents("#modal").find(".close").trigger('click');
           }
         }
-      }),
-
-      adminAddSecurity: require('routes/add_security')
-    }),
-
-    adminKerberos: Em.Route.extend({
-      route: '/kerberos',
-      index: Em.Route.extend({
-        route: '/',
-        connectOutlets: function (router, context) {
-          router.set('mainAdminController.category', "kerberos");
-          router.get('mainAdminController').connectOutlet('mainAdminKerberos');
-        }
-      }),
-      adminAddKerberos: require('routes/add_kerberos_routes')
+      })
     }),
 
     stackAndUpgrade: Em.Route.extend({

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

@@ -0,0 +1,23 @@
+{{!
+* 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.
+}}
+
+<div class="wizard">
+  <div class="row-fluid">
+    {{template "templates/common/progress"}}
+  </div>
+</div>

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

@@ -132,6 +132,7 @@ require('views/main/admin/audit');
 require('views/main/admin/authentication');
 
 require('views/main/admin/kerberos');
+require('views/main/admin/kerberos/disable_view');
 require('views/main/admin/kerberos/wizard_view');
 require('views/main/admin/kerberos/progress_view');
 require('views/main/admin/kerberos/step1_view');

+ 42 - 0
ambari-web/app/views/main/admin/kerberos/disable_view.js

@@ -0,0 +1,42 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+
+require('views/main/admin/kerberos/progress_view');
+
+App.KerberosDisableView = App.KerberosProgressPageView.extend({
+
+  didInsertElement: function () {
+    this._super();
+    this.get('controller').loadStep();
+  },
+
+  headerTitle: '',
+
+  noticeCompleted: Em.I18n.t('admin.kerberos.disable.notice.completed'),
+
+  notice: Em.I18n.t('admin.kerberos.disable.inProgress'),
+
+  templateName: require('templates/main/admin/kerberos/disable'),
+
+  msgColor: 'alert-info',
+
+  submitButtonText: Em.I18n.t('common.complete')
+
+});

+ 2 - 2
ambari-web/test/controllers/main/admin/kerberos/kerberos_wizard_controler_test.js

@@ -30,13 +30,13 @@ describe('App.KerberosWizardController', function() {
     });
     it('should open warning confirmation popup', function () {
       var f = Em.K;
-      var popup = controller.warnBeforeExitPopup(f, false);
+      controller.warnBeforeExitPopup(f, false);
       expect(App.showConfirmationPopup.calledWith(f, Em.I18n.t('admin.kerberos.wizard.exit.warning.msg'), null, null, Em.I18n.t('common.exitAnyway'), false)).to.be.true;
     });
 
     it('should open critical confirmation popup', function () {
       var f = Em.K;
-      var popup = controller.warnBeforeExitPopup(f, true);
+      controller.warnBeforeExitPopup(f, true);
       expect(App.showConfirmationPopup.calledWith(f, Em.I18n.t('admin.kerberos.wizard.exit.critical.msg'), null, null, Em.I18n.t('common.exitAnyway'), true)).to.be.true;
     });
   });