ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ababiic...@apache.org
Subject [2/2] git commit: AMBARI-6968 Fix server validation to load all hosts on service confg page. (ababiichuk)
Date Thu, 21 Aug 2014 09:47:23 GMT
AMBARI-6968 Fix server validation to load all hosts on service confg page. (ababiichuk)


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

Branch: refs/heads/trunk
Commit: 3a05d2ca1ec4a6f4bb74f53b2ffa4a06e39bb291
Parents: 315bf96
Author: aBabiichuk <ababiichuk@cybervisiontech.com>
Authored: Thu Aug 21 12:42:53 2014 +0300
Committer: aBabiichuk <ababiichuk@cybervisiontech.com>
Committed: Thu Aug 21 12:42:53 2014 +0300

----------------------------------------------------------------------
 ambari-web/app/mixins/common/serverValidator.js | 63 ++++++++++++++++----
 1 file changed, 50 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/3a05d2ca/ambari-web/app/mixins/common/serverValidator.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/serverValidator.js b/ambari-web/app/mixins/common/serverValidator.js
index a4be042..f809538 100644
--- a/ambari-web/app/mixins/common/serverValidator.js
+++ b/ambari-web/app/mixins/common/serverValidator.js
@@ -43,6 +43,9 @@ App.ServerValidatorMixin = Em.Mixin.create({
    */
   recommendationsConfigs: null,
 
+  loadAdditionalinfo: function() {
+    return !(this.get('content.hosts') && this.get('content.hosts').length);
+  }.property('content.hosts'),
   /**
    * by default loads data from model otherwise must be overridden as computed property
    * refer to \assets\data\stacks\HDP-2.1\recommendations_configs.json to learn structure
@@ -52,10 +55,10 @@ App.ServerValidatorMixin = Em.Mixin.create({
   hostNames: function() {
     return this.get('content.hosts')
         ? Object.keys(this.get('content.hosts'))
-        : App.HostComponent.find().mapProperty('hostName').uniq();
-  }.property('content.hosts'),
-
+        : this.get('allHostNames');
+  }.property('content.hosts', 'allHostNames'),
 
+  allHostNames: [],
   /**
    * by default loads data from model otherwise must be overridden as computed property
    * @type {Array} - of strings (serviceNames)
@@ -135,21 +138,55 @@ App.ServerValidatorMixin = Em.Mixin.create({
     console.error('Load recommendations failed');
   },
 
+  serverSideValidation: function() {
+    var deferred = $.Deferred();
+    if (!App.get('supports.serverRecommendValidate')) {
+      deferred.resolve();
+    } else {
+      this.set('configValidationFailed', false);
+      if (this.get('loadAdditionalinfo')) {
+        var self = this;
+        this.getHostNames().complete(function() {
+          if (self.get('configValidationFailed')) {
+            self.warnUser(deferred);
+          } else {
+            self.runServerSideValidation(deferred);
+          }
+        });
+      } else {
+        this.runServerSideValidation(deferred);
+      }
+    }
+    return deferred;
+  },
+
+  getHostNames: function() {
+    return App.ajax.send({
+      name: 'hosts.all',
+      sender: this,
+      success: 'getHostNamesSuccess',
+      error: 'getHostNamesError'
+    })
+  },
+
+  getHostNamesSuccess: function(data) {
+    this.set("allHostNames", data.items.mapProperty("Hosts.host_name"));
+  },
+
+  getHostNamesError: function() {
+    this.set('configValidationFailed', true);
+    console.error('failed to load hostNames');
+  },
   /**
    * @method serverSideValidation
    * send request to validate configs
    * @returns {*}
    */
-  serverSideValidation: function() {
+  runServerSideValidation: function(deferred) {
     var self = this;
-    var deferred = $.Deferred();
-    if (!App.get('supports.serverRecommendValidate')) {
-      deferred.resolve();
-      return deferred;
-    }
     var recommendations = this.get('hostGroups');
     recommendations.blueprint.configurations = blueprintUtils.buildConfisJSON(this.get('services'),
this.get('stepConfigs'));
-    App.ajax.send({
+    return App.ajax.send({
       name: 'config.validations',
       sender: this,
       data: {
@@ -164,7 +201,6 @@ App.ServerValidatorMixin = Em.Mixin.create({
     }).complete(function() {
       self.warnUser(deferred);
     });
-    return deferred;
   },
 
 
@@ -178,7 +214,6 @@ App.ServerValidatorMixin = Em.Mixin.create({
     var self = this;
     self.set('configValidationError', false);
     self.set('configValidationWarning', false);
-    self.set('configValidationFailed', false);
     data.resources.forEach(function(r) {
       r.items.forEach(function(item){
         if (item.type == "configuration") {
@@ -189,7 +224,7 @@ App.ServerValidatorMixin = Em.Mixin.create({
                   self.set('configValidationError', true);
                   property.set('errorMessage', item.message);
                   property.set('error', true);
-                } else if (item.level == "ERROR") {
+                } else if (item.level == "WARN") {
                   self.set('configValidationWarning', true);
                   property.set('warnMessage', item.message);
                   property.set('warn', true);
@@ -219,10 +254,12 @@ App.ServerValidatorMixin = Em.Mixin.create({
     if (this.get('configValidationFailed')) {
       this.set('isSubmitDisabled', false);
       this.set("isApplyingChanges", false);
+      deferred.reject();
       return App.showAlertPopup(Em.I18n.t('installer.step7.popup.validation.failed.header'),
Em.I18n.t('installer.step7.popup.validation.request.failed.body'));
     } else if (this.get('configValidationError')) {
       this.set("isApplyingChanges", false);
       this.set('isSubmitDisabled', true);
+      deferred.reject();
       return App.showAlertPopup(Em.I18n.t('installer.step7.popup.validation.failed.header'),
Em.I18n.t('installer.step7.popup.validation.failed.body'));
     } else if (this.get('configValidationWarning')) {
       this.set('isSubmitDisabled', true);


Mime
View raw message