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. Compute-instance management library and tools.
Currently supports only QEMU/KVM based virtual machines.
## Docs ## Docs
Run `make serve-docs`. See [Development](#development) below. 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) instance = session.get_instance(args.instance)
ga = GuestAgent(instance.domain, timeout=args.timeout) ga = GuestAgent(instance.domain, timeout=args.timeout)
arguments = args.arguments.copy() arguments = args.arguments.copy()
if len(arguments) > 1: if len(arguments) > 1 and not args.no_join_args:
arguments = [shlex.join(arguments)] arguments = [shlex.join(arguments)]
if not args.no_cmd_string: if not args.no_join_args:
arguments.insert(0, '-c') arguments.insert(0, '-c')
stdin = None stdin = None
if not sys.stdin.isatty(): if not sys.stdin.isatty():
stdin = sys.stdin.read() stdin = sys.stdin.read()
try: try:
output = ga.guest_exec( output = ga.guest_exec(
path=args.shell, path=args.executable,
args=arguments, args=arguments,
env=args.env, env=args.env,
stdin=stdin, stdin=stdin,
@ -296,8 +296,8 @@ def cli() -> None: # noqa: PLR0915
), ),
) )
execute.add_argument( execute.add_argument(
'-s', '-x',
'--shell', '--executable',
default='/bin/sh', default='/bin/sh',
help='path to executable in guest, /bin/sh by default', help='path to executable in guest, /bin/sh by default',
) )
@ -311,11 +311,11 @@ def cli() -> None: # noqa: PLR0915
) )
execute.add_argument( execute.add_argument(
'-n', '-n',
'--no-cmd-string', '--no-join-args',
action='store_true', action='store_true',
default=False, default=False,
help=( 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.' 'for non-shell executables and other specific cases.'
), ),
) )

View File

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