diff --git a/avocado/plugins/vm.py b/avocado/plugins/vm.py index ba7fc8d6af7ee2ae3c87d53d1679892f964146b2..96308bb2a03e2a35372596409486416ebe2be5c0 100644 --- a/avocado/plugins/vm.py +++ b/avocado/plugins/vm.py @@ -250,6 +250,9 @@ class RunVM(plugin.Plugin): enabled = True def configure(self, app_parser, cmd_parser): + if virt.virt_capable is False: + self.enabled = False + return username = getpass.getuser() self.parser = app_parser app_parser.add_argument('--vm', action='store_true', default=False, diff --git a/avocado/utils/virt.py b/avocado/utils/virt.py index e5d32c4af02a84b3516669633c858087adead701..2d9e2f366a52a274d3e108ee994c6b7cdde6fa62 100644 --- a/avocado/utils/virt.py +++ b/avocado/utils/virt.py @@ -16,7 +16,12 @@ Module to provide classes for Virtual Machines. """ -import libvirt +try: + import libvirt +except ImportError: + virt_capable = False +else: + virt_capable = True from xml.dom import minidom from avocado.utils import remote