[pve-devel] [PATCH] add live storage migration to migrate window
Alexandre Derumier
aderumier at odiso.com
Tue Jul 4 16:17:51 CEST 2017
If online is checked,
we display 2 new field:
-use-local-disk checkbox (unchecked by default)
-target storage option (disabled by default, enabled is localdisk is checked)
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
www/manager6/window/Migrate.js | 90 ++++++++++++++++++++++++++++++++++++------
1 file changed, 77 insertions(+), 13 deletions(-)
diff --git a/www/manager6/window/Migrate.js b/www/manager6/window/Migrate.js
index dfc8da33..ddd6f018 100644
--- a/www/manager6/window/Migrate.js
+++ b/www/manager6/window/Migrate.js
@@ -3,7 +3,7 @@ Ext.define('PVE.window.Migrate', {
resizable: false,
- migrate: function(target, online) {
+ migrate: function(target, online, localdisks, targetstorage) {
var me = this;
var params = {
target: target
@@ -11,6 +11,12 @@ Ext.define('PVE.window.Migrate', {
if (me.vmtype === 'qemu') {
params.online = online;
+ if(localdisks) {
+ params['with-local-disks'] = localdisks;
+ if(targetstorage) {
+ params.targetstorage = targetstorage;
+ }
+ }
} else {
params.restart = online;
}
@@ -57,21 +63,51 @@ Ext.define('PVE.window.Migrate', {
running = true;
}
- me.formPanel = Ext.create('Ext.form.Panel', {
- bodyPadding: 10,
- border: false,
- fieldDefaults: {
- labelWidth: 100,
- anchor: '100%'
- },
- items: [
+ me.localdisks = Ext.createWidget('pvecheckbox', {
+ name: 'localdisks',
+ defaultValue: 0,
+ fieldLabel: gettext('Migrate local disks'),
+ hidden: running ? false : true,
+ listeners: {
+ change: function(field, checked) {
+
+ if(checked) {
+ me.storagesel.setDisabled(false);
+ } else {
+ me.storagesel.setDisabled(true);
+ }
+ }
+ }
+ });
+
+ me.storagesel = Ext.create('PVE.form.StorageSelector', {
+ nodename: me.nodename,
+ name: 'targetstorage',
+ value: '',
+ fieldLabel: gettext('Storage'),
+ storageContent: 'images',
+ autoSelect: false, // will use for each disk the same storage as source
+ allowBlank: true,
+ emptyText: gettext('Same as source'),
+ disabled: true,
+ hidden: running ? false : true
+ });
+
+ var items = [
{
xtype: 'pveNodeSelector',
name: 'target',
fieldLabel: gettext('Target node'),
allowBlank: false,
disallowedNodes: [me.nodename],
- onlineValidator: true
+ onlineValidator: true,
+ listeners: {
+ change: function(f, value) {
+ if (me.vmtype === 'qemu') {
+ me.storagesel.setNodename(value);
+ }
+ }
+ }
},
{
xtype: 'pvecheckbox',
@@ -79,9 +115,37 @@ Ext.define('PVE.window.Migrate', {
uncheckedValue: 0,
defaultValue: 0,
checked: running,
- fieldLabel: me.vmtype === 'qemu' ? gettext('Online') : gettext('Restart Mode')
+ fieldLabel: me.vmtype === 'qemu' ? gettext('Online') : gettext('Restart Mode'),
+ listeners: {
+ change: function(field, checked) {
+ if (me.vmtype === 'qemu') {
+
+ if(checked) {
+ me.storagesel.setHidden(false);
+ me.localdisks.setHidden(false);
+ } else {
+ me.storagesel.setHidden(true);
+ me.localdisks.setHidden(true);
+ }
+ }
+ }
+ }
}
- ]
+ ];
+
+ if (me.vmtype === 'qemu') {
+ items.push(me.localdisks);
+ items.push(me.storagesel);
+ }
+
+ me.formPanel = Ext.create('Ext.form.Panel', {
+ bodyPadding: 10,
+ border: false,
+ fieldDefaults: {
+ labelWidth: 100,
+ anchor: '100%'
+ },
+ items: items
});
var form = me.formPanel.getForm();
@@ -90,7 +154,7 @@ Ext.define('PVE.window.Migrate', {
text: gettext('Migrate'),
handler: function() {
var values = form.getValues();
- me.migrate(values.target, values.online);
+ me.migrate(values.target, values.online, values.localdisks, values.targetstorage);
}
});
--
2.11.0
More information about the pve-devel
mailing list