[pve-devel] [PATCH pve-manager] integrate move disk for LXC in GUI

Wolfgang Link w.link at proxmox.com
Wed Nov 18 11:14:49 CET 2015


---
 www/manager/Makefile         |   1 +
 www/manager/lxc/MPMove.js    | 118 +++++++++++++++++++++++++++++++++++++++++++
 www/manager/lxc/Resources.js |  30 ++++++++++-
 3 files changed, 148 insertions(+), 1 deletion(-)
 create mode 100644 www/manager/lxc/MPMove.js

diff --git a/www/manager/Makefile b/www/manager/Makefile
index 55a7ef5..6f05bfe 100644
--- a/www/manager/Makefile
+++ b/www/manager/Makefile
@@ -151,6 +151,7 @@ JSSRC= 				                 	\
 	lxc/Snapshot.js					\
 	lxc/ResourceEdit.js				\
 	lxc/MPResize.js					\
+	lxc/MPMove.js					\
 	pool/StatusView.js				\
 	pool/Summary.js					\
 	pool/Config.js					\
diff --git a/www/manager/lxc/MPMove.js b/www/manager/lxc/MPMove.js
new file mode 100644
index 0000000..e48983b
--- /dev/null
+++ b/www/manager/lxc/MPMove.js
@@ -0,0 +1,118 @@
+Ext.define('PVE.window.MPMove', {
+    extend: 'Ext.window.Window',
+
+    resizable: false,
+
+
+    move_disk: function(disk, storage, delete_disk) {
+	var me = this;
+
+        var params =  { disk: disk, storage: storage };
+
+	if (delete_disk) {
+	    params['delete'] = 1;
+	}
+
+	PVE.Utils.API2Request({
+	    params: params,
+	    url: '/nodes/' + me.nodename + '/lxc/' + me.vmid + '/move_disk',
+	    waitMsgTarget: me,
+	    method: 'POST',
+	    failure: function(response, opts) {
+		Ext.Msg.alert('Error', response.htmlStatus);
+	    },
+	    success: function(response, options) {
+		var upid = response.result.data;
+		var win = Ext.create('PVE.window.TaskViewer', { upid: upid });
+		win.show();
+		me.close();
+	    }
+	});
+
+    },
+
+    initComponent : function() {
+	var me = this;
+
+	var diskarray = [];
+
+	if (!me.nodename) {
+	    throw "no node name specified";
+	}
+
+	if (!me.vmid) {
+	    throw "no VM ID specified";
+	}
+
+        var items = [
+            {
+                xtype: 'displayfield',
+                name: 'disk',
+                value: me.disk,
+                fieldLabel: gettext('Disk'),
+                vtype: 'StorageId',
+                allowBlank: false
+            }
+        ];
+
+        me.hdstoragesel = Ext.create('PVE.form.StorageSelector', {
+                name: 'hdstorage',
+                nodename: me.nodename,
+                fieldLabel: gettext('Target Storage'),
+                storageContent: 'images',
+                autoSelect: me.insideWizard,
+                allowBlank: true,
+                disabled: false,
+                hidden: false,
+	});
+
+	items.push(me.hdstoragesel);
+
+	items.push({
+	    xtype: 'pvecheckbox',
+	    fieldLabel: gettext('Delete source'),
+	    name: 'deleteDisk',
+	    uncheckedValue: 0,
+	    checked: false
+	});
+
+	me.formPanel = Ext.create('Ext.form.Panel', {
+	    bodyPadding: 10,
+	    border: false,
+	    fieldDefaults: {
+		labelWidth: 100,
+		anchor: '100%'
+	    },
+	    items: items
+	});
+
+	var form = me.formPanel.getForm();
+
+	var submitBtn;
+
+	me.title =  gettext("Move disk");
+	submitBtn = Ext.create('Ext.Button', {
+	    text: gettext('Move disk'),
+	    handler: function() {
+		if (form.isValid()) {
+		    var values = form.getValues();
+		    me.move_disk(me.disk, values.hdstorage, values.deleteDisk);
+		}
+	    }
+	});
+
+	Ext.apply(me, {
+	    modal: true,
+	    width: 350,
+	    border: false,
+	    layout: 'fit',
+	    buttons: [ submitBtn ],
+	    items: [ me.formPanel ],
+	});
+
+
+	me.callParent();
+
+
+    }
+});
diff --git a/www/manager/lxc/Resources.js b/www/manager/lxc/Resources.js
index 7149ff0..f052ffb 100644
--- a/www/manager/lxc/Resources.js
+++ b/www/manager/lxc/Resources.js
@@ -138,6 +138,23 @@ Ext.define('PVE.lxc.RessourceView', {
 	    win.on('destroy', reload);
 	};
 
+	var run_move = function() {
+	    var rec = sm.getSelection()[0];
+	    if (!rec) {
+		return;
+	    }
+
+	    var win = Ext.create('PVE.window.MPMove', {
+		disk: rec.data.key,
+		nodename: nodename,
+		vmid: vmid
+	    });
+
+	    win.show();
+
+	    win.on('destroy', reload);
+	};
+
 	var edit_btn = new PVE.button.Button({
 	    text: gettext('Edit'),
 	    selModel: sm,
@@ -159,6 +176,13 @@ Ext.define('PVE.lxc.RessourceView', {
 	    handler: run_resize
 	});
 
+	var move_btn = new PVE.button.Button({
+	    text: gettext('Move disk'),
+	    selModel: sm,
+	    disabled: true,
+	    handler: run_move
+	});
+
 	var set_button_status = function() {
 	    var sm = me.getSelectionModel();
 	    var rec = sm.getSelection()[0];
@@ -166,6 +190,7 @@ Ext.define('PVE.lxc.RessourceView', {
 	    if (!rec) {
 		edit_btn.disable();
 		resize_btn.disable();
+		move_btn.disable();
 		return;
 	    }
 	    var key = rec.data.key;
@@ -176,6 +201,8 @@ Ext.define('PVE.lxc.RessourceView', {
 
 	    edit_btn.setDisabled(rec.data['delete'] || !rowdef.editor);
 
+	    move_btn.setDisabled(!isDisk);
+
 	    resize_btn.setDisabled(!isDisk);
 
 	};
@@ -185,7 +212,8 @@ Ext.define('PVE.lxc.RessourceView', {
 	    selModel: sm,
 	    cwidth1: 170,
 	    tbar: [ edit_btn,
-		    resize_btn],
+		    resize_btn,
+		    move_btn],
 	    rows: rows,
 	    listeners: {
 		show: reload,
-- 
2.1.4





More information about the pve-devel mailing list