commit 3843690c884f8c19db069207158a97a0014285f7 Author: Ondrej Lichtner olichtne@redhat.com Date: Thu Feb 20 13:21:50 2014 +0100
Controller: conditional VirtUtils import
Since running the lnst controller doesn't necessarily depend on having libvirt running or installed this commit adds a condition to the import of the VirtUtils module. This will fix lnst-ctl crashing on machines that don't have libvirt running.
Signed-off-by: Ondrej Lichtner olichtne@redhat.com Signed-off-by: Jiri Pirko jiri@resnulli.us
lnst/Controller/Machine.py | 6 +++++- lnst/Controller/NetTestController.py | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) --- diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py index 75c0d8a..25749e0 100644 --- a/lnst/Controller/Machine.py +++ b/lnst/Controller/Machine.py @@ -24,11 +24,15 @@ from pprint import pprint, pformat from lnst.Common.Config import lnst_config from lnst.Common.Logs import log_exc_traceback from lnst.Common.NetUtils import MacPool, normalize_hwaddr -from lnst.Common.VirtUtils import VirtNetCtl, VirtDomainCtl from lnst.Common.Utils import wait_for, md5sum, dir_md5sum, create_tar_archive +from lnst.Common.Utils import check_process_running from lnst.Common.ConnectionHandler import send_data, recv_data from lnst.Common.ConnectionHandler import ConnectionHandler
+# conditional support for libvirt +if check_process_running("libvirtd"): + from lnst.Common.VirtUtils import VirtNetCtl, VirtDomainCtl + DEFAULT_TIMEOUT = 60
class MachineError(Exception): diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py index 1831a71..39bc83a 100644 --- a/lnst/Controller/NetTestController.py +++ b/lnst/Controller/NetTestController.py @@ -21,7 +21,6 @@ import imp from time import sleep from xmlrpclib import Binary from lnst.Common.NetUtils import MacPool -from lnst.Common.VirtUtils import VirtNetCtl, VirtDomainCtl from lnst.Common.Utils import wait_for, md5sum, dir_md5sum, create_tar_archive from lnst.Common.Utils import check_process_running, bool_it from lnst.Common.NetTestCommand import NetTestCommandContext, NetTestCommand @@ -37,6 +36,10 @@ from lnst.Common.Colours import decorate_with_preset from lnst.Common.NetUtils import test_tcp_connection import lnst.Controller.Task as Task
+# conditional support for libvirt +if check_process_running("libvirtd"): + from lnst.Common.VirtUtils import VirtNetCtl, VirtDomainCtl + class NetTestError(Exception): pass
lnst-developers@lists.fedorahosted.org