You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by rz...@apache.org on 2016/03/07 20:47:18 UTC
ambari git commit: AMBARI-15308 UI: ability to perform bulk add host
components (Joe Wang via rzang)
Repository: ambari
Updated Branches:
refs/heads/trunk 29d636ccb -> 7cc897bd6
AMBARI-15308 UI: ability to perform bulk add host components (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/7cc897bd
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7cc897bd
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7cc897bd
Branch: refs/heads/trunk
Commit: 7cc897bd6c700fb74028ec90426392411905e7a2
Parents: 29d636c
Author: Richard Zang <rz...@apache.org>
Authored: Mon Mar 7 11:46:45 2016 -0800
Committer: Richard Zang <rz...@apache.org>
Committed: Mon Mar 7 11:46:45 2016 -0800
----------------------------------------------------------------------
.../main/host/bulk_operations_controller.js | 125 +++++++++++++++++++
ambari-web/app/messages.js | 3 +
.../templates/main/host/bulk_operation_menu.hbs | 6 +-
ambari-web/app/utils/ajax/ajax.js | 11 ++
.../views/main/host/hosts_table_menu_view.js | 25 ++++
.../host/bulk_operations_controller_test.js | 11 ++
6 files changed, 179 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/7cc897bd/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 b0ea13b..659d335 100644
--- a/ambari-web/app/controllers/main/host/bulk_operations_controller.js
+++ b/ambari-web/app/controllers/main/host/bulk_operations_controller.js
@@ -38,6 +38,9 @@ App.BulkOperationsController = Em.Controller.extend({
if (operationData.action === 'RESTART') {
this.bulkOperationForHostComponentsRestart(operationData, hosts);
}
+ else if (operationData.action === 'ADD') {
+ this.bulkOperationForHostComponentsAddConfirm(operationData, hosts);
+ }
else {
if (operationData.action.indexOf('DECOMMISSION') == -1) {
this.bulkOperationForHostComponents(operationData, hosts);
@@ -305,6 +308,128 @@ App.BulkOperationsController = Em.Controller.extend({
updateHostPassiveState: function (data, opt, params) {
return batchUtils.infoPassiveState(params.passive_state);
},
+
+ /**
+ * Confirm bulk add for selected hostComponent
+ * @param {Object} operationData - data about bulk operation (action, hostComponent etc)
+ * @param {Array} hosts - list of affected hosts
+ */
+ bulkOperationForHostComponentsAddConfirm: function (operationData, hosts) {
+ var self = this;
+
+ hosts = hosts.mapProperty('hostName');
+
+ var allHostsWithComponent = App.HostComponent.find().filterProperty('componentName', operationData.componentName).mapProperty('hostName');
+ var hostsWithComponent = hosts.filter(function (host) {
+ return allHostsWithComponent.contains(host);
+ });
+ var hostsWithOutComponent = hosts.filter(function(host) {
+ return !hostsWithComponent.contains(host);
+ });
+
+ var minShown = 3;
+
+ if (hostsWithOutComponent.length) {
+ return App.ModalPopup.show({
+ header: Em.I18n.t('hosts.bulkOperation.confirmation.header'),
+ hostNames: hostsWithOutComponent.join("\n"),
+ visibleHosts: self._showHostNames(hostsWithOutComponent, "\n", minShown),
+ hostNamesSkippedVisible: self._showHostNames(hostsWithComponent, "\n", minShown),
+ expanded: false,
+
+ hostNamesSkipped: function() {
+ return hostsWithComponent.length ? hostsWithComponent.join("\n") : false;
+ }.property(),
+
+ didInsertElement: function() {
+ this.set('expanded', hostsWithOutComponent.length <= minShown);
+ },
+
+ onPrimary: function() {
+ self.bulkOperationForHostComponentsAdd(operationData, hostsWithOutComponent);
+ this._super();
+ },
+ bodyClass: Em.View.extend({
+ templateName: require('templates/main/host/bulk_operation_confirm_popup'),
+ message: Em.I18n.t('hosts.bulkOperation.confirmation.add.component').format(operationData.message, operationData.componentNameFormatted, hostsWithOutComponent.length),
+ warningInfo: Em.I18n.t('hosts.bulkOperation.confirmation.add.component.skip').format(operationData.componentNameFormatted),
+ textareaVisible: false,
+ textTrigger: function() {
+ this.toggleProperty('textareaVisible');
+ },
+
+ showAll: function() {
+ this.set('parentView.visibleHosts', this.get('parentView.hostNames'));
+ this.set('parentView.hostNamesSkippedVisible', this.get('parentView.hostNamesSkipped'));
+ this.set('parentView.expanded', true);
+ },
+ putHostNamesToTextarea: function() {
+ var hostNames = this.get('parentView.hostNames');
+ if (this.get('textareaVisible')) {
+ var wrapper = $(".task-detail-log-maintext");
+ $('.task-detail-log-clipboard').html(hostNames).width(wrapper.width()).height(250);
+ Em.run.next(function() {
+ $('.task-detail-log-clipboard').select();
+ });
+ }
+ }.observes('textareaVisible')
+ })
+ });
+ }
+ return App.ModalPopup.show({
+ header: Em.I18n.t('rolling.nothingToDo.header'),
+ body: Em.I18n.t('hosts.bulkOperation.confirmation.add.component.nothingToDo.body').format(operationData.componentNameFormatted),
+ secondary: false
+ });
+ },
+ /**
+ * Bulk add for selected hostComponent
+ * @param {Object} operationData - data about bulk operation (action, hostComponent etc)
+ * @param {Array} hostNames - list of affected hosts' names
+ */
+ bulkOperationForHostComponentsAdd: function (operationData, hostNames) {
+ var self= this;
+ App.get('router.mainAdminKerberosController').getKDCSessionState(function () {
+ App.ajax.send({
+ name: 'host.host_component.add_new_components',
+ sender: self,
+ data: {
+ data: JSON.stringify({
+ RequestInfo: {
+ query: 'Hosts/host_name.in(' + hostNames.join(',') + ')'
+ },
+ Body: {
+ host_components: [
+ {
+ HostRoles: {
+ component_name: operationData.componentName
+ }
+ }
+ ]
+ }
+ }),
+ context: operationData.message + ' ' + operationData.componentNameFormatted,
+ },
+ success: 'bulkOperationForHostComponentsAddSuccessCallback'
+ });
+ });
+ },
+
+ bulkOperationForHostComponentsAddSuccessCallback: function (data, opt, params) {
+ App.ajax.send({
+ name: 'common.host_components.update',
+ sender: this,
+ data: {
+ query: 'HostRoles/state=INIT',
+ HostRoles: {
+ state: 'INSTALLED'
+ },
+ context: params.context
+ },
+ success: 'bulkOperationForHostComponentsSuccessCallback'
+ });
+ },
+
/**
* Bulk operation for selected hostComponents
* @param {Object} operationData - data about bulk operation (action, hostComponents etc)
http://git-wip-us.apache.org/repos/asf/ambari/blob/7cc897bd/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index a3a4d1d..8e69dd0 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -2272,6 +2272,9 @@ Em.I18n.translations = {
'hosts.bulkOperation.passiveState.nothingToDo.body':'All hosts that you selected are already in Maintenance Mode.',
'hosts.bulkOperation.warningInfo.body':'Components on these hosts are stopped so decommission will be skipped.',
'hosts.bulkOperation.host_components.passiveState.nothingToDo.body':'All host components that you selected are already in Maintenance Mode',
+ 'hosts.bulkOperation.confirmation.add.component':'You are going to <strong>{0} {1}</strong> on the following {2} hosts.',
+ 'hosts.bulkOperation.confirmation.add.component.skip':'The following hosts are skipped as they already have {0} installed.',
+ 'hosts.bulkOperation.confirmation.add.component.nothingToDo.body': 'All the selected hosts have {0} installed already.',
'hosts.selectHostsDialog.title': 'Select Configuration Group Hosts',
'hosts.selectHostsDialog.message': 'Select hosts that should belong to this {0} Configuration Group. All hosts belonging to this group will have the same set of configurations.',
http://git-wip-us.apache.org/repos/asf/ambari/blob/7cc897bd/ambari-web/app/templates/main/host/bulk_operation_menu.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/host/bulk_operation_menu.hbs b/ambari-web/app/templates/main/host/bulk_operation_menu.hbs
index fab2576..543deb0 100644
--- a/ambari-web/app/templates/main/host/bulk_operation_menu.hbs
+++ b/ambari-web/app/templates/main/host/bulk_operation_menu.hbs
@@ -121,9 +121,11 @@
<a href="javascript:void(null);">{{operation.label}}</a>
{{/view}}
{{else}}
- {{#view view.commonOperationView contentBinding="operation.operationData" selection="a"}}
+ {{#unless operation.delete}}
+ {{#view view.commonOperationView contentBinding="operation.operationData" selection="a"}}
<a href="javascript:void(null);">{{operation.label}}</a>
- {{/view}}
+ {{/view}}
+ {{/unless}}
{{/if}}
{{/each}}
</ul>
http://git-wip-us.apache.org/repos/asf/ambari/blob/7cc897bd/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 a5d0899..c054b38 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -865,6 +865,17 @@ var urls = {
}
},
+ 'host.host_component.add_new_components': {
+ 'real': '/clusters/{clusterName}/hosts',
+ 'mock': '/data/wizard/deploy/poll_1.json',
+ 'format': function (data) {
+ return {
+ type: 'POST',
+ data: data.data
+ }
+ }
+ },
+
'host.host_component.slave_desired_admin_state': {
'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}/?fields=HostRoles/desired_admin_state',
'mock': '/data/hosts/HDP2/decommission_state.json'
http://git-wip-us.apache.org/repos/asf/ambari/blob/7cc897bd/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 733edc7..0d119f7 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
@@ -134,6 +134,31 @@ App.HostTableMenuView = Em.View.extend({
})
])
}
+ if (App.isAuthorized("HOST.ADD_DELETE_COMPONENTS")) {
+ menuItems.pushObjects([
+ O.create({
+ label: Em.I18n.t('common.add'),
+ operationData: O.create({
+ action: 'ADD',
+ message: Em.I18n.t('common.add'),
+ componentName: content.componentName,
+ serviceName: content.serviceName,
+ componentNameFormatted: content.componentNameFormatted
+ })
+ }),
+ O.create({
+ label: Em.I18n.t('common.delete'),
+ delete: true,
+ operationData: O.create({
+ action: 'DELETE',
+ message: Em.I18n.t('common.delete'),
+ componentName: content.componentName,
+ serviceName: content.serviceName,
+ componentNameFormatted: content.componentNameFormatted
+ })
+ })
+ ])
+ }
if (App.isAuthorized("SERVICE.DECOMMISSION_RECOMMISSION") && App.get('components.decommissionAllowed').contains(content.componentName)) {
menuItems.pushObjects([
O.create({
http://git-wip-us.apache.org/repos/asf/ambari/blob/7cc897bd/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 05e0904..178a6fd 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
@@ -32,6 +32,7 @@ describe('BulkOperationsController', function () {
sinon.stub(hostController, 'bulkOperationForHostComponentsRestart', Em.K);
sinon.stub(hostController, 'bulkOperationForHostComponentsDecommission', Em.K);
sinon.stub(hostController, 'bulkOperationForHostComponents', Em.K);
+ sinon.stub(hostController, 'bulkOperationForHostComponentsAddConfirm', Em.K);
sinon.stub(hostController, 'bulkOperationForHostsPassiveState', Em.K);
});
@@ -42,6 +43,7 @@ describe('BulkOperationsController', function () {
hostController.bulkOperationForHostComponentsRestart.restore();
hostController.bulkOperationForHostComponentsDecommission.restore();
hostController.bulkOperationForHostComponents.restore();
+ hostController.bulkOperationForHostComponentsAddConfirm.restore();
hostController.bulkOperationForHostsPassiveState.restore();
});
@@ -113,6 +115,15 @@ describe('BulkOperationsController', function () {
expect(hostController.bulkOperationForHostComponents.calledOnce).to.equal(true);
});
+ it('ADD for hostComponents', function() {
+ var operationData = {
+ action: 'ADD',
+ componentNameFormatted: 'DataNodes'
+ };
+ hostController.bulkOperation(operationData, []);
+ expect(hostController.bulkOperationForHostComponentsAddConfirm.calledOnce).to.equal(true);
+ });
+
it('DECOMMISSION for hostComponents', function() {
var operationData = {
action: 'DECOMMISSION',