various improvements

This commit is contained in:
ge 2023-11-09 02:21:42 +03:00
parent 64bdbbd97b
commit f70349716a
3 changed files with 8 additions and 10 deletions

View File

@ -2,8 +2,6 @@
Compute-instance management library and tools.
Currently supports only QEMU/KVM based virtual machines.
## Docs
Run `make serve-docs`. See [Development](#development) below.

View File

@ -89,16 +89,16 @@ def _exec_guest_agent_command(
instance = session.get_instance(args.instance)
ga = GuestAgent(instance.domain, timeout=args.timeout)
arguments = args.arguments.copy()
if len(arguments) > 1:
if len(arguments) > 1 and not args.no_join_args:
arguments = [shlex.join(arguments)]
if not args.no_cmd_string:
if not args.no_join_args:
arguments.insert(0, '-c')
stdin = None
if not sys.stdin.isatty():
stdin = sys.stdin.read()
try:
output = ga.guest_exec(
path=args.shell,
path=args.executable,
args=arguments,
env=args.env,
stdin=stdin,
@ -296,8 +296,8 @@ def cli() -> None: # noqa: PLR0915
),
)
execute.add_argument(
'-s',
'--shell',
'-x',
'--executable',
default='/bin/sh',
help='path to executable in guest, /bin/sh by default',
)
@ -311,11 +311,11 @@ def cli() -> None: # noqa: PLR0915
)
execute.add_argument(
'-n',
'--no-cmd-string',
'--no-join-args',
action='store_true',
default=False,
help=(
"do not append '-c' option to arguments list, suitable "
"do not join arguments list and add '-c' option, suitable "
'for non-shell executables and other specific cases.'
),
)

View File

@ -409,7 +409,7 @@ class Instance:
raise InstanceError(
f'Cannot set zero vCPUs for instance={self.name}'
)
if nvcpus == self.info.nproc:
if nvcpus == self.get_info().nproc:
log.warning(
'Instance instance=%s already have %s vCPUs, nothing to do',
self.name,