From: Daniel Herzig <d.herzig@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-esxi-import-tools] fix #6347: do not break vm listing on invalid configs
Date: Wed, 23 Apr 2025 15:03:15 +0200 [thread overview]
Message-ID: <20250423130315.360403-1-d.herzig@proxmox.com> (raw)
Move the queries for vCLS machines and empty datastore strings into
the already existing try-except routine to save `listvms.py` from
breaking when `vm.config` is `None`.
Do not store the result of the `any` function in a variable anymore,
do the same for the datastore query to shorten code.
Prepare more verbose logging.
Signed-off-by: Daniel Herzig <d.herzig@proxmox.com>
---
listvms.py | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/listvms.py b/listvms.py
index 89ddfb2..4995975 100755
--- a/listvms.py
+++ b/listvms.py
@@ -265,21 +265,19 @@ def main():
with connect_to_esxi_host(connection_args) as connection:
data = {}
for vm in list_vms(connection):
- # drop vCLS machines
- vCLS = any(cfg.key == "HDCS.agent"
- and cfg.value.lower() == "true"
- for cfg in vm.config.extraConfig)
- if vCLS:
- 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)
- continue
try:
+ # drop vCLS machines
+ if any(cfg.key == "HDCS.agent"
+ and cfg.value.lower() == "true"
+ for cfg in vm.config.extraConfig):
+ print(f"Skipping ESXI VM (VMware internals): {vm.name}",
+ file=sys.stderr)
+ continue
+ # drop vms with empty datastore
+ if not parse_file_path(vm.config.files.vmPathName)[0]:
+ print(f"Skipping ESXI VM (no datastore value): {vm.name}",
+ file=sys.stderr)
+ continue
fetch_and_update_vm_data(vm, data)
except Exception as err:
print(
--
2.39.5
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next reply other threads:[~2025-04-23 13:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-23 13:03 Daniel Herzig [this message]
2025-04-23 13:28 ` Daniel Kral
2025-04-23 14:04 ` Daniel Herzig
2025-04-23 14:45 ` Daniel Kral
2025-04-23 15:17 ` Daniel Herzig
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=20250423130315.360403-1-d.herzig@proxmox.com \
--to=d.herzig@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