Skip to content

Commit

Permalink
server: introduce --console and --ssh shortcuts
Browse files Browse the repository at this point in the history
Introduce the following shortcuts for convenience:

 $ vng --ssh PORT # equivalent of vng --server ssh --port PORT

 $ vng --console PORT # equivalent of vng --server console --port PORT

Signed-off-by: Andrea Righi <[email protected]>
  • Loading branch information
arighi committed Dec 23, 2024
1 parent 6a14e5d commit 67cb602
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion virtme_ng/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,26 @@ def make_parser():
+ "or to launch this command instead of a prompt (--client).",
)

g_remote.add_argument(
"--console",
action="store",
nargs="?",
type=int,
const=2222,
metavar="PORT",
help="Shortcut for `--server console --port PORT`"
)

g_remote.add_argument(
"--ssh",
action="store",
nargs="?",
type=int,
const=2222,
metavar="PORT",
help="Shortcut for `--server ssh --port PORT`"
)

return parser


Expand Down Expand Up @@ -993,7 +1013,14 @@ def _get_virtme_net_mac_address(self, args):
self.virtme_param["net_mac_address"] = ""

def _get_virtme_server(self, args):
if args.server is not None:
if args.console is not None and args.ssh is not None:
arg_fail('--console cannot be used with --ssh', show_usage=False)

if args.console is not None:
self.virtme_param["server"] = f"--server console --port {args.console}"
elif args.ssh is not None:
self.virtme_param["server"] = f"--server ssh --port {args.ssh}"
elif args.server is not None:
self.virtme_param["server"] = "--server " + args.server
else:
self.virtme_param["server"] = ""
Expand Down

0 comments on commit 67cb602

Please sign in to comment.