public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Max Carrara" <m.carrara@proxmox.com>
To: "Proxmox VE development discussion" <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [RFC esxi-import-tools 2/2] listvms: add message when skipping vCLS agent VMs
Date: Fri, 11 Apr 2025 17:45:14 +0200	[thread overview]
Message-ID: <D93XC9W3SU16.27FQNEVYLV0PI@proxmox.com> (raw)
In-Reply-To: <20250411150634.253684-2-d.kral@proxmox.com>

On Fri Apr 11, 2025 at 5:06 PM CEST, Daniel Kral wrote:
> While at it, factor out the checks to make the control flow a little
> easier to read and add information why there is an extra check for the
> vm.config.

Both of these patches LGTM. Neat!

Side note: Shame that the type annotations in that regard are
incomplete, but that's something we have to deal with, unfortunately :s

Consider:

Reviewed-by: Max Carrara <m.carrara@proxmox.com>

>
> Signed-off-by: Daniel Kral <d.kral@proxmox.com>
> ---
> This is not essential, but I thought it wouldn't hurt to let people know
> of both types being skipped, but could also get quite noisy if there are
> vCLS and/or diskless VMs.
>
>  listvms.py | 30 ++++++++++++++++++------------
>  1 file changed, 18 insertions(+), 12 deletions(-)
>
> diff --git a/listvms.py b/listvms.py
> index bd0adcf..be03759 100755
> --- a/listvms.py
> +++ b/listvms.py
> @@ -251,6 +251,20 @@ def fetch_and_update_vm_data(vm: vim.VirtualMachine, data: dict[Any, Any]):
>      datastores.update({ds.name: ds.url for ds in vm.config.datastoreUrl})
>  
>  
> +def is_vcls_agent_vm(vm: vim.VirtualMachine) -> bool:
> +    # older ESXi installations seem to not expose the vm config
> +    if vm.config is not None:
> +        return False
> +
> +    return any(cfg.key == "HDCS.agent"
> +               and cfg.value.lower() == "true"
> +               for cfg in vm.config.extraConfig)
> +
> +def is_diskless_vm(vm: vim.VirtualMachine) -> bool:
> +    datastore_name, _ = parse_file_path(vm.config.files.vmPathName)
> +
> +    return not datastore_name
> +
>  def main():
>      args = parse_args()
>  
> @@ -266,20 +280,12 @@ def main():
>          data = {}
>          for vm in list_vms(connection):
>              # drop vCLS machines
> -            vCLS = vm.config is not None and any(
> -                cfg.key == "HDCS.agent"
> -                and cfg.value.lower() == "true"
> -                for cfg in vm.config.extraConfig
> -            )
> -            if vCLS:
> +            if is_vcls_agent_vm(vm):
> +                print(f"Skipping vCLS agent VM: {vm.name}", file=sys.stderr)
>                  continue
>              # drop vms with empty datastore
> -            datastore_name, relative_vmx_path = parse_file_path(
> -                vm.config.files.vmPathName
> -            )
> -            if not datastore_name:
> -                print(f"Skipping VM (no datastore value): {vm.name}",
> -                      file=sys.stderr)
> +            if is_diskless_vm(vm):
> +                print(f"Skipping diskless VM: {vm.name}", file=sys.stderr)
>                  continue
>              try:
>                  fetch_and_update_vm_data(vm, data)



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  reply	other threads:[~2025-04-11 15:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-11 15:06 [pve-devel] [PATCH esxi-import-tools 1/2] listvms: add check for vCLS test whether vm configuration is present Daniel Kral
2025-04-11 15:06 ` [pve-devel] [RFC esxi-import-tools 2/2] listvms: add message when skipping vCLS agent VMs Daniel Kral
2025-04-11 15:45   ` Max Carrara [this message]
2025-04-24 17:33 ` [pve-devel] applied: [PATCH esxi-import-tools 1/2] listvms: add check for vCLS test whether vm configuration is present Thomas Lamprecht
2025-04-25  7:38   ` Daniel Kral

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=D93XC9W3SU16.27FQNEVYLV0PI@proxmox.com \
    --to=m.carrara@proxmox.com \
    --cc=pve-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