[pve-devel] [PATCH manager 2/5] make clone window guest agnostic

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Mar 19 15:25:36 CET 2018


On 3/19/18 1:32 PM, Dominik Csapak wrote:
> so that we can reuse it for containers
> 
> while we do this, we also have to adapt the SnapshotSelector
> 

We use the 'target' property to determine where to clone the VM to,
but the CT API path doesn't implements this, so cloning always fails...

Either we work around this and allow only local node cloning, for now,
or implement it for arbitrary targets, as long as the CT "disks"
are on shared storage...

> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
>  www/manager6/form/SnapshotSelector.js |  6 +++++-
>  www/manager6/qemu/CmdMenu.js          |  2 +-
>  www/manager6/qemu/Config.js           |  2 +-
>  www/manager6/window/Clone.js          | 20 +++++++++++++-------
>  4 files changed, 20 insertions(+), 10 deletions(-)
> 
> diff --git a/www/manager6/form/SnapshotSelector.js b/www/manager6/form/SnapshotSelector.js
> index 1ed420ab..96ee08c7 100644
> --- a/www/manager6/form/SnapshotSelector.js
> +++ b/www/manager6/form/SnapshotSelector.js
> @@ -22,7 +22,7 @@ Ext.define('PVE.form.SnapshotSelector', {
>  
>  	me.store.setProxy({
>  	    type: 'proxmox',
> -	    url: '/api2/json/nodes/' + me.nodename + '/qemu/' + me.vmid +'/snapshot'
> +	    url: '/api2/json/nodes/' + me.nodename + '/' + me.guestType + '/' + me.vmid +'/snapshot'
>  	});
>  
>  	me.store.load();
> @@ -39,6 +39,10 @@ Ext.define('PVE.form.SnapshotSelector', {
>              throw "no VM ID specified";
>          }
>  
> +	if (!me.guestType) {
> +	    throw "no guest type specified";
> +	}
> +
>  	var store = Ext.create('Ext.data.Store', {
>  	    fields: [ 'name'],
>  	    filterOnLoad: true
> diff --git a/www/manager6/qemu/CmdMenu.js b/www/manager6/qemu/CmdMenu.js
> index 49ea62bc..00af7cbc 100644
> --- a/www/manager6/qemu/CmdMenu.js
> +++ b/www/manager6/qemu/CmdMenu.js
> @@ -133,7 +133,7 @@ Ext.define('PVE.qemu.CmdMenu', {
>  		iconCls: 'fa fa-fw fa-clone',
>  		hidden: !caps.vms['VM.Clone'],
>  		handler: function() {
> -		    PVE.window.Clone.wrap(nodename, vmid, me.isTemplate);
> +		    PVE.window.Clone.wrap(nodename, vmid, me.isTemplate, 'qemu');
>  		}
>  	    },
>  	    {
> diff --git a/www/manager6/qemu/Config.js b/www/manager6/qemu/Config.js
> index 5de39fc3..38496f4f 100644
> --- a/www/manager6/qemu/Config.js
> +++ b/www/manager6/qemu/Config.js
> @@ -85,7 +85,7 @@ Ext.define('PVE.qemu.Config', {
>  		    iconCls: 'fa fa-fw fa-clone',
>  		    hidden: caps.vms['VM.Clone'] ? false : true,
>  		    handler: function() {
> -			PVE.window.Clone.wrap(nodename, vmid, template);
> +			PVE.window.Clone.wrap(nodename, vmid, template, 'qemu');
>  		    }
>  		},
>  		{
> diff --git a/www/manager6/window/Clone.js b/www/manager6/window/Clone.js
> index 0df7825e..48b63afe 100644
> --- a/www/manager6/window/Clone.js
> +++ b/www/manager6/window/Clone.js
> @@ -21,9 +21,9 @@ Ext.define('PVE.window.Clone', {
>  
>      statics: {
>  	// display a snapshot selector only if needed
> -	wrap: function(nodename, vmid, isTemplate) {
> +	wrap: function(nodename, vmid, isTemplate, guestType) {
>  	    Proxmox.Utils.API2Request({
> -		url: '/nodes/' + nodename + '/qemu/' + vmid +'/snapshot',
> +		url: '/nodes/' + nodename + '/' + guestType + '/' + vmid +'/snapshot',
>  		failure: function(response, opts) {
>  		    Ext.Msg.alert('Error', response.htmlStatus);
>  		},
> @@ -34,6 +34,7 @@ Ext.define('PVE.window.Clone', {
>  
>  		    Ext.create('PVE.window.Clone', {
>  			nodename: nodename,
> +			guestType: guestType,
>  			vmid: vmid,
>  			isTemplate: isTemplate,
>  			hasSnapshots: hasSnapshots
> @@ -76,7 +77,7 @@ Ext.define('PVE.window.Clone', {
>  
>  	Proxmox.Utils.API2Request({
>  	    params: params,
> -	    url: '/nodes/' + me.nodename + '/qemu/' + me.vmid + '/clone',
> +	    url: '/nodes/' + me.nodename + '/' + me.guestType + '/' + me.vmid + '/clone',
>  	    waitMsgTarget: me,
>  	    method: 'POST',
>  	    failure: function(response, opts) {
> @@ -112,7 +113,7 @@ Ext.define('PVE.window.Clone', {
>  
>  	Proxmox.Utils.API2Request({
>  	    waitMsgTarget: me,
> -	    url: '/nodes/' + me.nodename + '/qemu/' + me.vmid + '/feature',
> +	    url: '/nodes/' + me.nodename + '/' + me.guestType + '/' + me.vmid + '/feature',
>  	    params: params,
>  	    method: 'GET',
>  	    failure: function(response, opts) {
> @@ -143,7 +144,11 @@ Ext.define('PVE.window.Clone', {
>  	    me.snapname = 'current';
>  	}
>  
> -	var titletext = me.isTemplate ? "Template" : "VM";
> +	if (!me.guestType) {
> +	    throw "no Guest Type specified";
> +	}
> +
> +	var titletext = me.isTemplate ? "Template" : (me.guestType === 'qemu'? 'VM' : 'CT');
>  	me.title = "Clone " + titletext + " " + me.vmid;
>  
>  	var col1 = [];
> @@ -172,7 +177,7 @@ Ext.define('PVE.window.Clone', {
>  	col1.push({
>  	    xtype: 'pveGuestIDSelector',
>  	    name: 'newvmid',
> -	    guestType: 'qemu',
> +	    guestType: me.guestType,
>  	    value: '',
>  	    loadNextFreeID: true,
>  	    validateExists: false
> @@ -214,6 +219,7 @@ Ext.define('PVE.window.Clone', {
>  	    reference: 'snapshotsel',
>  	    fieldLabel: gettext('Snapshot'),
>  	    nodename: me.nodename,
> +	    guestType: me.guestType,
>  	    vmid: me.vmid,
>  	    hidden: me.isTemplate || !me.hasSnapshots ? true : false,
>  	    disabled: false,
> @@ -234,7 +240,7 @@ Ext.define('PVE.window.Clone', {
>  	    hideSelection: true,
>  	    storageLabel: gettext('Target Storage'),
>  	    allowBlank: true,
> -	    storageContent: 'images',
> +	    storageContent: me.guestType === 'qemu' ? 'images' : 'rootdir',
>  	    emptyText: gettext('Same as source'),
>  	    disabled: me.isTemplate ? true : false // because default mode is clone for templates
>  	});
> 





More information about the pve-devel mailing list