You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by rz...@apache.org on 2015/06/29 23:22:09 UTC

ambari git commit: AMBARI-12141. Kerberos configs aren't restored when moving back from Review to the Configure Identities step (rzang)

Repository: ambari
Updated Branches:
  refs/heads/trunk 42dfdbbd0 -> 1dd3e8f2d


AMBARI-12141. Kerberos configs aren't restored when moving back from Review to the Configure Identities step (rzang)


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

Branch: refs/heads/trunk
Commit: 1dd3e8f2d7b881f9c33036ff13281199808ccf32
Parents: 42dfdbb
Author: Richard Zang <rz...@apache.org>
Authored: Mon Jun 29 14:17:46 2015 -0700
Committer: Richard Zang <rz...@apache.org>
Committed: Mon Jun 29 14:17:46 2015 -0700

----------------------------------------------------------------------
 .../main/admin/kerberos/step2_controller.js     |  2 +-
 .../main/admin/kerberos/step4_controller.js     | 14 ++++++++--
 ambari-web/app/controllers/wizard.js            | 29 ++++++++++++++++++++
 ambari-web/app/routes/add_kerberos_routes.js    |  2 ++
 ambari-web/app/routes/add_service_routes.js     |  2 ++
 ambari-web/app/utils/config.js                  | 17 ++++++++++++
 .../admin/kerberos/step4_controller_test.js     |  6 ++++
 7 files changed, 69 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1dd3e8f2/ambari-web/app/controllers/main/admin/kerberos/step2_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/kerberos/step2_controller.js b/ambari-web/app/controllers/main/admin/kerberos/step2_controller.js
