瀏覽代碼

AMBARI-14731. Ability to re-install all host components that failed to install (INSTALL_FAILED state) from UI (Joe Wang via rzang)

Richard Zang 9 年之前
父節點
當前提交
cddb46fe0c

+ 24 - 0
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);
@@ -224,6 +227,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)

+ 2 - 0
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':'&nbsp;!&nbsp;',
   'hosts.decommission.popup.body':'Are you sure?',
   'hosts.decommission.popup.header':'Confirmation',

+ 7 - 0
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')
+            })
           })
         ]);
       }

+ 10 - 0
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'