Repository: ambari Updated Branches: refs/heads/trunk 8f7576f20 -> cddb46fe0
AMBARI-14731. Ability to re-install all host components that failed to install (INSTALL_FAILED state) from UI (Joe Wang via rzang) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/cddb46fe Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/cddb46fe Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/cddb46fe Branch: refs/heads/trunk Commit: cddb46fe0c8b580d5cf0bb5ee0cdf1de50d1be7b Parents: 8f7576f Author: Richard Zang <rz...@apache.org> Authored: Fri Jan 22 07:08:20 2016 +0800 Committer: Richard Zang <rz...@apache.org> Committed: Fri Jan 22 07:09:34 2016 +0800 ---------------------------------------------------------------------- .../main/host/bulk_operations_controller.js | 24 ++++++++++++++++++++ ambari-web/app/messages.js | 2 ++ .../views/main/host/hosts_table_menu_view.js | 7 ++++++ .../host/bulk_operations_controller_test.js | 10 ++++++++ 4 files changed, 43 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/cddb46fe/ambari-web/app/controllers/main/host/bulk_operations_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/host/bulk_operations_controller.js b/ambari-web/app/controllers/main/host/bulk_operations_controller.js index 8703016..13b7d96 100644 --- a/ambari-web/app/controllers/main/host/bulk_operations_controller.js +++ b/ambari-web/app/controllers/main/host/bulk_operations_controller.js @@ -55,6 +55,9 @@ App.BulkOperationsController = Em.Controller.extend({ if (operationData.action === 'RESTART') { this.bulkOperationForHostsRestart(operationData, hosts); } + else if (operationData.action === 'REINSTALL'){ + this.bulkOperationForHostsReinstall(operationData, hosts); + } else { if (operationData.action === 'PASSIVE_STATE') { this.bulkOperationForHostsPassiveState(operationData, hosts); @@ -225,6 +228,27 @@ App.BulkOperationsController = Em.Controller.extend({ }, /** + * Bulk reinstall failed components for selected hosts + * @param {Object} operationData - data about bulk operation (action, hostComponents etc) + * @param {Ember.Enumerable} hosts - list of affected hosts + */ + bulkOperationForHostsReinstall: function (operationData, hosts) { + return App.ajax.send({ + name: 'common.host_components.update', + sender: this, + data: { + HostRoles: { + state: 'INSTALLED' + }, + query: 'HostRoles/host_name.in(' + hosts.mapProperty('hostName').join(',') + ')&HostRoles/state=INSTALL_FAILED', + context: operationData.message, + noOpsMessage: Em.I18n.t('hosts.host.maintainance.reinstallFailedComponents.context') + }, + success: 'bulkOperationForHostComponentsSuccessCallback' + }); + }, + + /** * Bulk turn on/off passive state for selected hosts * @param {Object} operationData - data about bulk operation (action, hostComponents etc) * @param {Array} hosts - list of affected hosts http://git-wip-us.apache.org/repos/asf/ambari/blob/cddb46fe/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index fac2893..3ca62fc 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -2241,6 +2241,7 @@ Em.I18n.translations = { 'hosts.table.menu.l1.allHosts':'All Hosts', 'hosts.table.menu.l2.allComponents':'All Components', 'hosts.table.menu.l2.restartAllComponents':'Restart All Components', + 'hosts.table.menu.l2.reinstallFailedComponents':'Reinstall Failed Components', 'hosts.bulkOperation.confirmation.header':'Confirm Bulk Operation', 'hosts.bulkOperation.confirmation.hosts':'Are you sure you want to <strong>{0}</strong> on the following {1} hosts?', @@ -2388,6 +2389,7 @@ Em.I18n.translations = { 'hosts.host.maintainance.allComponents.context': 'All Host Components', 'hosts.host.maintainance.stopAllComponents.context': 'Stop All Host Components', 'hosts.host.maintainance.startAllComponents.context': 'Start All Host Components', + 'hosts.host.maintainance.reinstallFailedComponents.context': 'Reinstall Failed Components', 'hosts.host.alerts.st':' ! ', 'hosts.decommission.popup.body':'Are you sure?', 'hosts.decommission.popup.header':'Confirmation', http://git-wip-us.apache.org/repos/asf/ambari/blob/cddb46fe/ambari-web/app/views/main/host/hosts_table_menu_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/host/hosts_table_menu_view.js b/ambari-web/app/views/main/host/hosts_table_menu_view.js index 1ace762..733edc7 100644 --- a/ambari-web/app/views/main/host/hosts_table_menu_view.js +++ b/ambari-web/app/views/main/host/hosts_table_menu_view.js @@ -263,6 +263,13 @@ App.HostTableMenuView = Em.View.extend({ action: 'RESTART', message: Em.I18n.t('hosts.table.menu.l2.restartAllComponents') }) + }), + O.create({ + label: Em.I18n.t('hosts.table.menu.l2.reinstallFailedComponents'), + operationData: O.create({ + action: 'REINSTALL', + message: Em.I18n.t('hosts.table.menu.l2.reinstallFailedComponents') + }) }) ]); } http://git-wip-us.apache.org/repos/asf/ambari/blob/cddb46fe/ambari-web/test/controllers/main/host/bulk_operations_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/host/bulk_operations_controller_test.js b/ambari-web/test/controllers/main/host/bulk_operations_controller_test.js index 9ed0cec..05e0904 100644 --- a/ambari-web/test/controllers/main/host/bulk_operations_controller_test.js +++ b/ambari-web/test/controllers/main/host/bulk_operations_controller_test.js @@ -28,6 +28,7 @@ describe('BulkOperationsController', function () { hostController = App.BulkOperationsController.create({}); sinon.stub(hostController, 'bulkOperationForHostsRestart', Em.K); sinon.stub(hostController, 'bulkOperationForHosts', Em.K); + sinon.stub(hostController, 'bulkOperationForHostsReinstall', Em.K); sinon.stub(hostController, 'bulkOperationForHostComponentsRestart', Em.K); sinon.stub(hostController, 'bulkOperationForHostComponentsDecommission', Em.K); sinon.stub(hostController, 'bulkOperationForHostComponents', Em.K); @@ -37,6 +38,7 @@ describe('BulkOperationsController', function () { afterEach(function() { hostController.bulkOperationForHosts.restore(); hostController.bulkOperationForHostsRestart.restore(); + hostController.bulkOperationForHostsReinstall.restore(); hostController.bulkOperationForHostComponentsRestart.restore(); hostController.bulkOperationForHostComponentsDecommission.restore(); hostController.bulkOperationForHostComponents.restore(); @@ -68,6 +70,14 @@ describe('BulkOperationsController', function () { expect(hostController.bulkOperationForHosts.calledOnce).to.equal(true); }); + it('REINSTALL for hosts', function() { + var operationData = { + action: 'REINSTALL' + }; + hostController.bulkOperation(operationData, []); + expect(hostController.bulkOperationForHostsReinstall.calledOnce).to.equal(true); + }); + it('PASSIVE_STATE for hosts', function() { var operationData = { action: 'PASSIVE_STATE'