Implement VMs provisioning starting for kvm-virt nodes in UI

Related to blueprint reduced-footprint

Change-Id: I5c79512e4fe945391969515fccf1d1ce3e6b795f
This commit is contained in:
Vitaly Kramskikh 2015-07-13 21:08:05 +03:00
parent e4e19e41a5
commit 127c5e7d4e
4 changed files with 65 additions and 15 deletions

View File

@ -452,7 +452,7 @@ define([
},
groups: {
network: ['verify_networks', 'check_networks'],
deployment: ['update', 'stop_deployment', 'deploy', 'reset_environment']
deployment: ['update', 'stop_deployment', 'deploy', 'reset_environment', 'spawn_vms']
},
extendGroups: function(filters) {
return _.union(utils.composeList(filters.name), _.flatten(_.map(utils.composeList(filters.group), _.bind(function(group) {return this.groups[group];}, this))));

View File

@ -12,6 +12,7 @@
"rename_button": "Rename",
"delete_button": "Delete",
"remove_button": "Remove",
"start_button": "Start",
"stop_button": "Stop",
"reset_button": "Reset",
"save_settings_button": "Save Settings",
@ -622,6 +623,7 @@
},
"discard_changes": "Discard Changes",
"deploy_changes": "Deploy Changes",
"provision_vms": "Provision VMs",
"reset_environment": "Resetting",
"stop_deployment": "Stopping",
"stop_deployment_button": "Stop deployment",
@ -775,6 +777,12 @@
"invalid_settings": "Environment settings are invalid.",
"settings_link": "Settings tab"
},
"provision_vms": {
"title": "Provision VMs",
"text": "Are you sure you want to start VMs provisioning on __count__ node?",
"text_plural": "Are you sure you want to start VMs provisioning on __count__ nodes?",
"provision_vms_error": "Unable to start provisioning"
},
"show_node": {
"manufacturer_label": "Manufacturer",
"mac_address_label": "MAC Address",

View File

@ -377,15 +377,15 @@ function($, _, i18n, Backbone, React, utils, models, dispatcher, componentMixins
showDialog: function(Dialog) {
Dialog.show({cluster: this.props.cluster});
},
onDeployRequest: function() {
onActionRequest: function(Dialog) {
if (this.props.hasChanges()) {
dialogs.DiscardSettingsChangesDialog.show({cb: _.bind(function() {
this.props.revertChanges();
if (this.props.activeTab == 'nodes') app.navigate('cluster/' + this.props.cluster.id + '/nodes', {trigger: true, replace: true});
this.showDialog(dialogs.DeployChangesDialog);
this.showDialog(Dialog);
}, this)});
} else {
this.showDialog(dialogs.DeployChangesDialog);
this.showDialog(Dialog);
}
},
render: function() {
@ -395,8 +395,11 @@ function($, _, i18n, Backbone, React, utils, models, dispatcher, componentMixins
taskName = task ? task.get('name') : '',
taskProgress = task && task.get('progress') || 0,
infiniteTask = _.contains(['stop_deployment', 'reset_environment'], taskName),
stoppableTask = !_.contains(['stop_deployment', 'reset_environment', 'update'], taskName),
isDeploymentImpossible = cluster.get('release').get('state') == 'unavailable' || (!cluster.get('nodes').hasChanges() && !cluster.needsRedeployment());
stoppableTask = !_.contains(['stop_deployment', 'reset_environment', 'update', 'spawn_vms'], taskName),
isDeploymentImpossible = cluster.get('release').get('state') == 'unavailable' || (!cluster.get('nodes').hasChanges() && !cluster.needsRedeployment()),
isVMsProvisioningAvailable = cluster.get('nodes').any(function(node) {
return node.get('pending_addition') && node.hasRole('kvm-virt');
});
return (
<div className='col-xs-6 col-md-3'>
<div className='deploy-box pull-right'>
@ -436,15 +439,25 @@ function($, _, i18n, Backbone, React, utils, models, dispatcher, componentMixins
<div className='discard-changes-icon'></div>
</button>
),
<button
key='deploy-changes'
className='btn btn-primary deploy-btn'
disabled={isDeploymentImpossible}
onClick={this.onDeployRequest}
>
<div className='deploy-icon'></div>
{i18n('cluster_page.deploy_changes')}
</button>
isVMsProvisioningAvailable ?
<button
key='provision-vms'
className='btn btn-primary deploy-btn'
onClick={_.partial(this.onActionRequest, dialogs.ProvisionVMsDialog)}
>
<div className='deploy-icon'></div>
{i18n('cluster_page.provision_vms')}
</button>
:
<button
key='deploy-changes'
className='btn btn-primary deploy-btn'
disabled={isDeploymentImpossible}
onClick={_.partial(this.onActionRequest, dialogs.DeployChangesDialog)}
>
<div className='deploy-icon'></div>
{i18n('cluster_page.deploy_changes')}
</button>
]}
</div>
</div>

View File

@ -420,6 +420,35 @@ function($, _, i18n, Backbone, React, utils, models, dispatcher, controls, compo
}
});
dialogs.ProvisionVMsDialog = React.createClass({
mixins: [dialogMixin],
getDefaultProps: function() {return {title: i18n('dialog.provision_vms.title')};},
startProvisioning: function() {
this.setState({actionInProgress: true});
var task = new models.Task();
task.save({}, {url: _.result(this.props.cluster, 'url') + '/spawn_vms', type: 'PUT'})
.done(function() {
this.close();
dispatcher.trigger('deploymentTaskStarted');
}.bind(this))
.fail(_.bind(function(response) {
this.showError(response, i18n('dialog.provision_vms.provision_vms_error'));
}, this));
},
renderBody: function() {
var vmsCount = this.props.cluster.get('nodes').where(function(node) {
return node.get('pending_addition') && node.hasRole('kvm-virt');
}).length;
return i18n('dialog.provision_vms.text', {count: vmsCount});
},
renderFooter: function() {
return ([
<button key='cancel' className='btn btn-default' onClick={this.close} disabled={this.state.actionInProgress}>{i18n('common.cancel_button')}</button>,
<button key='provision' className='btn btn-success' disabled={this.state.actionInProgress} onClick={this.startProvisioning}>{i18n('common.start_button')}</button>
]);
}
});
dialogs.StopDeploymentDialog = React.createClass({
mixins: [dialogMixin],
getDefaultProps: function() {return {title: i18n('dialog.stop_deployment.title')};},