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

Moayad Almalat m.almalat at proxmox.com
Tue May 19 11:45:21 CEST 2020


Signed-off-by: Moayad Almalat <m.almalat at proxmox.com>
---
 PVE/API2/Subscription.pm          | 21 +++++++++++++++++++++
 PVE/CLI/pvesubscription.pm        |  1 +
 www/manager6/node/Subscription.js |  9 +++++++++
 3 files changed, 31 insertions(+)

diff --git a/PVE/API2/Subscription.pm b/PVE/API2/Subscription.pm
index 6657c00d..bf03dd28 100644
--- a/PVE/API2/Subscription.pm
+++ b/PVE/API2/Subscription.pm
@@ -245,4 +245,25 @@ __PACKAGE__->register_method ({
 	return undef;
     }});
 
+__PACKAGE__->register_method ({
+    name =>  'delete',
+    path =>  '',
+    method =>  'DELETE',
+        permissions =>  {
+             check =>  ['perm', '/nodes/{node}', [ 'Sys.Modify' ]],
+        },
+        description =>  "Delete subscription key.",
+        proxyto =>  'node',
+        protected =>  1,
+        parameters =>  {
+            additionalProperties =>  0,
+            properties =>  {
+                 node =>  get_standard_option('pve-node'),
+                },
+          },
+          code =>  sub {
+                  unlink("/etc/subscription");
+          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..a82d91b1 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() {
-- 
2.20.1




More information about the pve-devel mailing list