Skip to content

Commit

Permalink
virt: Make virsh absence non fatal for other tests
Browse files Browse the repository at this point in the history
This is a solution for issue autotest#563.

If one is only testing kvm components, for example,
the absence of virsh should not be relevant, but
since the module throws an exception on import, and
module is imported on env_processing, a ValueError
will be thrown and fail completely all the tests.

Let's fail things only when actual functionality of
the module is called, during the initialization of
the BaseVirsh class.

CC: Chris Evich <[email protected]>
Signed-off-by: Lucas Meneghel Rodrigues <[email protected]>
  • Loading branch information
lmr committed Sep 24, 2012
1 parent 5ce7cf7 commit b3b38df
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion client/tests/virt/virttest/virsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@
]

# default virsh executable
VIRSH_EXEC = os_dep.command("virsh")
try:
VIRSH_EXEC = os_dep.command("virsh")
except ValueError:
VIRSH_EXEC = None
logging.info("Command 'virsh' is not installed, please install it")

# Virsh class properties and default values
# Schema: {<name>:<default>}
Expand Down Expand Up @@ -97,6 +101,9 @@ def __init__(self, **dargs):
"""
Initialize libvirt connection/state from VIRSH_PROPERTIES and/or dargs
"""
if VIRSH_EXEC is None:
raise ValueError("Command 'virsh' is not installed, "
"please install it.")
# Setup defaults, (calls properties)
_dargs = VIRSH_PROPERTIES.copy()
_dargs.update(dargs)
Expand Down

0 comments on commit b3b38df

Please sign in to comment.