api, ui: allow to remove subscription

Signed-off-by: Moayad Almalat <m.almalat@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Moayad Almalat 2020-05-26 21:39:45 +02:00 committed by Thomas Lamprecht
parent bc92b15f84
commit 85222f8237
3 changed files with 34 additions and 0 deletions

View File

@ -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.",
proxyto => 'node',
protected => 1,
parameters => {
additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
},
},
returns => { type => 'null'},
code => sub {
my $subscription_file = '/etc/subscription';
return if ! -e $subscription_file;
unlink($subscription_file) or die "cannot delete subscription key: $!";
return undef;
}});
1;

View File

@ -28,6 +28,7 @@ our $cmddef = {
}
}],
set => [ 'PVE::API2::Subscription', 'set', ['key'], { node => $nodename } ],
delete => [ 'PVE::API2::Subscription', 'delete', undef, { node => $nodename } ],
};
1;

View File

@ -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() {