* [pve-devel] [PATCH esxi-import-tools 1/2] listvms: add check for vCLS test whether vm configuration is present
@ 2025-04-11 15:06 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-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
0 siblings, 2 replies; 5+ messages in thread
From: Daniel Kral @ 2025-04-11 15:06 UTC (permalink / raw)
To: pve-devel
It seems that on older ESXi installations, e.g. ESXi 6.7 [0], there are
virtual machines, which do not expose a config property for some VMs.
Therefore, test whether the config is available before checking if the
current entry is a vCLS VM.
[0] https://forum.proxmox.com/threads/164900/
Signed-off-by: Daniel Kral <d.kral@proxmox.com>
---
listvms.py | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/listvms.py b/listvms.py
index 89ddfb2..bd0adcf 100755
--- a/listvms.py
+++ b/listvms.py
@@ -266,9 +266,11 @@ def main():
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)
+ 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:
continue
# drop vms with empty datastore
base-commit: e6f497ea7668e6956ec4461837cf613a0736e684
--
2.39.5
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pve-devel] [RFC esxi-import-tools 2/2] listvms: add message when skipping vCLS agent VMs
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 ` Daniel Kral
2025-04-11 15:45 ` Max Carrara
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
1 sibling, 1 reply; 5+ messages in thread
From: Daniel Kral @ 2025-04-11 15:06 UTC (permalink / raw)
To: pve-devel
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.
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)
--
2.39.5
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [pve-devel] [RFC esxi-import-tools 2/2] listvms: add message when skipping vCLS agent VMs
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
0 siblings, 0 replies; 5+ messages in thread
From: Max Carrara @ 2025-04-11 15:45 UTC (permalink / raw)
To: Proxmox VE development discussion
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pve-devel] applied: [PATCH esxi-import-tools 1/2] listvms: add check for vCLS test whether vm configuration is present
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-24 17:33 ` Thomas Lamprecht
2025-04-25 7:38 ` Daniel Kral
1 sibling, 1 reply; 5+ messages in thread
From: Thomas Lamprecht @ 2025-04-24 17:33 UTC (permalink / raw)
To: pve-devel, Daniel Kral
On Fri, 11 Apr 2025 17:06:33 +0200, Daniel Kral wrote:
> It seems that on older ESXi installations, e.g. ESXi 6.7 [0], there are
> virtual machines, which do not expose a config property for some VMs.
> Therefore, test whether the config is available before checking if the
> current entry is a vCLS VM.
>
> [0] https://forum.proxmox.com/threads/164900/
>
> [...]
Applied, but I had to make a followup for the second patch, which had a
logical error that was even reported on package build:
---
mypy listvms.py
listvms.py:261: error: "None" has no attribute "extraConfig" [attr-defined]
---
Would be great if you could end to end test changes.
As reference, I took this patch over the one from Daniel Herzig [0]
mostly due timing and the R-b trailer here.
[0]: https://lore.proxmox.com/all/20250423130315.360403-1-d.herzig@proxmox.com/
[1/2] listvms: add check for vCLS test whether vm configuration is present
commit: 3d3c4d60849a706fd3c9ad1402233fb4be09a38f
[2/2] listvms: add message when skipping vCLS agent VMs
commit: 9fee27b19e4cbd7f68adb0056d2fe8545a309700
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [pve-devel] applied: [PATCH esxi-import-tools 1/2] listvms: add check for vCLS test whether vm configuration is present
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
0 siblings, 0 replies; 5+ messages in thread
From: Daniel Kral @ 2025-04-25 7:38 UTC (permalink / raw)
To: Thomas Lamprecht, pve-devel
On 4/24/25 19:33, Thomas Lamprecht wrote:
> Applied, but I had to make a followup for the second patch, which had a
> logical error that was even reported on package build:
>
> ---
> mypy listvms.py
> listvms.py:261: error: "None" has no attribute "extraConfig" [attr-defined]
> ---
>
> Would be great if you could end to end test changes.
Yes, I'm sorry, I should have catched that before sending the patch. I
will take more care for future patches.
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-04-25 7:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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
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