ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexantone...@apache.org
Subject ambari git commit: AMBARI-13043. Ambari upgrade 1.6.1 to 2.1.1. Missed info from stack_versions endpoint. (alexantonenko)
Date Wed, 09 Sep 2015 09:17:37 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 6d9b99751 -> 50613bbdd


AMBARI-13043. Ambari upgrade 1.6.1 to 2.1.1. Missed info from stack_versions endpoint. (alexantonenko)


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

Branch: refs/heads/branch-2.1
Commit: 50613bbdda10d666649cf3c9834b0052391edc47
Parents: 6d9b997
Author: Alex Antonenko <hiveww@gmail.com>
Authored: Wed Sep 9 12:01:48 2015 +0300
Committer: Alex Antonenko <hiveww@gmail.com>
Committed: Wed Sep 9 12:17:32 2015 +0300

----------------------------------------------------------------------
 .../app/controllers/wizard/step8_controller.js  | 61 ++++++++++++++++++--
 1 file changed, 55 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/50613bbd/ambari-web/app/controllers/wizard/step8_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step8_controller.js b/ambari-web/app/controllers/wizard/step8_controller.js
index 20f6a30..fe24f2a 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/ambari-web/app/controllers/wizard/step8_controller.js
@@ -454,7 +454,12 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs,
App.wiz
 
     //repo
     if (['addHostController', 'addServiceController'].contains(this.get('content.controllerName')))
{
-      this.loadRepoInfo();
+      // For some stacks there is no info regarding stack versions to upgrade, e.g. HDP-2.1
+      if (App.StackVersion.find().get('content.length')) {
+        this.loadRepoInfo();
+      } else {
+        this.loadDefaultRepoInfo();
+      }
     } else {
       // from install wizard
       var selectedStack = App.Stack.find().findProperty('isSelected');
@@ -505,17 +510,61 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs,
App.wiz
    * @method loadRepoInfoSuccessCallback
    */
   loadRepoInfoSuccessCallback: function (data) {
-    var allRepos = [];
     Em.assert('Current repo-version may be only one', data.items.length === 1);
-    data.items[0].repository_versions[0].operating_systems.forEach(function (os) {
-      os.repositories.forEach(function (repository) {
-        allRepos.push(Em.Object.create({
+    if (data.items.length) {
+      var allRepos = this.generateRepoInfo(Em.getWithDefault(data, 'items.0.repository_versions.0.operating_systems',
[]));
+      allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
+      this.get('clusterInfo').set('repoInfo', allRepos);
+    } else {
+      this.loadDefaultRepoInfo();
+    }
+  },
+
+  /**
+   * Generate list regarding info about OS versions and repositories.
+   *
+   * @param {Object{}} oses - OS array
+   * @returns {Em.Object[]}
+   */
+  generateRepoInfo: function(oses) {
+    return oses.map(function(os) {
+      return os.repositories.map(function (repository) {
+        return Em.Object.create({
           base_url: repository.Repositories.base_url,
           os_type: repository.Repositories.os_type,
           repo_id: repository.Repositories.repo_id
-        }));
+        });
       });
+    }).reduce(function(p, c) { return p.concat(c); });
+  },
+
+  /**
+   * Load repo info from stack. Used if installed stack doesn't have upgrade info.
+   *
+   * @returns {$.Deferred}
+   * @method loadDefaultRepoInfo
+   */
+  loadDefaultRepoInfo: function() {
+    var nameVersionCombo = App.get('currentStackVersion').split('-');
+
+    return App.ajax.send({
+      name: 'cluster.load_repositories',
+      sender: this,
+      data: {
+        stackName: nameVersionCombo[0],
+        stackVersion: nameVersionCombo[1]
+      },
+      success: 'loadDefaultRepoInfoSuccessCallback',
+      error: 'loadRepoInfoErrorCallback'
     });
+  },
+
+  /**
+   * @param {Object} data - JSON data from server
+   * @method loadDefaultRepoInfoSuccessCallback
+   */
+  loadDefaultRepoInfoSuccessCallback: function (data) {
+    var allRepos = this.generateRepoInfo(Em.getWithDefault(data, 'items', []));
     allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
     this.get('clusterInfo').set('repoInfo', allRepos);
   },


Mime
View raw message