From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 61B6B7517B for ; Wed, 23 Jun 2021 15:39:19 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5C3E8B754 for ; Wed, 23 Jun 2021 15:39:18 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 2DBF2B667 for ; Wed, 23 Jun 2021 15:39:12 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id F30CD46740 for ; Wed, 23 Jun 2021 15:39:11 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Wed, 23 Jun 2021 15:39:02 +0200 Message-Id: <20210623133904.174072-10-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210623133904.174072-1-f.ebner@proxmox.com> References: <20210623133904.174072-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.673 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH v7 pve-manager 1/3] api: apt: add call for repository information X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Jun 2021 13:39:19 -0000 Signed-off-by: Fabian Ebner --- Dependency bump for pve-rs needed. Changes from v6: * adapt to backend API changes * merged the checkrepositories call into this one * the call now also gives a list of standard repositories and their configuration status. PVE/API2/APT.pm | 200 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) diff --git a/PVE/API2/APT.pm b/PVE/API2/APT.pm index fb4954e7..36d0e67a 100644 --- a/PVE/API2/APT.pm +++ b/PVE/API2/APT.pm @@ -19,6 +19,7 @@ use PVE::INotify; use PVE::Exception; use PVE::RESTHandler; use PVE::RPCEnvironment; +use PVE::RS::APT::Repositories; use PVE::API2Tools; use JSON; @@ -66,6 +67,7 @@ __PACKAGE__->register_method({ my $res = [ { id => 'changelog' }, + { id => 'repositories' }, { id => 'update' }, { id => 'versions' }, ]; @@ -478,6 +480,204 @@ __PACKAGE__->register_method({ return $data; }}); +__PACKAGE__->register_method({ + name => 'repositories', + path => 'repositories', + method => 'GET', + proxyto => 'node', + description => "Get APT repository information.", + permissions => { + check => ['perm', '/nodes/{node}', [ 'Sys.Audit' ]], + }, + parameters => { + additionalProperties => 0, + properties => { + node => get_standard_option('pve-node'), + }, + }, + returns => { + type => "object", + description => "Result from parsing the APT repository files in /etc/apt/.", + properties => { + files => { + type => "array", + description => "List of parsed repository files.", + items => { + type => "object", + properties => { + path => { + type => "string", + description => "Path to the problematic file.", + }, + 'file-type' => { + type => "string", + enum => [ 'list', 'sources' ], + description => "Format of the file.", + }, + repositories => { + type => "array", + description => "The parsed repositories.", + items => { + type => "object", + properties => { + Types => { + type => "array", + description => "List of package types.", + items => { + type => "string", + enum => [ 'deb', 'deb-src' ], + }, + }, + URIs => { + description => "List of repository URIs.", + type => "array", + items => { + type => "string", + }, + }, + Suites => { + type => "array", + description => "List of package distribuitions", + items => { + type => "string", + }, + }, + Components => { + type => "array", + description => "List of repository components", + optional => 1, # not present if suite is absolute + items => { + type => "string", + }, + }, + Options => { + type => "array", + description => "Additional options", + optional => 1, + items => { + type => "object", + properties => { + Key => { + type => "string", + }, + Values => { + type => "array", + items => { + type => "string", + }, + }, + }, + }, + }, + Comment => { + type => "string", + description => "Associated comment", + optional => 1, + }, + FileType => { + type => "string", + enum => [ 'list', 'sources' ], + description => "Format of the defining file.", + }, + Enabled => { + type => "boolean", + description => "Whether the repository is enabled or not", + }, + }, + }, + }, + digest => { + type => "array", + description => "Digest of the file as bytes.", + items => { + type => "integer", + }, + }, + }, + }, + }, + errors => { + type => "array", + description => "List of problematic repository files.", + items => { + type => "object", + properties => { + path => { + type => "string", + description => "Path to the problematic file.", + }, + error => { + type => "string", + description => "The error message", + }, + }, + }, + }, + digest => { + type => "string", + description => "Common digest of all files.", + }, + infos => { + type => "array", + description => "Additional information/warnings for APT repositories.", + items => { + type => "object", + properties => { + path => { + type => "string", + description => "Path to the associated file.", + }, + index => { + type => "string", + description => "Index of the associated repository within the file.", + }, + property => { + type => "string", + description => "Property from which the info originates.", + optional => 1, + }, + kind => { + type => "string", + description => "Kind of the information (e.g. warning).", + }, + message => { + type => "string", + description => "Information message.", + } + }, + }, + }, + 'standard-repos' => { + type => "array", + description => "List of standard repositories and their configuration status", + items => { + type => "object", + properties => { + handle => { + type => "string", + description => "Handle to identify the repository.", + }, + name => { + type => "string", + description => "Full name of the repository.", + }, + status => { + type => "boolean", + optional => 1, + description => "Indicating enabled/disabled status, if the " . + "repository is configured.", + }, + }, + }, + }, + }, + }, + code => sub { + my ($param) = @_; + + return PVE::RS::APT::Repositories::repositories(); + }}); + __PACKAGE__->register_method({ name => 'versions', path => 'versions', -- 2.30.2