[pmg-devel] applied: [PATCH pmg-api 1/2] api: alow to remove subscription
Thomas Lamprecht
t.lamprecht at proxmox.com
Wed Jun 3 19:40:55 CEST 2020
On 5/28/20 10:51 AM, Moayad Almalat wrote:
> Signed-off-by: Moayad Almalat <m.almalat at proxmox.com>
> ---
> src/PMG/API2/Subscription.pm | 21 +++++++++++++++++++++
> src/PMG/CLI/pmgsubscription.pm | 1 +
> 2 files changed, 22 insertions(+)
>
applied with small followup (see below)
> diff --git a/src/PMG/API2/Subscription.pm b/src/PMG/API2/Subscription.pm
> index d321a9e..c1323c5 100644
> --- a/src/PMG/API2/Subscription.pm
> +++ b/src/PMG/API2/Subscription.pm
> @@ -188,4 +188,25 @@ __PACKAGE__->register_method ({
> return undef;
> }});
>
> +__PACKAGE__->register_method ({
> + name => 'delete',
> + path => '',
> + method => 'DELETE',
> + description => "Delete 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/pmg/subscription';
> + return if ! -e $subscription_file;
> + unlink($subscription_file) or die "cannot delete subscription key: $1";
You probably meant $! not $1 here, easy to get wrong on the keyboard ;)
Fixed that in a followup.
> + return undef;
> + }});
> +
> 1;
> diff --git a/src/PMG/CLI/pmgsubscription.pm b/src/PMG/CLI/pmgsubscription.pm
> index fdb7afe..a4d5b86 100755
> --- a/src/PMG/CLI/pmgsubscription.pm
> +++ b/src/PMG/CLI/pmgsubscription.pm
> @@ -29,6 +29,7 @@ our $cmddef = {
> }
> }],
> set => [ 'PMG::API2::Subscription', 'set', ['key'], { node => $nodename } ],
> + delete => [ 'PMG::API2::Subscription', 'delete', undef, { node => $nodename } ],
> };
>
> 1;
>
More information about the pmg-devel
mailing list