ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject ambari git commit: AMBARI-21437 Allow user to execute force_remove_packages custom action from UI. (atkach)
Date Mon, 10 Jul 2017 16:53:40 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-feature-AMBARI-21348 b3be727e1 -> a42e2730e


AMBARI-21437 Allow user to execute force_remove_packages custom action from UI. (atkach)


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

Branch: refs/heads/branch-feature-AMBARI-21348
Commit: a42e2730e01fee9d9bdd591e3c0bea03236d1525
Parents: b3be727
Author: Andrii Tkach <atkach@apache.org>
Authored: Mon Jul 10 19:47:03 2017 +0300
Committer: Andrii Tkach <atkach@apache.org>
Committed: Mon Jul 10 19:47:03 2017 +0300

----------------------------------------------------------------------
 ambari-web/app/messages.js                      |  1 +
 .../main/admin/stack_upgrade/versions.hbs       |  7 ++++
 ambari-web/app/utils/ajax/ajax.js               | 24 +++++++++++
 .../main/admin/stack_upgrade/versions_view.js   | 16 ++++++++
 .../admin/stack_upgrade/version_view_test.js    | 42 ++++++++++++++++++++
 5 files changed, 90 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/a42e2730/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 703a40a..7a6482f 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1709,6 +1709,7 @@ Em.I18n.translations = {
   'admin.stackVersions.version.emptyHostsTooltip': 'No Hosts to List',
   'admin.stackVersions.version.notInstalled': "Not Installed",
   'admin.stackVersions.version.hostsInfoTooltip': "There are {0} hosts that do not need packages
installed:<li>{1} Maintenance Mode</li><li>{2} Not Required</li>",
+  'admin.stackVersions.removeIopSelect': "Remove IOP select",
   'admin.stackVersions.manageVersions': "Manage Versions",
   'admin.stackVersions.manageVersions.popup.body': 'You are about to leave the <b>Cluster
Management</b> interface' +
     ' and go to the <b>Ambari Administration</b> interface. You can return to
cluster management by using the' +

http://git-wip-us.apache.org/repos/asf/ambari/blob/a42e2730/ambari-web/app/templates/main/admin/stack_upgrade/versions.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/admin/stack_upgrade/versions.hbs b/ambari-web/app/templates/main/admin/stack_upgrade/versions.hbs
index bcc4b63..b7fac72 100644
--- a/ambari-web/app/templates/main/admin/stack_upgrade/versions.hbs
+++ b/ambari-web/app/templates/main/admin/stack_upgrade/versions.hbs
@@ -40,6 +40,13 @@
       {{/each}}
     </ul>
   </div>
+  {{#isAuthorized "AMBARI.MANAGE_STACK_VERSIONS"}}
+    {{#if view.showRemoveIopSelect}}
+      <button class="btn btn-danger pull-right" {{action removeIopSelect target="view"}}
id="remove-iop-select">
+        {{t admin.stackVersions.removeIopSelect}}
+      </button>
+    {{/if}}
+  {{/isAuthorized}}
 </div>
 <div id="versions-section" class="row-fluid">
   <div class="span2 left-menu-table">

http://git-wip-us.apache.org/repos/asf/ambari/blob/a42e2730/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index 92f05f1..6dce323 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -1837,6 +1837,30 @@ var urls = {
     }
   },
 
+  'admin.stack_versions.removeIopSelect': {
+    'real': '/requests',
+    'mock': '',
+    'type': 'POST',
+    'format': function (data) {
+      return {
+        data: JSON.stringify({
+          "RequestInfo":{
+            "context": "Remove IOP select",
+            "action": "force_remove_packages",
+            "parameters": {
+              "package_list": "iop-select"
+            }
+          },
+          "Requests/resource_filters": [
+            {
+              "hosts": data.hosts
+            }
+          ]
+        })
+      }
+    }
+  },
+
   'admin.upgrade.pre_upgrade_check': {
     'real': '/clusters/{clusterName}/rolling_upgrades_check?fields=*&UpgradeChecks/repository_version={value}&UpgradeChecks/upgrade_type={type}&UpgradeChecks/target_stack={targetStack}',
     'mock': '/data/stack_versions/pre_upgrade_check.json'

http://git-wip-us.apache.org/repos/asf/ambari/blob/a42e2730/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js b/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js
index c87cb81..f3c7b2f 100644
--- a/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js
+++ b/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js
@@ -243,6 +243,22 @@ App.MainAdminStackVersionsView = Em.View.extend({
         self.doPolling();
       });
     }
+  },
+
+  showRemoveIopSelect: function() {
+    return App.get('currentStackName') === 'BigInsights' && !App.get('upgradeIsRunning');
+  }.property('App.currentStackName', 'App.upgradeIsRunning'),
+
+  removeIopSelect: function() {
+    return App.showConfirmationPopup(function () {
+      App.ajax.send({
+        name: 'admin.stack_versions.removeIopSelect',
+        sender: this,
+        data: {
+          hosts: App.get('allHostNames').join(',')
+        }
+      });
+    });
   }
 
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/a42e2730/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
index cf9906f..8c8d5c7 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
@@ -485,4 +485,46 @@ describe('App.mainAdminStackVersionsView', function () {
       expect(view.get('controller').load.called).to.be.false;
     });
   });
+
+  describe('#showRemoveIopSelect', function() {
+    beforeEach(function() {
+      this.mockApp = sinon.stub(App, 'get');
+    });
+    afterEach(function() {
+      this.mockApp.restore();
+    });
+
+    it('should be true when BigInsights stack and upgrade not running', function() {
+      this.mockApp.withArgs('currentStackName').returns('BigInsights');
+      this.mockApp.withArgs('upgradeIsRunning').returns(false);
+      expect(view.get('showRemoveIopSelect')).to.be.true;
+    });
+
+    it('should be false when BigInsights stack and upgrade running', function() {
+      this.mockApp.withArgs('currentStackName').returns('BigInsights');
+      this.mockApp.withArgs('upgradeIsRunning').returns(true);
+      expect(view.get('showRemoveIopSelect')).to.be.false;
+    });
+
+    it('should be false when HDP stack and upgrade not running', function() {
+      this.mockApp.withArgs('currentStackName').returns('HDP');
+      this.mockApp.withArgs('upgradeIsRunning').returns(false);
+      expect(view.get('showRemoveIopSelect')).to.be.false;
+    });
+  });
+
+  describe('#removeIopSelect', function() {
+    beforeEach(function() {
+      sinon.stub(App, 'showConfirmationPopup', Em.clb);
+    });
+    afterEach(function() {
+      App.showConfirmationPopup.restore();
+    });
+
+    it('App.ajax.send should be called', function() {
+      view.removeIopSelect();
+      var args = testHelpers.findAjaxRequest('name', 'admin.stack_versions.removeIopSelect');
+      expect(args[0]).exists;
+    });
+  });
 });


Mime
View raw message