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 9E74568CEC for ; Wed, 11 Nov 2020 12:59:28 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 935292BC37 for ; Wed, 11 Nov 2020 12:59:28 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id D917D2BC2A for ; Wed, 11 Nov 2020 12:59:27 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id A711C42080 for ; Wed, 11 Nov 2020 12:59:27 +0100 (CET) To: pbs-devel@lists.proxmox.com References: <20201110132218.17717-1-m.limbeck@proxmox.com> From: Mira Limbeck Message-ID: Date: Wed, 11 Nov 2020 12:59:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <20201110132218.17717-1-m.limbeck@proxmox.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-SPAM-LEVEL: Spam detection results: 0 AWL 0.468 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -0.001 Looks like a legit reply (A) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [apt.rs, mod.rs] Subject: Re: [pbs-devel] [PATCH v2 proxmox-backup 1/2] add extra_info field to APTUpdateInfo X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Nov 2020 11:59:28 -0000 the 'running kernel: ' string should be used in both the found and notfound cases. will fix this in the next version. On 11/10/20 2:22 PM, Mira Limbeck wrote: > Add an optional string field to APTUpdateInfo which can be used for > extra information. > > This is used for passing running kernel and running version information > in the versions API call together with proxmox-backup and > proxmox-backup-server. > > Signed-off-by: Mira Limbeck > --- > v2: > - renamed additional_info to extra_info to make it compatible with > GUI code > - changed the running_kernel and running_version info to contain the > text 'running kernel: ' and 'running version: ' which removes the > need for special casing in proxmox-backup-manager versions and > makes it again compatible with the GUI > > src/api2/node/apt.rs | 35 ++++++++++++++++++++++++++++------- > src/api2/types/mod.rs | 2 ++ > src/tools/apt.rs | 1 + > 3 files changed, 31 insertions(+), 7 deletions(-) > > diff --git a/src/api2/node/apt.rs b/src/api2/node/apt.rs > index aa41d6a5..98d02318 100644 > --- a/src/api2/node/apt.rs > +++ b/src/api2/node/apt.rs > @@ -276,7 +276,7 @@ pub fn get_versions() -> Result { > "zfsutils-linux", > ]; > > - fn unknown_package(package: String) -> APTUpdateInfo { > + fn unknown_package(package: String, extra_info: Option) -> APTUpdateInfo { > APTUpdateInfo { > package, > title: "unknown".into(), > @@ -288,6 +288,7 @@ pub fn get_versions() -> Result { > priority: "unknown".into(), > section: "unknown".into(), > change_log_url: "unknown".into(), > + extra_info, > } > } > > @@ -301,14 +302,34 @@ pub fn get_versions() -> Result { > }, > None, > ); > - if let Some(proxmox_backup) = pbs_packages.iter().find(|pkg| pkg.package == "proxmox-backup") { > - packages.push(proxmox_backup.to_owned()); > + > + let running_kernel = nix::sys::utsname::uname().release().to_owned(); > + if let Some(proxmox_backup) = pbs_packages > + .iter() > + .find(|pkg| pkg.package == "proxmox-backup") > + { > + let mut proxmox_backup = proxmox_backup.clone(); > + proxmox_backup.extra_info = Some(format!("running kernel: {}", running_kernel)); > + packages.push(proxmox_backup); > } else { > - packages.push(unknown_package("proxmox-backup".into())); > + packages.push(unknown_package( > + "proxmox-backup".into(), > + Some(running_kernel), ^ should also contain 'running kernel: ' instead of just '' > + )); > } > > - if let Some(pkg) = pbs_packages.iter().find(|pkg| pkg.package == "proxmox-backup-server") { > - packages.push(pkg.to_owned()); > + if let Some(pkg) = pbs_packages > + .iter() > + .find(|pkg| pkg.package == "proxmox-backup-server") > + { > + let running_version = format!( > + "running version: {}.{}", > + crate::api2::version::PROXMOX_PKG_VERSION, > + crate::api2::version::PROXMOX_PKG_RELEASE > + ); > + let mut pkg = pkg.clone(); > + pkg.extra_info = Some(running_version); > + packages.push(pkg); > } > > let mut kernel_pkgs: Vec = pbs_packages > @@ -334,7 +355,7 @@ pub fn get_versions() -> Result { > } > match pbs_packages.iter().find(|item| &item.package == pkg) { > Some(apt_pkg) => packages.push(apt_pkg.to_owned()), > - None => packages.push(unknown_package(pkg.to_string())), > + None => packages.push(unknown_package(pkg.to_string(), None)), > } > } > > diff --git a/src/api2/types/mod.rs b/src/api2/types/mod.rs > index ba9d2da9..f240fb64 100644 > --- a/src/api2/types/mod.rs > +++ b/src/api2/types/mod.rs > @@ -1177,6 +1177,8 @@ pub struct APTUpdateInfo { > pub section: String, > /// URL under which the package's changelog can be retrieved > pub change_log_url: String, > + /// Additional package information > + pub extra_info: Option, > } > > #[api()] > diff --git a/src/tools/apt.rs b/src/tools/apt.rs > index 841b7447..af8f51f1 100644 > --- a/src/tools/apt.rs > +++ b/src/tools/apt.rs > @@ -361,6 +361,7 @@ where > }, > priority: priority_res, > section: section_res, > + extra_info: None, > }); > } > }