Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

osfv_cli/src/osfv/cli/cli.py: add ad-hoc-mode #94

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions osfv_cli/src/osfv/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,12 @@ def main():
help="Output as JSON (if applicable)",
)

parser.add_argument(
"--adhoc",
action="store_true",
help="Enable ad-hoc mode to use any RTE.",
)

subparsers = parser.add_subparsers(
title="commands", dest="command", help="Command to execute"
)
Expand Down Expand Up @@ -880,7 +886,13 @@ def main():
if asset_id:
check_out_asset(snipeit_api, asset_id)
else:
print(f"No asset found with RTE IP: {args.rte_ip}")
if args.adhoc:
print(
f"Ad-hoc mode: No asset found with RTE IP: {args.rte_ip}. Proceeding with ad-hoc configuration."
)
else:
print(f"No asset found with RTE IP: {args.rte_ip}")
sys.exit(1)
elif args.snipeit_cmd == "check_in":
if args.asset_id:
check_in_asset(snipeit_api, args.asset_id)
Expand All @@ -889,7 +901,13 @@ def main():
if asset_id:
check_in_asset(snipeit_api, asset_id)
else:
print(f"No asset found with RTE IP: {args.rte_ip}")
if args.adhoc:
print(
f"Ad-hoc mode: No asset found with RTE IP: {args.rte_ip}. Proceeding with ad-hoc configuration."
)
else:
print(f"No asset found with RTE IP: {args.rte_ip}")
sys.exit(1)
elif args.snipeit_cmd == "check_in_my":
check_in_my(snipeit_api, args)
elif args.snipeit_cmd == "user_add":
Expand All @@ -905,7 +923,13 @@ def main():
if not args.skip_snipeit:
asset_id = snipeit_api.get_asset_id_by_rte_ip(args.rte_ip)
if not asset_id:
print(f"No asset found with RTE IP: {args.rte_ip}")
if args.adhoc:
print(
f"Ad-hoc mode: No asset found with RTE IP: {args.rte_ip}. Skipping Snipe-IT checks."
)
else:
print(f"No asset found with RTE IP: {args.rte_ip}")
sys.exit(1)

if args.model:
print(f"DUT model retrieved from cmdline, skipping Snipe-IT query")
Expand Down Expand Up @@ -1009,7 +1033,13 @@ def main():

asset_id = snipeit_api.get_asset_id_by_sonoff_ip(sonoff_ip)
if not asset_id:
print(f"No asset found with RTE IP: {args.rte_ip}")
if args.adhoc:
print(
f"Ad-hoc mode: No asset found with RTE IP: {args.rte_ip}. Skipping Snipe-IT checks."
)
else:
print(f"No asset found with RTE IP: {args.rte_ip}")
sys.exit(1)

print(
f"Using rte command is invasive action, checking first if the device is not used..."
Expand Down