Skip to content

Commit

Permalink
Add support for xe --force argument
Browse files Browse the repository at this point in the history
Some xe commands, like vtpm-destroy, need to be passed a --force
parameter. Since it doesn't take any value, it needs to be handled like
the --minimal argument.

This patch adds support for a force=True|False parameter to host.xe(),
with force=False being the default.

Signed-off-by: Thierry Escande <[email protected]>
  • Loading branch information
tescande committed Aug 23, 2023
1 parent 2fa3e69 commit 526234c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,17 @@ def scp(self, src, dest, check=True, suppress_fingerprint_warnings=True, local_d
suppress_fingerprint_warnings=suppress_fingerprint_warnings, local_dest=local_dest
)

def xe(self, action, args={}, check=True, simple_output=True, minimal=False):
def xe(self, action, args={}, check=True, simple_output=True, minimal=False, force=False):
maybe_param_minimal = ['--minimal'] if minimal else []
maybe_param_force = ['--force'] if force else []

def stringify(key, value):
if isinstance(value, bool):
return "{}={}".format(key, to_xapi_bool(value))
return "{}={}".format(key, shlex.quote(value))

command = ['xe', action] + maybe_param_minimal + [stringify(key, value) for key, value in args.items()]
command = ['xe', action] + maybe_param_minimal + maybe_param_force + \
[stringify(key, value) for key, value in args.items()]
result = self.ssh(
command,
check=check,
Expand Down

0 comments on commit 526234c

Please sign in to comment.