[pve-devel] [RFC v5 pve-manager 22/23] api: apt: add call for repository check

Fabian Ebner f.ebner at proxmox.com
Fri May 28 16:30:01 CEST 2021


Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---

New in v5.

 PVE/API2/APT.pm | 76 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)

diff --git a/PVE/API2/APT.pm b/PVE/API2/APT.pm
index 0e1cc260..10f18944 100644
--- a/PVE/API2/APT.pm
+++ b/PVE/API2/APT.pm
@@ -68,6 +68,7 @@ __PACKAGE__->register_method({
 	my $res = [ 
 	    { id => 'changelog' },
 	    { id => 'repositories' },
+	    { id => 'checkrepositories' },
 	    { id => 'update' },
 	    { id => 'versions' },
 	];
@@ -631,6 +632,81 @@ __PACKAGE__->register_method({
 	};
     }});
 
+__PACKAGE__->register_method({
+    name => 'checkrepositories',
+    path => 'checkrepositories',
+    method => 'GET',
+    proxyto => 'node',
+    description => "Additional sanity checks for the configured APT repositories.",
+    permissions => {
+	check => ['perm', '/nodes/{node}', [ 'Sys.Audit' ]],
+    },
+    parameters => {
+	additionalProperties => 0,
+	properties => {
+	    node => get_standard_option('pve-node'),
+	    digest => {
+		type => "string",
+		description => "Digest to detect modifications.",
+		maxLength => 80,
+		optional => 1,
+	    },
+	},
+    },
+    returns => {
+	type => "object",
+	description => "Additional sanity checks for the configured APT repositories.",
+	properties => {
+	    infos => {
+		type => "array",
+		description => "Additional information/warnings for APT repositories.",
+		items => {
+		    type => "object",
+		    properties => {
+			path => {
+			    type => "string",
+			    description => "Path to the associated file.",
+			},
+			number => {
+			    type => "string",
+			    description => "Number of the associated repository within the file.",
+			},
+			kind => {
+			    type => "string",
+			    description => "Kind of the information (e.g. warning).",
+			},
+			message => {
+			    type => "string",
+			    description => "Information message.",
+			}
+		    },
+		},
+	    },
+	    enterprise => {
+		type => "boolean",
+		description => "Whether the enterprise repository is enabled or not.",
+	    },
+	    nosubscription => {
+		type => "boolean",
+		description => "Whether the no-subscription repository is enabled or not.",
+	    }
+	},
+    },
+    code => sub {
+	my ($param) = @_;
+
+	my $digest = $param->{digest} // '';
+
+	my ($infos, $enterprise, $nosubscription) =
+	    PVE::RS::APT::Repositories::check_repositories($digest);
+
+	return {
+	    infos => $infos,
+	    enterprise => $enterprise,
+	    nosubscription => $nosubscription,
+	};
+    }});
+
 __PACKAGE__->register_method({
     name => 'versions', 
     path => 'versions', 
-- 
2.20.1






More information about the pve-devel mailing list