fix(cli): silence info and warnings in --list mode, add -q/-v flags, bump version to 1.0.1
Build and Publish Release / Build Packages and Publish (push) Successful in 9s
Build and Publish Release / Build Packages and Publish (push) Successful in 9s
This commit is contained in:
1 parent
e19a4303f8
commit
5fedc44c6b
6 files changed
+64
-21
No files matched your search
@@ -19,7 +19,8 @@ class ProxmoxCollector(BaseCollector):
|
||||
token_secret: str,
|
||||
verify_ssl: bool = False,
|
||||
timeout: int = 10,
|
||||
default_user: str = "lain"
|
||||
default_user: str = "lain",
|
||||
quiet: bool = False
|
||||
) -> None:
|
||||
# Normalize base URL (strip trailing slashes and /api2/json if included)
|
||||
clean_url = url.rstrip("/")
|
||||
@@ -30,6 +31,7 @@ class ProxmoxCollector(BaseCollector):
|
||||
self.verify_ssl = verify_ssl
|
||||
self.timeout = timeout
|
||||
self.default_user = default_user
|
||||
self.quiet = quiet
|
||||
|
||||
if not self.verify_ssl:
|
||||
self.ssl_context = ssl._create_unverified_context()
|
||||
@@ -50,7 +52,8 @@ class ProxmoxCollector(BaseCollector):
|
||||
# 500 often happens if guest agent is not running on VM
|
||||
return {}
|
||||
except Exception as e:
|
||||
sys.stderr.write(f"[WARN] Proxmox API request failed for '{endpoint}': {e}\n")
|
||||
if not self.quiet:
|
||||
sys.stderr.write(f"[WARN] Proxmox API request failed for '{endpoint}': {e}\n")
|
||||
return {}
|
||||
|
||||
def _parse_tags(self, raw_tags: Optional[str]) -> List[str]:
|
||||
@@ -151,7 +154,8 @@ class ProxmoxCollector(BaseCollector):
|
||||
ip = self._resolve_qemu_ip(node_name, vmid, vm_name)
|
||||
if not ip:
|
||||
tags.append("no-ip")
|
||||
sys.stderr.write(f"[WARN] No IP address discovered for VM '{vm_name}' (vmid: {vmid}, status: {status})\n")
|
||||
if not self.quiet:
|
||||
sys.stderr.write(f"[WARN] No IP address discovered for VM '{vm_name}' (vmid: {vmid}, status: {status})\n")
|
||||
|
||||
groups = ["proxmox_vms", f"pve_node_{node_name}", f"status_{status}"]
|
||||
for t in tags:
|
||||
@@ -189,7 +193,8 @@ class ProxmoxCollector(BaseCollector):
|
||||
ip = self._resolve_lxc_ip(node_name, vmid, ct_name)
|
||||
if not ip:
|
||||
tags.append("no-ip")
|
||||
sys.stderr.write(f"[WARN] No IP address discovered for LXC container '{ct_name}' (vmid: {vmid}, status: {status})\n")
|
||||
if not self.quiet:
|
||||
sys.stderr.write(f"[WARN] No IP address discovered for LXC container '{ct_name}' (vmid: {vmid}, status: {status})\n")
|
||||
|
||||
groups = ["proxmox_lxc", f"pve_node_{node_name}", f"status_{status}"]
|
||||
for t in tags:
|
||||
|
||||
Reference in new issue
Block a user