You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by is...@apache.org on 2018/03/08 22:04:38 UTC

[ambari] branch branch-feature-AMBARI-14714-ui updated: Implemented the use of the cluster settings API instead of cluster-env. (#594)

This is an automated email from the ASF dual-hosted git repository.

ishanbha pushed a commit to branch branch-feature-AMBARI-14714-ui
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/branch-feature-AMBARI-14714-ui by this push:
     new 11ca525  Implemented the use of the cluster settings API instead of cluster-env. (#594)
11ca525 is described below

commit 11ca52533ddd8a7b3e1e9da8937630b2b2dbbed6
Author: Jason Golieb <j...@golieb.net>
AuthorDate: Thu Mar 8 17:04:35 2018 -0500

    Implemented the use of the cluster settings API instead of cluster-env. (#594)
---
 .../app/controllers/wizard/step7_controller.js     |  2 +-
 .../app/controllers/wizard/step8_controller.js     | 46 ++++++++++++++--------
 .../app/controllers/wizard/step9_controller.js     | 16 ++++++--
 .../data/configs/wizards/kerberos_identities.js    |  6 +--
 .../configs/stack_config_properties_mapper.js      | 36 +++++++++++------
 ambari-web/app/styles/application.less             |  7 +++-
 ambari-web/app/styles/wizard.less                  | 14 +++++--
 ambari-web/app/templates/wizard/step9.hbs          | 13 +++---
 ambari-web/app/utils/ajax/ajax.js                  | 12 +++++-
 ambari-web/app/utils/config.js                     |  3 --
 ambari-web/test/controllers/wizard/step8_test.js   |  4 +-
 ambari-web/test/controllers/wizard/step9_test.js   |  6 +--
 ambari-web/test/utils/config_test.js               |  3 --
 13 files changed, 111 insertions(+), 57 deletions(-)

diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js
index a584a29..de3d0bd 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -553,7 +553,7 @@ App.WizardStep7Controller = App.WizardStepController.extend(App.ServerValidatorM
     if (isRangerServiceAbsent) {
       var isExternalRangerSetup;
       if (isInstallerWizard) {
-        isExternalRangerSetup = configs.filterProperty('fileName','cluster-env.xml').findProperty('name','enable_external_ranger');
+        isExternalRangerSetup = configs.filterProperty('fileName','cluster-settings.xml').findProperty('name','enable_external_ranger');
         if (Em.isNone(isExternalRangerSetup) || isExternalRangerSetup.value !== "true") {
           App.config.removeRangerConfigs(this.get('stepConfigs'));
         }
diff --git a/ambari-web/app/controllers/wizard/step8_controller.js b/ambari-web/app/controllers/wizard/step8_controller.js
index 9cfaa4d..2ef1597 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/ambari-web/app/controllers/wizard/step8_controller.js
@@ -935,7 +935,8 @@ App.WizardStep8Controller = App.WizardStepController.extend(App.AddSecurityConfi
           this.applyConfigurationsToCluster(this.generateDesiredConfigsJSON(this.get('configs'), fileNamesToUpdate));
         }
       }
-      this.createConfigurations();
+      this.configureCluster();
+      this.createServiceConfigurations();
       this.applyConfigurationsToCluster(this.get('serviceConfigTags'));
     }
     this.createComponents();
@@ -1495,15 +1496,34 @@ App.WizardStep8Controller = App.WizardStepController.extend(App.AddSecurityConfi
   },
 
   /**
-   * Create config objects for cluster and services
-   * @method createConfigurations
+   * Configure cluster settings
    */
-  createConfigurations: function () {
-    if (this.get('isInstaller')) {
-      /** add cluster-env **/
-      this.get('serviceConfigTags').pushObject(this.createDesiredConfig('cluster-env', this.get('configs').filterProperty('filename', 'cluster-env.xml')));
-    }
+  configureCluster: function () {
+    const clusterSettings = this.get('configs').filterProperty('filename', 'cluster-settings.xml');
+    const data = [];
+    clusterSettings.forEach(setting => {
+      data.push({
+        "ClusterSettingInfo": {
+          "cluster_setting_name": setting.name,
+          "cluster_setting_value": setting.value
+        }
+      })
+    });
+
+    this.addRequestToAjaxQueue({
+      name: 'common.cluster.settings',
+      data: {
+        clusterName: this.get('clusterName'),
+        data: data
+      }
+    });
+  },
 
+  /**
+   * Create config objects for services
+   * @method createServiceConfigurations
+   */
+  createServiceConfigurations: function () {
     this.get('selectedServices').forEach(function (service) {
       Object.keys(service.get('configTypes')).forEach(function (type) {
         if (!this.get('serviceConfigTags').someProperty('type', type)) {
@@ -1563,14 +1583,6 @@ App.WizardStep8Controller = App.WizardStepController.extend(App.AddSecurityConfi
         }));
       }
     }, this);
-    var clusterConfig = serviceConfigTags.findProperty('type', 'cluster-env');
-    if (clusterConfig) {
-      allConfigData.pushObject(JSON.stringify({
-        Clusters: {
-          desired_config: [clusterConfig]
-        }
-      }));
-    }
 
     this.addRequestToAjaxQueue({
       name: 'common.across.services.configurations',
@@ -1906,7 +1918,7 @@ App.WizardStep8Controller = App.WizardStepController.extend(App.AddSecurityConfi
     //service configurations
     var totalConf = [];
     //Add cluster-env
-    var clusterEnv = this.get('configs').filterProperty('filename', 'cluster-env.xml');
+    var clusterEnv = this.get('configs').filterProperty('filename', 'cluster-settings.xml');
     var configurations = {};
     configurations["cluster-env"] = self.getConfigurationDetailsForConfigType(clusterEnv);
     totalConf.push(configurations);
diff --git a/ambari-web/app/controllers/wizard/step9_controller.js b/ambari-web/app/controllers/wizard/step9_controller.js
index 1f8e0f7..cd4dd30 100644
--- a/ambari-web/app/controllers/wizard/step9_controller.js
+++ b/ambari-web/app/controllers/wizard/step9_controller.js
@@ -109,7 +109,7 @@ App.WizardStep9Controller = App.WizardStepController.extend(App.ReloadPopupMixin
    * @type {bool}
    */
   isSubmitDisabled: function () {
-    var validStates = ['STARTED', 'START FAILED', 'START_SKIPPED'];
+    var validStates = ['INSTALLED', 'STARTED', 'START FAILED', 'START_SKIPPED'];
     var controllerName = this.get('content.controllerName');
     if (controllerName == 'addHostController' || controllerName == 'addServiceController') {
       validStates.push('INSTALL FAILED');
@@ -119,7 +119,7 @@ App.WizardStep9Controller = App.WizardStepController.extend(App.ReloadPopupMixin
       || !validStates.contains(this.get('content.cluster.status'));
   }.property('content.cluster.status'),
 
-  isNextButtonDisabled: Em.computed.or('App.router.nextBtnClickInProgress', 'isSubmitDisabled', 'wizardController.errors'),
+  isNextButtonDisabled: Em.computed.or('App.router.nextBtnClickInProgress', 'isSubmitDisabled', 'wizardController.errors.length'),
 
   /**
    * Observer function: Enables previous steps link if install task failed in installer wizard.
@@ -141,7 +141,17 @@ App.WizardStep9Controller = App.WizardStepController.extend(App.ReloadPopupMixin
    * Computed property to determine if the Retry button should be made visible on the page.
    * @type {bool}
    */
-  showRetry: Em.computed.equal('content.cluster.status', 'INSTALL FAILED'),
+  showRetry: function () {
+    const status = this.get('content.cluster.status');
+    switch (status) {
+      case 'INSTALL FAILED':
+      case 'INSTALLED':
+      case 'START FAILED':
+        return true;  
+    }
+
+    return false;
+  }.property('content.cluster.status'),
 
   /**
    * Observer function: Calls {hostStatusUpdates} function once with change in a host status from any registered hosts.
diff --git a/ambari-web/app/data/configs/wizards/kerberos_identities.js b/ambari-web/app/data/configs/wizards/kerberos_identities.js
index 8af6702..e5fd2d4 100644
--- a/ambari-web/app/data/configs/wizards/kerberos_identities.js
+++ b/ambari-web/app/data/configs/wizards/kerberos_identities.js
@@ -24,21 +24,21 @@ module.exports = {
       "name": "smokeuser_principal_name",
       "displayName": "Smoke user principal",
       "category": "Ambari Principals",
-      "filename": "cluster-env.xml",
+      "filename": "cluster-settings.xml",
       "index": 1
     },
     {
       "name": "smokeuser_keytab",
       "displayName": "Smoke user keytab",
       "category": "Ambari Principals",
-      "filename": "cluster-env.xml",
+      "filename": "cluster-settings.xml",
       "index": 2
     },
     {
       "name": "ambari-server_keytab",
       "displayName": "Ambari Keytab",
       "category": "Ambari Principals",
-      "filename": "cluster-env.xml",
+      "filename": "cluster-settings.xml",
       "index": 3
     },
     {
diff --git a/ambari-web/app/mappers/configs/stack_config_properties_mapper.js b/ambari-web/app/mappers/configs/stack_config_properties_mapper.js
index 75a5564..e9f2a4b 100644
--- a/ambari-web/app/mappers/configs/stack_config_properties_mapper.js
+++ b/ambari-web/app/mappers/configs/stack_config_properties_mapper.js
@@ -64,29 +64,43 @@ App.stackConfigPropertiesMapper = App.QuickDataMapper.create({
 
   map: function (json) {
     console.time('App.stackConfigPropertiesMapper execution time');
-    if (json && json.Versions) {
-      //hack for cluster versions
-      json = {items: [json]};
-      var clusterConfigs = true;
-    }
     if (json && json.items) {
+      //check if we are working with cluster settings
+      let clusterConfigs = false;
+      if (json.items[0].ClusterSettingsInfo) {
+        //change layout to match service configs so we can use same code to process
+        json = {
+          items: [
+            { configurations: json.items }
+          ]
+        }
+
+        clusterConfigs = true;
+      }
+
       var configs = [];
-      json.items.forEach(function(stackItem) {
-        var configTypeInfo = clusterConfigs ? Em.get(stackItem, 'Versions.config_types') : Em.get(stackItem, 'StackServices.config_types');
+      json.items.forEach(function (stackItem) {
+        if (!clusterConfigs) {
+          var configTypeInfo = Em.get(stackItem, 'StackServices.config_types');
+        }
 
-        stackItem.configurations.forEach(function(config) {
+        stackItem.configurations.forEach(function (config) {
           if (clusterConfigs) {
-            config.StackConfigurations = config.StackLevelConfigurations;
+            config.StackConfigurations = config.ClusterSettingsInfo;
           }
           var configType = App.config.getConfigTagFromFileName(config.StackConfigurations.type);
           config.id = App.config.configId(config.StackConfigurations.property_name, configType);
           config.recommended_is_final = config.StackConfigurations.final === "true";
-          config.supports_final = !!configTypeInfo[configType] && configTypeInfo[configType].supports.final === "true";
+          if (!clusterConfigs) {
+            config.supports_final = !!configTypeInfo[configType] && configTypeInfo[configType].supports.final === "true";
+          } else {
+            config.supports_final = false;
+          }
 
           var attributes = config.StackConfigurations.property_value_attributes;
           if (attributes) {
             config.is_required = this._isRequired(attributes.empty_value_valid, config.StackConfigurations.property_value);
-            config.is_reconfigurable = !(attributes.editable_only_at_install || config.StackConfigurations.type === 'cluster-env.xml');
+            config.is_reconfigurable = !(attributes.editable_only_at_install || config.StackConfigurations.type === 'cluster-settings.xml');
             config.is_editable = !attributes.read_only;
             config.is_required_by_agent = !attributes.ui_only_property;
           }
diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less
index 2acfcba..51f9dc6 100644
--- a/ambari-web/app/styles/application.less
+++ b/ambari-web/app/styles/application.less
@@ -2637,8 +2637,11 @@ td .no-data {
   display: table; 
 }
 .row.same-col-heights [class*="col-"]{
-  display: table-cell;
-  float: none;
+  &.wizard-nav,
+  &.wizard-content {
+    display: table-cell;
+    float: none;
+  }
   &.wizard-content {
     width: 9999999999px;
   }
diff --git a/ambari-web/app/styles/wizard.less b/ambari-web/app/styles/wizard.less
index 52f4b59..b44d96d 100644
--- a/ambari-web/app/styles/wizard.less
+++ b/ambari-web/app/styles/wizard.less
@@ -47,9 +47,7 @@
       border: 1px solid #ddd;
     }
     .panel.panel-default.panel-internal.install-retry-panel {
-      border-top: none;
-      border-left: none;
-      border-right: none;
+      border: none;
     }
     padding: 30px;
     background-color: #fff;
@@ -374,6 +372,16 @@
     }
   }
   #deploy {
+    #overall-progress {
+      .progress {
+        margin-bottom: 0;
+      }
+
+      .progress-message {
+        vertical-align: middle;
+      }
+    }
+
     .page-bar {
       border: none;
     }
diff --git a/ambari-web/app/templates/wizard/step9.hbs b/ambari-web/app/templates/wizard/step9.hbs
index 0f74396..3bbbc46 100644
--- a/ambari-web/app/templates/wizard/step9.hbs
+++ b/ambari-web/app/templates/wizard/step9.hbs
@@ -22,18 +22,18 @@
   <div class="panel panel-default">
     <div class="panel-body">
       <p class="step-description">{{t installer.step9.body}}</p>
-      <div class="row" {{QAAttr "overall-progress"}}>
+      <div class="row" id="overall-progress" {{QAAttr "overall-progress"}}>
         <div class="col-md-10">
           <div class="progress" {{QAAttr "progress-{status}"}}>
             <div {{bindAttr class="view.isStepCompleted::progress-bar-striped view.isStepCompleted::active view.barColor :progress-bar"}} {{bindAttr style="view.barWidth"}} {{QAAttr "progress-bar-{progress}"}}>
             </div>
           </div>
         </div>
-        <div class="col-md-2" {{QAAttr "progress-message"}}>{{view.progressMessage}}</div>
+        <div class="col-md-2 progress-message" {{QAAttr "progress-message"}}>{{view.progressMessage}}</div>
       </div>
 
-      <div class="panel panel-default panel-internal install-retry-panel">
-        <div class="panel-heading">
+      <div class="row">
+        <div class="col-xs-12">
           <div class="pull-right">
             {{#if controller.showRetry}}
               <button class="btn btn-default" href="#" {{action retry}} {{QAAttr "retry-button"}}>
@@ -60,7 +60,9 @@
           </div>
           <div class="clearfix"></div>
         </div>
-        <div class="panel-body pre-scrollable">
+      </div>
+      <div class="row">
+        <div class="col-xs-12">
           <table id="deploy-status-by-host" class="table table-hover" {{QAAttr "hosts-table"}}>
             <thead>
             <tr>
@@ -111,6 +113,7 @@
           </table>
         </div>
       </div>
+      
       {{#if view.resultMsg}}
         <p {{bindAttr class="view.resultMsgColor :alert :alert-warning"}} {{QAAttr "deploy-result-{status}"}}>{{view.resultMsg}}
           {{#if view.isHostHeartbeatLost}}
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index fa31b01..674d792 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -42,6 +42,16 @@ var urls = {
     }
   },
 
+  'common.cluster.settings' : {
+    'type': 'POST',
+    'real': '/clusters/{clusterName}/settings',
+    'format': function (data) {
+      return {
+        data: JSON.stringify(data.data)
+      };
+    }
+  },
+
   'common.services.update' : {
     'real': '/clusters/{clusterName}/servicegroups/{defaultServiceGroupName}/services?{urlParams}',
     'mock': '/data/wizard/deploy/poll_1.json',
@@ -738,7 +748,7 @@ var urls = {
   /*************************STACK CONFIGS**************************************/
 
   'configs.stack_configs.load.cluster_configs': {
-    'real': '{stackVersionUrl}?fields=configurations/*,Versions/config_types/*',
+    'real': '/cluster_settings?fields=*',
     'mock': '/data/stacks/HDP-2.2/configurations.json'
   },
 
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index de3171c..371a31b 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -1037,9 +1037,6 @@ App.config = Em.Object.create({
     return App.ajax.send({
       name: 'configs.stack_configs.load.cluster_configs',
       sender: this,
-      data: {
-        stackVersionUrl: App.get('stackVersionURL')
-      },
       success: 'saveConfigsToModel'
     });
   },
diff --git a/ambari-web/test/controllers/wizard/step8_test.js b/ambari-web/test/controllers/wizard/step8_test.js
index e7e974a..597265d 100644
--- a/ambari-web/test/controllers/wizard/step8_test.js
+++ b/ambari-web/test/controllers/wizard/step8_test.js
@@ -1994,7 +1994,7 @@ describe('App.WizardStep8Controller', function () {
 
   describe('#startDeploy', function () {
 
-    var stubbedNames = ['createCluster', 'createServiceGroups', 'createSelectedServices', 'createConfigurations',
+    var stubbedNames = ['createCluster', 'createServiceGroups', 'createSelectedServices', 'configureCluster', 'createServiceConfigurations',
         'applyConfigurationsToCluster', 'createComponents', 'registerHostsToCluster', 'createConfigurationGroups',
         'createMasterHostComponents', 'createSlaveAndClientsHostComponents', 'createAdditionalClientComponents',
         'createAdditionalHostComponents'],
@@ -2007,7 +2007,7 @@ describe('App.WizardStep8Controller', function () {
         },
         {
           controllerName: 'addHostController',
-          notExecuted: ['createConfigurations', 'applyConfigurationsToCluster', 'createAdditionalClientComponents'],
+          notExecuted: ['configureCluster', 'createServiceConfigurations', 'applyConfigurationsToCluster', 'createAdditionalClientComponents'],
           title: 'Add Host Wizard'
         },
         {
diff --git a/ambari-web/test/controllers/wizard/step9_test.js b/ambari-web/test/controllers/wizard/step9_test.js
index 71b4915..83a573e 100644
--- a/ambari-web/test/controllers/wizard/step9_test.js
+++ b/ambari-web/test/controllers/wizard/step9_test.js
@@ -85,18 +85,18 @@ describe('App.InstallerStep9Controller', function () {
       {controllerName: 'addHostController', state: 'START FAILED', e: false},
       {controllerName: 'addHostController', state: 'INSTALL FAILED', e: false},
       {controllerName: 'addHostController', state: 'PENDING', e: true},
-      {controllerName: 'addHostController', state: 'INSTALLED', e: true},
+      {controllerName: 'addHostController', state: 'INSTALLED', e: false},
       {controllerName: 'addServiceController', state: 'STARTED', e: false},
       {controllerName: 'addServiceController', state: 'START_SKIPPED', e: false},
       {controllerName: 'addServiceController', state: 'START FAILED', e: false},
       {controllerName: 'addServiceController', state: 'INSTALL FAILED', e: false},
       {controllerName: 'addServiceController', state: 'PENDING', e: true},
-      {controllerName: 'addServiceController', state: 'INSTALLED', e: true},
+      {controllerName: 'addServiceController', state: 'INSTALLED', e: false},
       {controllerName: 'installerController', state: 'STARTED', e: false},
       {controllerName: 'installerController', state: 'START_SKIPPED', e: false},
       {controllerName: 'installerController', state: 'START FAILED', e: false},
       {controllerName: 'installerController', state: 'INSTALL FAILED', e: true},
-      {controllerName: 'installerController', state: 'INSTALLED', e: true},
+      {controllerName: 'installerController', state: 'INSTALLED', e: false},
       {controllerName: 'installerController', state: 'PENDING', e: true}
     ]);
     tests.forEach(function (test) {
diff --git a/ambari-web/test/utils/config_test.js b/ambari-web/test/utils/config_test.js
index 2c7baf9..05fa565 100644
--- a/ambari-web/test/utils/config_test.js
+++ b/ambari-web/test/utils/config_test.js
@@ -1601,9 +1601,6 @@ describe('App.config', function() {
       var args = testHelpers.findAjaxRequest('name', 'configs.stack_configs.load.cluster_configs');
       expect(args[0]).exists;
       expect(args[0].sender).to.be.eql(App.config);
-      expect(args[0].data).to.be.eql({
-        stackVersionUrl: App.get('stackVersionURL')
-      });
     });
   });
 

-- 
To stop receiving notification emails like this one, please contact
ishanbha@apache.org.