Bladeren bron

AMBARI-9039 UI should offer to reinstall OUT_OF_SYNC cluster stack versions. (ababiichuk)

aBabiichuk 10 jaren geleden
bovenliggende
commit
6eb5bd6316

+ 4 - 2
ambari-web/app/controllers/main/admin/stack_versions/repo_version_management_controller.js

@@ -35,8 +35,9 @@ App.RepoVersionsManagementController = Em.ArrayController.extend({
    * @type {String}
    */
   realRepoUrl: function () {
+    //TODO correct url after api will be fixed
     return App.get('apiPrefix') + App.get('stackVersionURL') +
-      '/repository_versions?fields=*,operating_systems/*,operating_systems/repositories/*';
+      '/repository_versions?fields=*,operating_systems/*,operating_systems/repositories/*,operatingSystems/*,operatingSystems/repositories/*';
   }.property('App.stackVersionURL'),
 
   /**
@@ -50,8 +51,9 @@ App.RepoVersionsManagementController = Em.ArrayController.extend({
    * @type {String}
    */
   realStackUrl: function () {
+    //TODO correct url after api will be fixed
     return App.apiPrefix + '/clusters/' + App.get('clusterName') +
-      '/stack_versions?fields=*,repository_versions/*,repository_versions/operating_systems/repositories/*';
+      '/stack_versions?fields=*,repository_versions/*,repository_versions/operating_systems/repositories/*,repository_versions/operatingSystems/repositories/*';
   }.property('App.clusterName'),
 
   /**

+ 4 - 5
ambari-web/app/controllers/main/admin/stack_versions/stack_version_details_controller.js

@@ -50,8 +50,7 @@ App.MainStackVersionsDetailsController = Em.Controller.extend({
    */
   installComplete: function() {
     return this.get('content.stackVersion.state')
-      && this.get('content.stackVersion.state') != "INSTALLING"
-      && this.get('content.stackVersion.state') != "INSTALL_FAILED";
+      && !["INSTALLING", "INSTALL_FAILED", "OUT_OF_SYNC"].contains(this.get('content.stackVersion.state'));
   }.property('content.stackVersion.state'),
 
   /**
@@ -62,7 +61,7 @@ App.MainStackVersionsDetailsController = Em.Controller.extend({
    * @type {Boolean}
    */
   notInstalled: function() {
-    return !this.get('content.stackVersion.state') || this.get('content.stackVersion.state') == "INSTALL_FAILED";
+    return !this.get('content.stackVersion.state') || ["INSTALL_FAILED", "OUT_OF_SYNC"].contains(this.get('content.stackVersion.state'));
   }.property('content.stackVersion.state'),
 
   /**
@@ -78,8 +77,8 @@ App.MainStackVersionsDetailsController = Em.Controller.extend({
    * @type {Number}
    */
   hostsToInstall: function() {
-    return this.get('content.stackVersion') ? this.get('content.stackVersion.initHosts.length') : App.get('allHostNames.length');
-  }.property('content.stackVersion.initHosts.length'),
+    return this.get('content.stackVersion') ? this.get('content.stackVersion.notInstalledHosts.length') : App.get('allHostNames.length');
+  }.property('content.stackVersion.notInstalledHosts.length'),
 
   /**
    * persentage of install progress

+ 13 - 0
ambari-web/app/mappers/stack_version_mapper.js

@@ -27,9 +27,11 @@ App.stackVersionMapper = App.QuickDataMapper.create({
     "version": "version",
     "repository_version_id": "repository_version_id",
     "state": "state",
+    "not_installed_hosts": "host_states.NOT_INSTALLED",
     "installing_hosts": "host_states.INSTALLING",
     "installed_hosts": "host_states.INSTALLED",
     "install_failed_hosts": "host_states.INSTALL_FAILED",
+    "out_of_sync_hosts": "host_states.OUT_OF_SYNC",
     "upgrading_hosts": "host_states.UPGRADING",
     "upgraded_hosts": "host_states.UPGRADED",
     "upgrade_failed_hosts": "host_states.UPGRADE_FAILED",
@@ -44,6 +46,17 @@ App.stackVersionMapper = App.QuickDataMapper.create({
       json.items.forEach(function (item) {
         var stack = item.ClusterStackVersions;
         stack.repository_version_id = item.ClusterStackVersions.repository_version;
+        /**
+         * this property contains array of hosts on which repoversion wasn't installed
+         * possible states:
+         * <code>INSTALLING<code>
+         * <code>INSTALL_FAILED<code>
+         * <code>OUT_OF_SYNC<code>
+         */
+        stack.host_states.NOT_INSTALLED = item.ClusterStackVersions.host_states.INSTALLING
+          .concat(item.ClusterStackVersions.host_states.INSTALL_FAILED)
+          .concat(item.ClusterStackVersions.host_states.OUT_OF_SYNC);
+
         /**
          * this property contains array of hosts on which repoversion was installed
          * but state of repoveriosn for this hosts can be any postinstalled state

+ 2 - 2
ambari-web/app/models/host_stack_version.js

@@ -37,7 +37,7 @@ App.HostStackVersion = DS.Model.extend({
     return App.HostStackVersion.formatStatus(this.get('status'));
   }.property('status'),
   installEnabled: function () {
-    return (this.get('status') === 'INIT' || this.get('status') === 'INSTALL_FAILED');
+    return ['OUT_OF_SYNC', 'INSTALL_FAILED'].contains(this.get('status'));
   }.property('status'),
   installDisabled: Ember.computed.not('installEnabled')
 });
@@ -52,7 +52,7 @@ App.HostStackVersion.statusDefinition = [
   "INSTALLED",
   "INSTALLING",
   "INSTALL_FAILED",
-  "INIT",
+  "OUT_OF_SYNC",
   "CURRENT"
 ];
 

+ 4 - 6
ambari-web/app/models/stack_version/version.js

@@ -27,18 +27,16 @@ App.StackVersion = DS.Model.extend({
   }.property('stack', 'version'),
   state: DS.attr('string'),
   repositoryVersion: DS.belongsTo('App.RepositoryVersion'),
+  notInstalledHosts: DS.attr('array'),
   installingHosts: DS.attr('array'),
   installedHosts: DS.attr('array'),
   installFailedHosts: DS.attr('array'),
+  outOfSyncHosts: DS.attr('array'),
   upgradingHosts: DS.attr('array'),
   upgradedHosts: DS.attr('array'),
   upgradeFailedHosts: DS.attr('array'),
   currentHosts: DS.attr('array'),
 
-  initHosts:  function() {
-    return this.get('installingHosts') && this.get('installingHosts').concat(this.get('installFailedHosts'));
-  }.property('installFailedHosts', 'installingHosts'),
-
   noInstalledHosts:  function() {
     return this.get('installedHosts.length') == 0;
   }.property('installedHosts.length'),
@@ -48,8 +46,8 @@ App.StackVersion = DS.Model.extend({
   }.property('currentHosts.length'),
 
   noInitHosts: function() {
-    return this.get('initHosts.length') == 0;
-  }.property('initHosts.length')
+    return this.get('notInstalledHosts.length') == 0;
+  }.property('notInstalledHosts.length')
 });
 
 App.StackVersion.FIXTURES = [];

+ 3 - 3
ambari-web/app/templates/main/admin/stack_versions/stack_version_details.hbs

@@ -31,9 +31,9 @@
               <div class="span3">{{t admin.stackVersions.details.not.installed.on}}</div>
               <div {{bindAttr class="view.noInitHosts:not-active-link :span6"}}>
                 <a href="#" class="not-installed-hosts-count"
-                  {{action showHosts view.versionStateMap.not_installed content.repositoryVersion view.initHosts target="App.router.mainStackVersionsController"}}>
-                  {{view.initHosts.length}}&nbsp;
-                  {{pluralize view.initHosts.length singular="t:admin.stackVersions.details.host" plural="t:admin.stackVersions.details.hosts"}}
+                  {{action showHosts view.versionStateMap.not_installed content.repositoryVersion view.notInstalledHosts target="App.router.mainStackVersionsController"}}>
+                  {{view.notInstalledHosts.length}}&nbsp;
+                  {{pluralize view.notInstalledHosts.length singular="t:admin.stackVersions.details.host" plural="t:admin.stackVersions.details.hosts"}}
                 </a>
               </div>
             </div>

+ 4 - 4
ambari-web/app/views/main/admin/stack_versions/stack_version_details_view.js

@@ -68,13 +68,13 @@ App.MainStackVersionsDetailsView = Em.View.extend({
    * hosts with stack versions in not installed state
    * when stack version for repoversion is not created returns all hosts in cluster
    */
-  initHosts: function() {
-    if (this.get('showCounters') && this.get('content.stackVersion.installingHosts') && this.get('content.stackVersion.installFailedHosts')) {
-      return this.get('content.stackVersion.installingHosts').concat(this.get('content.stackVersion.installFailedHosts'));
+  notInstalledHosts: function() {
+    if (this.get('showCounters') && this.get('content.stackVersion.notInstalledHosts')) {
+      return this.get('content.stackVersion.notInstalledHosts');
     } else {
       return App.get('allHostNames');
     }
-  }.property('showCounters', 'content.stackVersion.installingHosts.length', 'content.stackVersion.installFailedHosts.length', 'App.allHostNames'),
+  }.property('showCounters', 'content.stackVersion.notInstalledHosts.length', 'App.allHostNames'),
 
   /**
    * hosts with stack versions in installed state

+ 1 - 1
ambari-web/test/models/host_stack_version_test.js

@@ -62,7 +62,7 @@ describe('App.HostStackVersion', function () {
   describe("#installEnabled", function () {
     var testCases = [
       {
-        status: 'INIT',
+        status: 'OUT_OF_SYNC',
         result: true
       },
       {

+ 11 - 0
ambari-web/test/views/main/admin/stack_version/stack_version_details_test.js

@@ -50,6 +50,12 @@ describe('App.MainStackVersionsDetailsView', function () {
       view.set("content.stackVersion.state", "INSTALL_FAILED");
       expect(view.get('installButtonMsg')).to.equal(Em.I18n.t('admin.stackVersions.details.hosts.btn.reinstall'))
     });
+
+    it("install button msg for out of sync failed state" , function() {
+      view.set("controller.hostsToInstall", 1);
+      view.set("content.stackVersion.state", "OUT_OF_SYNC");
+      expect(view.get('installButtonMsg')).to.equal(Em.I18n.t('admin.stackVersions.details.hosts.btn.install').format(1))
+    });
   });
 
   describe('#installButtonClass', function () {
@@ -62,6 +68,11 @@ describe('App.MainStackVersionsDetailsView', function () {
       view.set("content.stackVersion.state", "INSTALL_FAILED");
       expect(view.get('installButtonClass')).to.equal('btn-danger')
     });
+
+    it("install button class install out of sync state" , function() {
+      view.set("content.stackVersion.state", "OUT_OF_SYNC");
+      expect(view.get('installButtonClass')).to.equal('btn-success')
+    });
   });
 
   describe('#progress', function () {