[pve-devel] [PATCH v2 pve-manager] api, ui: allow to remove subscriptio

Thomas Lamprecht t.lamprecht at proxmox.com
Wed May 27 14:18:11 CEST 2020


On 5/26/20 9:39 PM, Moayad Almalat wrote:
> Signed-off-by: Moayad Almalat <m.almalat at proxmox.com>
> ---
>  PVE/API2/Subscription.pm          | 24 ++++++++++++++++++++++++
>  PVE/CLI/pvesubscription.pm        |  1 +
>  www/manager6/node/Subscription.js |  9 +++++++++
>  3 files changed, 34 insertions(+)
> 

applied, some comments inline. Please fix now also the patch for the PMG, thanks!

> diff --git a/PVE/API2/Subscription.pm b/PVE/API2/Subscription.pm
> index 6657c00d..e1a9c31c 100644
> --- a/PVE/API2/Subscription.pm
> +++ b/PVE/API2/Subscription.pm
> @@ -245,4 +245,28 @@ __PACKAGE__->register_method ({
>  	return undef;
>      }});
>  
> +__PACKAGE__->register_method ({
> +    name => 'delete',
> +    path => '',
> +    method => 'DELETE',
> +    permissions => {
> +	check => ['perm', '/nodes/{node}', [ 'Sys.Modify' ]],
> +    },
> +    description => "Set subscription key.",

Not "Set" but "Delete" ;-) I made a followup fix for this.

> +    proxyto => 'node',
> +    protected => 1,
> +    parameters => {
> +    	additionalProperties => 0,

wrong indentation, you got that one and the wrong "description" one probably from
basing this all on the 'set' API endpoint definition.

> +	properties => {
> +	    node => get_standard_option('pve-node'),
> +	},
> +    },
> +    returns => { type => 'null'},
> +    code => sub {
> +	my $subscription_file = '/etc/subscription';
> +	return if ! -e $subscription_file; 

trailing white space at the end of above line

> +	unlink($subscription_file) or die "cannot delete subscription key: $!";
> +	return undef;
> +    }});
> +
>  1;
> diff --git a/PVE/CLI/pvesubscription.pm b/PVE/CLI/pvesubscription.pm
> index cd81c415..751dde58 100755
> --- a/PVE/CLI/pvesubscription.pm
> +++ b/PVE/CLI/pvesubscription.pm
> @@ -28,6 +28,7 @@ our $cmddef = {
>  		 }
>  	     }],
>      set => [ 'PVE::API2::Subscription', 'set', ['key'], { node => $nodename } ],
> +    delete => [ 'PVE::API2::Subscription', 'delete', undef, { node => $nodename } ],
>  };
>  
>  1;
> diff --git a/www/manager6/node/Subscription.js b/www/manager6/node/Subscription.js
> index e4a35874..15319429 100644
> --- a/www/manager6/node/Subscription.js
> +++ b/www/manager6/node/Subscription.js
> @@ -163,6 +163,15 @@ Ext.define('PVE.node.Subscription', {
>  			win.on('destroy', reload);
>  		    }
>  		},
> +		{
> +		    text: gettext('Remove Subscription'),
> +		    xtype: 'proxmoxStdRemoveButton',
> +		    confirmMsg: gettext('Are you sure to remove the subscription key?'),
> +		    baseurl: baseurl,
> +		    dangerous: true,
> +		    selModel: false,
> +		    callback: reload,
> +		},
>  		{
>  		    text: gettext('Check'),
>  		    handler: function() {
> 





More information about the pve-devel mailing list