commit 2a0f57c89c3ba111a4c28c94e34aa1013d4d26c1
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Tue Nov 27 08:20:20 2012 +0100
NetTestController: check for running libvirtd
The controller now checks if the libvirt daemon is running and based on
this it decides if the MachinePool class should or shouldn't load
machine files that describe virtual machines.
There is also a minor change to the check_process_running function to
redirect the command output so that it isn't logged.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
lnst/Common/Utils.py | 3 ++-
lnst/Controller/MachinePool.py | 8 ++++++--
lnst/Controller/NetTestController.py | 10 ++++++++--
3 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/lnst/Common/Utils.py b/lnst/Common/Utils.py
index 65d5902..b2315f8 100644
--- a/lnst/Common/Utils.py
+++ b/lnst/Common/Utils.py
@@ -152,7 +152,8 @@ def _is_newer_than(f, threshold):
def check_process_running(process_name):
try:
- proc = subprocess.check_call(["pgrep", process_name])
+ proc = subprocess.check_call(["pgrep", process_name],
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
return True
except subprocess.CalledProcessError:
return False
diff --git a/lnst/Controller/MachinePool.py b/lnst/Controller/MachinePool.py
index 7ed6272..f70edcb 100644
--- a/lnst/Controller/MachinePool.py
+++ b/lnst/Controller/MachinePool.py
@@ -33,7 +33,10 @@ class MachinePool:
_machine_matches = []
_network_matches = []
- def __init__(self, pool_dirs):
+ _allow_virtual = False
+
+ def __init__(self, pool_dirs, allow_virtual=False):
+ self._allow_virtual = allow_virtual
for pool_dir in pool_dirs:
self.add_dir(pool_dir)
@@ -62,7 +65,8 @@ class MachinePool:
machine["dom_node_ref"] = machineconfig
parser.parse(machineconfig)
- self._pool[machine_id] = machine
+ if 'libvirt_domain' not in machine['info'] or
self._allow_virtual:
+ self._pool[machine_id] = machine
def provision_setup(self, setup_requirements):
"""
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index 1b3bad0..5e899be 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -25,6 +25,7 @@ from lnst.Common.XmlRpc import ServerProxy, ServerException
from lnst.Common.NetUtils import MacPool
from lnst.Common.VirtUtils import VirtNetCtl, VirtDomainCtl, BridgeCtl
from lnst.Common.Utils import wait_for, md5sum, dir_md5sum, create_tar_archive
+from lnst.Common.Utils import check_process_running
from lnst.Common.NetTestCommand import NetTestCommandContext, NetTestCommand
from lnst.Common.NetTestCommand import str_command
from lnst.Controller.NetTestParse import NetTestParse
@@ -44,8 +45,13 @@ class NetTestController:
self._remote_capture_files = {}
self._config = config
self._log_root_path = Logs.get_logging_root_path()
- self._machine_pool = MachinePool(config.get_option('environment',
- 'pool_dirs'))
+
+ if check_process_running("libvirtd"):
+ self._machine_pool = MachinePool(config.get_option('environment',
+ 'pool_dirs'), allow_virtual=True)
+ else:
+ self._machine_pool = MachinePool(config.get_option('environment',
+ 'pool_dirs'), allow_virtual=False)
self._recipe = {}
definitions = {"recipe": self._recipe}
Show replies by date