[pve-devel] [PATCH manager 4/5] adapt and rescope TemplateMenu for containers

Dominik Csapak d.csapak at proxmox.com
Mon Mar 19 13:32:35 CET 2018


make it guest agnostic so that we can use it for lxc also

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/Utils.js             |  2 +-
 www/manager6/menu/TemplateMenu.js | 14 ++++++++++----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index c5fef391..7b495890 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -837,7 +837,7 @@ Ext.define('PVE.Utils', { utilities: {
 		pveSelNode: record
 	    });
 	} else if (record.data.type === 'qemu' && record.data.template) {
-	    menu = Ext.create('PVE.qemu.TemplateMenu', {
+	    menu = Ext.create('PVE.menu.TemplateMenu', {
 		pveSelNode: record
 	    });
 	} else if (record.data.type === 'lxc' && !record.data.template) {
diff --git a/www/manager6/menu/TemplateMenu.js b/www/manager6/menu/TemplateMenu.js
index bf193afd..23240cca 100644
--- a/www/manager6/menu/TemplateMenu.js
+++ b/www/manager6/menu/TemplateMenu.js
@@ -1,4 +1,4 @@
-Ext.define('PVE.qemu.TemplateMenu', {
+Ext.define('PVE.menu.TemplateMenu', {
     extend: 'Ext.menu.Menu',
 
     initComponent: function() {
@@ -14,6 +14,11 @@ Ext.define('PVE.qemu.TemplateMenu', {
 	    throw "no VM ID specified";
 	}
 
+	var guestType = me.pveSelNode.data.type;
+	if (guestType !== 'qemu' && guestType != 'lxc') {
+	    throw "invalid guest type";
+	}
+
 	var vmname = me.pveSelNode.data.name;
 
 	var template = me.pveSelNode.data.template;
@@ -21,7 +26,7 @@ Ext.define('PVE.qemu.TemplateMenu', {
 	var vm_command = function(cmd, params) {
 	    Proxmox.Utils.API2Request({
 		params: params,
-		url: '/nodes/' + nodename + '/qemu/' + vmid + "/status/" + cmd,
+		url: '/nodes/' + nodename + '/' + guestType + '/' + vmid + "/status/" + cmd,
 		method: 'POST',
 		failure: function(response, opts) {
 		    Ext.Msg.alert(gettext('Error'), response.htmlStatus);
@@ -29,7 +34,7 @@ Ext.define('PVE.qemu.TemplateMenu', {
 	    });
 	};
 
-	me.title = "VM " + vmid;
+	me.title = (guestType === 'qemu' ? 'VM ' : 'CT ') + vmid;
 
 	me.items = [
 	    {
@@ -37,7 +42,7 @@ Ext.define('PVE.qemu.TemplateMenu', {
 		iconCls: 'fa fa-fw fa-send-o',
 		handler: function() {
 		    var win = Ext.create('PVE.window.Migrate', {
-			vmtype: 'qemu',
+			vmtype: guestType,
 			nodename: nodename,
 			vmid: vmid
 		    });
@@ -50,6 +55,7 @@ Ext.define('PVE.qemu.TemplateMenu', {
 		handler: function() {
 		    var win = Ext.create('PVE.window.Clone', {
 			nodename: nodename,
+			guestType: guestType,
 			vmid: vmid,
 			isTemplate: template
 		    });
-- 
2.11.0




More information about the pve-devel mailing list