index 77ab68f..0090ff9 100644
--- a/ambari-web/app/controllers/main/admin/kerberos/step2_controller.js
+++ b/ambari-web/app/controllers/main/admin/kerberos/step2_controller.js
@@ -78,7 +78,7 @@ App.KerberosWizardStep2Controller = App.WizardStep7Controller.extend({
    * @method loadStep
    */
   loadStep: function () {
-    console.log("TRACE: Loading step7: Configure Services");
+    console.log("TRACE: Loading step2: Configure Kerberos");
     if (!App.StackService.find().someProperty('serviceName', 'KERBEROS') || !this.get('isConfigsLoaded')) {
       return;
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/1dd3e8f2/ambari-web/app/controllers/main/admin/kerberos/step4_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/kerberos/step4_controller.js b/ambari-web/app/controllers/main/admin/kerberos/step4_controller.js
index 08f4e10..500f2c7 100644
--- a/ambari-web/app/controllers/main/admin/kerberos/step4_controller.js
+++ b/ambari-web/app/controllers/main/admin/kerberos/step4_controller.js
@@ -21,6 +21,9 @@ require('controllers/wizard/step7_controller');
 
 App.KerberosWizardStep4Controller = App.WizardStep7Controller.extend(App.AddSecurityConfigs, App.ToggleIsRequiredMixin, {
   name: 'kerberosWizardStep4Controller',
+  isWithinAddService: function () {
+    return this.get('wizardController.name') == 'addServiceController';
+  }.property('wizardController.name'),
 
   adminPropertyNames: [{name: 'admin_principal', displayName: 'Admin principal'}, {name: 'admin_password', displayName: 'Admin password'}],
   
@@ -166,13 +169,20 @@ App.KerberosWizardStep4Controller = App.WizardStep7Controller.extend(App.AddSecu
    * @returns {App.ServiceConfigProperty[]}
    */
   prepareConfigProperties: function(configs) {
+    console.log("call prepare");
     var self = this;
     var storedServiceConfigs = this.get('wizardController').getDBProperty('serviceConfigProperties');
     var installedServiceNames = ['Cluster'].concat(App.Service.find().mapProperty('serviceName'));
     var adminProps = [];
     var configProperties = configs.slice(0);
     var siteProperties = App.config.get('preDefinedSiteProperties');
-    if (this.get('wizardController.name') == 'addServiceController') {
+    // override stored values
+    App.config.mergeStoredValue(configProperties, storedServiceConfigs);
+    console.log(this.get('wizardController'));
+    App.config.mergeStoredValue(configProperties, this.get('wizardController').loadCachedStepConfigValues(this));
+
+    // show admin properties in add service wizard
+    if (this.get('isWithinAddService')) {
       installedServiceNames = installedServiceNames.concat(this.get('selectedServiceNames'));
       this.get('adminPropertyNames').forEach(function(item) {
         var property = storedServiceConfigs.filterProperty('filename', 'krb5-conf.xml').findProperty('name', item.name);
@@ -188,8 +198,8 @@ App.KerberosWizardStep4Controller = App.WizardStep7Controller.extend(App.AddSecu
           adminProps.push(_prop);
         }
       });
-      configProperties = adminProps.concat(configProperties);
     }
+    configProperties = adminProps.concat(configProperties);
     configProperties = configProperties.filter(function(item) {
       return installedServiceNames.contains(item.get('serviceName'));
     });

http://git-wip-us.apache.org/repos/asf/ambari/blob/1dd3e8f2/ambari-web/app/controllers/wizard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js
index 49b9700..fd2a588 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -1247,6 +1247,35 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
     return dfd.promise();
   },
 
+
+  /**
+   * Cache all step config to local storage in name value pairs
+   * @param stepController
+   */
+  cacheStepConfigValues: function(stepController) {
+    var stepConfigs = [];
+    stepController.get("stepConfigs").forEach(function (category) {
+      var configs = category.configs.map(function(config) {
+        return {
+          name: config.name,
+          value: config.value
+        };
+      });
+      stepConfigs = stepConfigs.concat(configs);
+    });
+    if (stepConfigs.length > 0 ) {
+      this.setDBProperty(stepController.name + "-sc", stepConfigs);
+    }
+  },
+
+  loadCachedStepConfigValues: function(stepController) {
+    return this.getDBProperty(stepController.name + "-sc");
+  },
+
+  clearCachedStepConfigValues: function(stepController) {
+    this.setDBProperty(stepController.name + "-sc", null);
+  },
+
   saveTasksStatuses: function (tasksStatuses) {
     this.set('content.tasksStatuses', tasksStatuses);
     this.setDBProperty('tasksStatuses', tasksStatuses);

http://git-wip-us.apache.org/repos/asf/ambari/blob/1dd3e8f2/ambari-web/app/routes/add_kerberos_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/add_kerberos_routes.js b/ambari-web/app/routes/add_kerberos_routes.js
index ef2d1e7..1cb6d83 100644
--- a/ambari-web/app/routes/add_kerberos_routes.js
+++ b/ambari-web/app/routes/add_kerberos_routes.js
@@ -211,6 +211,7 @@ module.exports = App.WizardRoute.extend({
     next: function (router) {
       var kerberosWizardController = router.get('kerberosWizardController');
       kerberosWizardController.setDBProperty('kerberosDescriptorConfigs', null);
+      kerberosWizardController.clearCachedStepConfigValues(router.get('kerberosWizardStep4Controller'));
       router.transitionTo('step4');
     }
   }),
@@ -245,6 +246,7 @@ module.exports = App.WizardRoute.extend({
       var kerberosWizardController = router.get('kerberosWizardController');
       var step5Controller = router.get('kerberosWizardStep5Controller');
       var kerberosDescriptor = kerberosWizardController.get('kerberosDescriptorConfigs');
+      kerberosWizardController.cacheStepConfigValues(router.get('kerberosWizardStep4Controller'));
       step5Controller.postKerberosDescriptor(kerberosDescriptor).always(function (data, result, request) {
         if (result === 'error' && data.status === 409) {
           step5Controller.putKerberosDescriptor(kerberosDescriptor);

http://git-wip-us.apache.org/repos/asf/ambari/blob/1dd3e8f2/ambari-web/app/routes/add_service_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/add_service_routes.js b/ambari-web/app/routes/add_service_routes.js
index 2df6c99..c646002 100644
--- a/ambari-web/app/routes/add_service_routes.js
+++ b/ambari-web/app/routes/add_service_routes.js
@@ -226,6 +226,7 @@ module.exports = App.WizardRoute.extend({
       addServiceController.saveServiceConfigProperties(wizardStep7Controller);
       addServiceController.saveServiceConfigGroups(wizardStep7Controller, true);
       if (router.get('mainAdminKerberosController.securityEnabled')) {
+        addServiceController.clearCachedStepConfigValues(router.get('kerberosWizardStep4Controller'));
         router.transitionTo('step5');
         return;
       }
@@ -272,6 +273,7 @@ module.exports = App.WizardRoute.extend({
         } else {
           router.get('kerberosWizardStep2Controller').createKerberosAdminSession(router.get('kerberosWizardStep4Controller.stepConfigs')[0].get('configs'));
         }
+        router.get('addServiceController').cacheStepConfigValues(router.get('kerberosWizardStep4Controller'));
       }
       router.transitionTo('step6');
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/1dd3e8f2/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index 6d78e0f..250b650 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -1800,5 +1800,22 @@ App.config = Em.Object.create({
 
     newOverride.validate();
     return newOverride;
+  },
+
+
+  /**
+   * Merge values in "stored" to "base" if name matches, it's a value only merge.
+   * @param base {Array} Em.Object
+   * @param stored {Array} Object
+   */
+  mergeStoredValue: function(base, stored) {
+    if (stored) {
+      base.forEach(function (p) {
+        var sp = stored.findProperty("name", p.name);
+        if (sp) {
+          p.set("value", sp.value);
+        }
+      });
+    }
   }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/1dd3e8f2/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js b/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js
index 4a95297..e52d8a5 100644
--- a/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js
@@ -58,6 +58,9 @@ describe('App.KerberosWizardStep4Controller', function() {
             return Em.A([
               Em.Object.create({ name: 'realm', value: 'realm_value' })
             ]);
+          },
+          loadCachedStepConfigValues: function() {
+            return null;
           }
         }
       });
@@ -185,6 +188,9 @@ describe('App.KerberosWizardStep4Controller', function() {
                 Em.Object.create({ name: 'admin_principal', value: 'some_val1', recommendedValue: 'some_val1', filename: 'krb5-conf.xml' }),
                 Em.Object.create({ name: 'admin_password', value: 'some_password', recommendedValue: 'some_password', filename: 'krb5-conf.xml' })
               ]);
+            },
+            loadCachedStepConfigValues : function() {
+              return null;
             }
           })
         });