You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2015/10/19 15:54:34 UTC

[48/50] [abbrv] ambari git commit: AMBARI-13472. KDC Credentials: Retrieve storage type along with Security Status.

AMBARI-13472. KDC Credentials: Retrieve storage type along with Security Status.


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 16b2f928c74204fda45dedca4605568cd3ef0aa7
Parents: 27acc3a
Author: Alex Antonenko <hi...@gmail.com>
Authored: Mon Oct 19 15:39:30 2015 +0300
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Mon Oct 19 15:49:02 2015 +0300

----------------------------------------------------------------------
 .../controllers/global/cluster_controller.js    |  1 +
 .../main/admin/kerberos/step2_controller.js     |  4 ---
 .../main/admin/kerberos/wizard_controller.js    |  9 +------
 ambari-web/app/mappers/cluster_mapper.js        |  4 +--
 .../common/kdc_credentials_controller_mixin.js  |  5 ++--
 ambari-web/app/models/cluster.js                | 10 +++++--
 .../app/views/common/chart/linear_time.js       |  8 +++---
 .../common/form/manage_credentials_form_view.js |  9 +++----
 .../common/modal_popups/invalid_KDC_popup.js    | 15 +++--------
 .../kdc_credentials_controller_mixin_test.js    | 28 --------------------
 .../form/manage_kdc_credentials_form_test.js    |  6 ++---
 11 files changed, 27 insertions(+), 72 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/16b2f928/ambari-web/app/controllers/global/cluster_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/cluster_controller.js b/ambari-web/app/controllers/global/cluster_controller.js
