public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Mira Limbeck <m.limbeck@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: Re: [pbs-devel] [PATCH v2 proxmox-backup 1/2] add extra_info field to APTUpdateInfo
Date: Wed, 11 Nov 2020 12:59:26 +0100	[thread overview]
Message-ID: <aaceb162-e751-18b0-ebbe-36ba42027096@proxmox.com> (raw)
In-Reply-To: <20201110132218.17717-1-m.limbeck@proxmox.com>

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 <m.limbeck@proxmox.com>
> ---
> 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<Value, Error> {
>           "zfsutils-linux",
>       ];
>   
> -    fn unknown_package(package: String) -> APTUpdateInfo {
> +    fn unknown_package(package: String, extra_info: Option<String>) -> APTUpdateInfo {
>           APTUpdateInfo {
>               package,
>               title: "unknown".into(),
> @@ -288,6 +288,7 @@ pub fn get_versions() -> Result<Value, Error> {
>               priority: "unknown".into(),
>               section: "unknown".into(),
>               change_log_url: "unknown".into(),
> +            extra_info,
>           }
>       }
>   
> @@ -301,14 +302,34 @@ pub fn get_versions() -> Result<Value, Error> {
>           },
>           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: <kernelversion>' instead of just 
'<kernelversion>'
> +        ));
>       }
>   
> -    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<APTUpdateInfo> = pbs_packages
> @@ -334,7 +355,7 @@ pub fn get_versions() -> Result<Value, Error> {
>           }
>           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<String>,
>   }
>   
>   #[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,
>               });
>           }
>       }




  parent reply	other threads:[~2020-11-11 11:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-10 13:22 Mira Limbeck
2020-11-10 13:22 ` [pbs-devel] [PATCH v2 proxmox-backup 2/2] add versions command to proxmox-backup-manager Mira Limbeck
2020-11-11 17:38   ` [pbs-devel] applied: " Thomas Lamprecht
2020-11-12  9:12     ` [pbs-devel] [PATCH proxmox-backup] apt: use typed response for get_versions Stefan Reiter
2020-11-12  9:18       ` [pbs-devel] applied: " Thomas Lamprecht
     [not found]     ` <c16a8594-0f66-eadb-1063-d6309187a4e5@proxmox.com>
2020-11-12  9:29       ` [pbs-devel] applied: [PATCH v2 proxmox-backup 2/2] add versions command to proxmox-backup-manager Thomas Lamprecht
2020-11-11 11:59 ` Mira Limbeck [this message]
2020-11-11 17:33 ` [pbs-devel] applied: [PATCH v2 proxmox-backup 1/2] add extra_info field to APTUpdateInfo Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aaceb162-e751-18b0-ebbe-36ba42027096@proxmox.com \
    --to=m.limbeck@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal