feat: release v1.1.0 - clean YAML, wildcard DNS protection, and tag/group/source filtering
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
5fedc44c6b
commit
598e5d7397
18 files changed
+318
-22
No files matched your search
@@ -101,6 +101,21 @@ def build_parser() -> argparse.ArgumentParser:
|
||||
type=Path,
|
||||
help="Path to configuration file (config.yaml)."
|
||||
)
|
||||
parser.add_argument(
|
||||
"-t", "--tag", "--filter-tag",
|
||||
dest="filter_tag",
|
||||
help="Filter hosts by tag (e.g. 'hypervisor', 'pve', 'k3s')."
|
||||
)
|
||||
parser.add_argument(
|
||||
"-g", "--group", "--category", "--filter-group",
|
||||
dest="filter_group",
|
||||
help="Filter hosts by group or category name (e.g. 'proxmox_vms', 'storage')."
|
||||
)
|
||||
parser.add_argument(
|
||||
"--source-type", "--filter-source", "--origin",
|
||||
dest="filter_source",
|
||||
help="Filter hosts by source provider (e.g. 'proxmox', 'static', 'file', 'k3s')."
|
||||
)
|
||||
return parser
|
||||
|
||||
def main(argv: Optional[List[str]] = None) -> int:
|
||||
@@ -149,7 +164,8 @@ def main(argv: Optional[List[str]] = None) -> int:
|
||||
verify_ssl=verify_ssl,
|
||||
timeout=app_config.proxmox.timeout,
|
||||
default_user=app_config.default_ssh_user,
|
||||
quiet=is_quiet
|
||||
quiet=is_quiet,
|
||||
resolve_dns=app_config.proxmox.resolve_dns
|
||||
)
|
||||
raw_records.extend(pve_collector.collect())
|
||||
|
||||
@@ -180,10 +196,28 @@ def main(argv: Optional[List[str]] = None) -> int:
|
||||
for w in warnings:
|
||||
sys.stderr.write(f"[WARN] {w}\n")
|
||||
|
||||
# 4b. Filter inventory by tag, group, or source provider if requested
|
||||
has_filter = bool(args.filter_tag or args.filter_group or args.filter_source)
|
||||
if has_filter:
|
||||
inv = inv.filter(
|
||||
tag=args.filter_tag,
|
||||
group=args.filter_group,
|
||||
source=args.filter_source
|
||||
)
|
||||
|
||||
# 5. Inspection / Dry-run Mode
|
||||
if args.dry_run:
|
||||
filter_desc = []
|
||||
if args.filter_tag:
|
||||
filter_desc.append(f"tag='{args.filter_tag}'")
|
||||
if args.filter_group:
|
||||
filter_desc.append(f"group='{args.filter_group}'")
|
||||
if args.filter_source:
|
||||
filter_desc.append(f"source='{args.filter_source}'")
|
||||
filter_suffix = f" (filtered by {', '.join(filter_desc)})" if filter_desc else ""
|
||||
|
||||
if not is_quiet:
|
||||
sys.stderr.write(f"[INFO] Discovered {len(inv.hosts)} hosts across {len(inv.groups)} groups.\n")
|
||||
sys.stderr.write(f"[INFO] Discovered {len(inv.hosts)} hosts across {len(inv.groups)} groups{filter_suffix}.\n")
|
||||
print("NAME IP ADDRESS SOURCE GROUPS")
|
||||
for h in inv.hosts.values():
|
||||
groups_str = ", ".join(h.groups)
|
||||
|
||||
Reference in new issue
Block a user