index 8c7b19c..6fdfc18 100644
--- a/ambari-web/app/controllers/global/cluster_controller.js
+++ b/ambari-web/app/controllers/global/cluster_controller.js
@@ -197,6 +197,7 @@ App.ClusterController = Em.Controller.extend(App.ReloadPopupMixin, {
 
     App.HttpClient.get(clusterUrl, App.clusterMapper, {
       complete: function (jqXHR, textStatus) {
+        App.set('isCredentialStorePersistent', Em.getWithDefault(App.Cluster.find().findProperty('clusterName', App.get('clusterName')), 'isCredentialStorePersistent', false));
       }
     }, function (jqXHR, textStatus) {
     });

http://git-wip-us.apache.org/repos/asf/ambari/blob/16b2f928/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 77a27e5..59cb813 100644
--- a/ambari-web/app/controllers/main/admin/kerberos/step2_controller.js
+++ b/ambari-web/app/controllers/main/admin/kerberos/step2_controller.js
@@ -36,10 +36,6 @@ App.KerberosWizardStep2Controller = App.WizardStep7Controller.extend(App.KDCCred
 
   addMiscTabToPage: false,
 
-  isStorePersisted: function() {
-    return this.get('wizardController.content.secureStoragePersisted');
-  }.property('wizardController.content.secureStoragePersisted'),
-
   /**
    * @type {boolean} true if test connection to hosts is in progress
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/16b2f928/ambari-web/app/controllers/main/admin/kerberos/wizard_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/kerberos/wizard_controller.js b/ambari-web/app/controllers/main/admin/kerberos/wizard_controller.js
index 4541914..69329a0 100644
--- a/ambari-web/app/controllers/main/admin/kerberos/wizard_controller.js
+++ b/ambari-web/app/controllers/main/admin/kerberos/wizard_controller.js
@@ -64,8 +64,7 @@ App.KerberosWizardController = App.WizardController.extend(App.InstallComponent,
     services: [],
     advancedServiceConfig: null,
     serviceConfigProperties: [],
-    failedTask: null,
-    secureStoragePersisted: null
+    failedTask: null
   }),
 
   /**
@@ -241,13 +240,7 @@ App.KerberosWizardController = App.WizardController.extend(App.InstallComponent,
       {
         type: 'sync',
         callback: function () {
-          var self = this;
           this.loadKerberosOption();
-          if (App.get('supports.storeKDCCredentials')) {
-            credentialsUtils.isStorePersisted(App.get('clusterName')).then(function(isPersisted) {
-              self.set('content.secureStoragePersisted', isPersisted);
-            });
-          }
         }
       }
     ],

http://git-wip-us.apache.org/repos/asf/ambari/blob/16b2f928/ambari-web/app/mappers/cluster_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/cluster_mapper.js b/ambari-web/app/mappers/cluster_mapper.js
index 4604aaf..5689867 100644
--- a/ambari-web/app/mappers/cluster_mapper.js
+++ b/ambari-web/app/mappers/cluster_mapper.js
@@ -25,7 +25,6 @@ App.clusterMapper = App.QuickDataMapper.create({
         var result = json;
         result = this.parseIt(result, this.config);
         App.store.load(this.get('model'), result);
-        
         var cluster = App.Cluster.find(result.id);
         var clusterDesiredConfigs = [];
         // Create desired_configs_array
@@ -57,6 +56,7 @@ App.clusterMapper = App.QuickDataMapper.create({
       stack_name: 'Clusters.stack_name',
       version: 'Clusters.version',
       security_type: 'Clusters.security_type',
-      total_hosts: 'Clusters.total_hosts'
+      total_hosts: 'Clusters.total_hosts',
+      credential_store_properties: 'Clusters.credential_store_properties'
     }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/16b2f928/ambari-web/app/mixins/common/kdc_credentials_controller_mixin.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/kdc_credentials_controller_mixin.js b/ambari-web/app/mixins/common/kdc_credentials_controller_mixin.js
index 070ea35..a634ef9 100644
--- a/ambari-web/app/mixins/common/kdc_credentials_controller_mixin.js
+++ b/ambari-web/app/mixins/common/kdc_credentials_controller_mixin.js
@@ -30,13 +30,12 @@ App.KDCCredentialsControllerMixin = Em.Mixin.create({
 
   /**
    * Returns <code>true</code> if persisted secure storage available.
-   * Should be implemented as computed property.
    *
    * @type {boolean}
    */
   isStorePersisted: function() {
-    Em.assert("Should be implemented", false);
-  }.property(),
+    return App.get('isCredentialStorePersistent');
+  }.property('App.isCredentialStorePersistent'),
 
   /**
    * List of required UI-only properties needed for storing KDC credentials

http://git-wip-us.apache.org/repos/asf/ambari/blob/16b2f928/ambari-web/app/models/cluster.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/cluster.js b/ambari-web/app/models/cluster.js
index b4a2010..18ad1ce 100644
--- a/ambari-web/app/models/cluster.js
+++ b/ambari-web/app/models/cluster.js
@@ -18,6 +18,7 @@
 
 
 var App = require('app');
+var credentialUtils = require('utils/credentials');
 
 App.Cluster = DS.Model.extend({
   clusterName: DS.attr('string'),
@@ -25,6 +26,7 @@ App.Cluster = DS.Model.extend({
   version: DS.attr('string'),
   totalHosts:DS.attr('number'),
   securityType: DS.attr('string'),
+  credentialStoreProperties: DS.attr('object', {defaultValue: {}}),
   /**
    * Array containing desired configs. New array
    * should be set by instances of class.
@@ -33,7 +35,11 @@ App.Cluster = DS.Model.extend({
 
   isKerberosEnabled: function() {
     return this.get('securityType') === 'KERBEROS';
-  }.property('securityType')
+  }.property('securityType'),
+
+  isCredentialStorePersistent: function() {
+    return this.get('credentialStoreProperties')[credentialUtils.STORE_TYPES.PERSISTENT_PATH] === "true";
+  }.property('credentialStoreProperties')
 });
 
-App.Cluster.FIXTURES = [];
\ No newline at end of file
+App.Cluster.FIXTURES = [];

http://git-wip-us.apache.org/repos/asf/ambari/blob/16b2f928/ambari-web/app/views/common/chart/linear_time.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/chart/linear_time.js b/ambari-web/app/views/common/chart/linear_time.js
index 18f80c3..f6e71a3 100644
--- a/ambari-web/app/views/common/chart/linear_time.js
+++ b/ambari-web/app/views/common/chart/linear_time.js
@@ -511,8 +511,12 @@ App.ChartLinearTimeView = Ember.View.extend(App.ExportMetricsMixin, {
         var avg = 0;
         var min = Number.MAX_VALUE;
         var max = Number.MIN_VALUE;
+        var numberOfNotNullValues = 0;
         for (var i = 0; i < series.data.length; i++) {
           avg += series.data[i]['y'];
+          if (series.data[i]['y'] !== null) {
+            numberOfNotNullValues++;
+          }
           if (!Em.isNone(series.data[i]['y'])) {
             if (series.data[i]['y'] < min) {
               min = series.data[i]['y'];
@@ -522,13 +526,11 @@ App.ChartLinearTimeView = Ember.View.extend(App.ExportMetricsMixin, {
             max = series.data[i]['y'];
           }
         }
-
-
         series.name = string_utils.pad(series.name.length > 36 ? series.name.substr(0, 36) + '...' : series.name, 40, '&nbsp;', 2) + '|&nbsp;' +
           string_utils.pad('min', 5, '&nbsp;', 3) +
           string_utils.pad(self.get('yAxisFormatter')(min), 12, '&nbsp;', 3) +
           string_utils.pad('avg', 5, '&nbsp;', 3) +
-          string_utils.pad(self.get('yAxisFormatter')(avg / series.data.compact().length), 12, '&nbsp;', 3) +
+          string_utils.pad(self.get('yAxisFormatter')(avg / numberOfNotNullValues), 12, '&nbsp;', 3) +
           string_utils.pad('max', 12, '&nbsp;', 3) +
           string_utils.pad(self.get('yAxisFormatter')(max), 5, '&nbsp;', 3);
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/16b2f928/ambari-web/app/views/common/form/manage_credentials_form_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/form/manage_credentials_form_view.js b/ambari-web/app/views/common/form/manage_credentials_form_view.js
index c71021c..2bc27ee 100644
--- a/ambari-web/app/views/common/form/manage_credentials_form_view.js
+++ b/ambari-web/app/views/common/form/manage_credentials_form_view.js
@@ -36,7 +36,9 @@ App.ManageCredentialsFormView = Em.View.extend({
    * Status of persistent storage. Returns <code>true</code> if persistent storage is available.
    * @type {boolean}
    */
-  storePersisted: false,
+  storePersisted: function() {
+    return App.get('isCredentialStorePersistent');
+  }.property('App.isCredentialStorePersistent'),
 
   /**
    * Disable checkbox if persistent storage not available
@@ -120,11 +122,6 @@ App.ManageCredentialsFormView = Em.View.extend({
 
   prepareContent: function() {
     var self = this;
-    credentialsUtils.isStorePersisted(App.get('clusterName')).then(function(isPersisted) {
-      Em.run.next(function() {
-        self.set('storePersisted', isPersisted);
-      });
-    });
     credentialsUtils.credentials(App.get('clusterName'), function(credentials) {
       Em.run.next(function() {
         self.set('isRemovable', credentialsUtils.isKDCCredentialsPersisted(credentials));

http://git-wip-us.apache.org/repos/asf/ambari/blob/16b2f928/ambari-web/app/views/common/modal_popups/invalid_KDC_popup.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/modal_popups/invalid_KDC_popup.js b/ambari-web/app/views/common/modal_popups/invalid_KDC_popup.js
index ca5de7d..9de8537b 100644
--- a/ambari-web/app/views/common/modal_popups/invalid_KDC_popup.js
+++ b/ambari-web/app/views/common/modal_popups/invalid_KDC_popup.js
@@ -42,7 +42,9 @@ App.showInvalidKDCPopup = function (ajaxOpt, message) {
      * Status of persistent storage. Returns <code>true</code> if persistent storage is available.
      * @type {boolean}
      */
-    storePersisted: false,
+    storePersisted: function() {
+      return App.get('isCredentialStorePersistent');
+    }.property('App.isCredentialStorePersistent'),
 
     /**
      * Disable checkbox if persistent storage not available
@@ -76,17 +78,6 @@ App.showInvalidKDCPopup = function (ajaxOpt, message) {
       templateName: require('templates/common/modal_popups/invalid_KDC_popup')
     }),
 
-    willInsertElement: function() {
-      if (App.get('supports.storeKDCCredentials')) {
-        var self = this;
-        credentialsUtils.isStorePersisted(App.get('clusterName')).then(function(isPersisted) {
-          Em.run.next(function() {
-            self.set('storePersisted', isPersisted);
-          });
-        });
-      }
-    },
-
     didInsertElement: function() {
       this._super();
       App.tooltip(this.$('[rel="tooltip"]'));

http://git-wip-us.apache.org/repos/asf/ambari/blob/16b2f928/ambari-web/test/mixins/common/kdc_credentials_controller_mixin_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/kdc_credentials_controller_mixin_test.js b/ambari-web/test/mixins/common/kdc_credentials_controller_mixin_test.js
index a584979..2553397 100644
--- a/ambari-web/test/mixins/common/kdc_credentials_controller_mixin_test.js
+++ b/ambari-web/test/mixins/common/kdc_credentials_controller_mixin_test.js
@@ -33,34 +33,6 @@ describe('App.KDCCredentialsControllerMixin', function() {
     mixedObject.destroy();
   });
 
-  describe('#isStorePersisted', function() {
-    it('should throw error if not overrided in mixed object', function() {
-      var errorThrown = false;
-      try {
-        mixedObject.get('isStorePersisted');
-      } catch (e) {
-        errorThrown = true;
-      } finally {
-        expect(errorThrown).to.be.true;
-      }
-    });
-    it('should not throw error if overrided in mixed object', function() {
-      var errorThrown = false;
-      mixedObject.reopen({
-        isStorePersisted: function() {
-          return true;
-        }.property()
-      });
-      try {
-        mixedObject.get('isStorePersisted');
-      } catch (e) {
-        errorThrown = true;
-      } finally {
-        expect(errorThrown).to.be.false;
-      }
-    });
-  });
-
   describe('#initilizeKDCStoreProperties', function() {
     [
       {

http://git-wip-us.apache.org/repos/asf/ambari/blob/16b2f928/ambari-web/test/views/common/form/manage_kdc_credentials_form_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/form/manage_kdc_credentials_form_test.js b/ambari-web/test/views/common/form/manage_kdc_credentials_form_test.js
index ca5e4d0..0d8c9af 100644
--- a/ambari-web/test/views/common/form/manage_kdc_credentials_form_test.js
+++ b/ambari-web/test/views/common/form/manage_kdc_credentials_form_test.js
@@ -69,16 +69,14 @@ describe('#App.ManageCredentialsFormView', function() {
         sinon.stub(credentialUtils, 'credentials', function(clusterName, callback) {
           callback(test.credentials);
         });
-        sinon.stub(credentialUtils, 'isStorePersisted', function() {
-          return $.Deferred().resolve(test.isStorePersistent).promise();
-        });
+        sinon.stub(App, 'get').withArgs('isCredentialStorePersistent').returns(test.e.storePersisted);
         view.prepareContent();
         Em.run.next(function() {
           assert.equal(view.get('isRemovable'), test.e.isRemovable, '#isRemovable property validation');
           assert.equal(view.get('isRemoveDisabled'), test.e.isRemoveDisabled, '#isRemoveDisabled property validation');
           assert.equal(view.get('storePersisted'), test.e.storePersisted, '#storePersisted property validation');
           credentialUtils.credentials.restore();
-          credentialUtils.isStorePersisted.restore();
+          App.get.restore();
           done();
         });
       });