[PATCH] Ignorecase when parsing output in iperf module
by Artem Savkov
With iperf-2.0.5 when throughput is in kilobits iperf outputs it as
'Kbits/sec', example:
[ 27] 0.0-44.3 sec 1.12 MBytes 213 Kbits/sec
lnst's iperf module however, looks for lowercase k failing to
parse output.
Added re.IGNORECASE flag so any case would work. Regexp is complex enough so
that ignorecase shouldn't introduce any false hits.
Signed-off-by: Artem Savkov <asavkov(a)redhat.com>
---
test_modules/Iperf.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test_modules/Iperf.py b/test_modules/Iperf.py
index 74fa9b6..8e5bd67 100644
--- a/test_modules/Iperf.py
+++ b/test_modules/Iperf.py
@@ -90,7 +90,7 @@ class Iperf(TestGeneric):
logging.info("Iperf connection failed!")
return (False, "Iperf connection failed!")
- m = re.search("\[[^0-9]*[0-9]*\]\s*0.0-\s*\d*\.\d sec\s*\d*(\.\d*){0,1}\s*[ kGMT]Bytes\s*(\d*(\.\d*){0,1}\s*[ kGMT]bits\/sec)", output)
+ m = re.search("\[[^0-9]*[0-9]*\]\s*0.0-\s*\d*\.\d sec\s*\d*(\.\d*){0,1}\s*[ kGMT]Bytes\s*(\d*(\.\d*){0,1}\s*[ kGMT]bits\/sec)", output, re.IGNORECASE)
if m is None:
logging.info("Could not get performance throughput!")
return (False, "Could not get performance throughput!")
--
1.9.3
9 years, 1 month
[PATCH] Support for parallelization when querying machines in machine pools.
by Jiri Prochazka
Changes: Controller now loads all machines from all machine pool dirs,
and queries them all at once. This significantly improves waiting time
when any number of unavailable devices are in the pool.
Queue is used for storing touples (m_id, available)
Process runs function query_machine, for querying machine
Signed-off-by: Jiri Prochazka <jprochaz(a)redhat.com>
---
lnst/Controller/SlavePool.py | 93 ++++++++++++++++++++++++++------------------
1 file changed, 56 insertions(+), 37 deletions(-)
diff --git a/lnst/Controller/SlavePool.py b/lnst/Controller/SlavePool.py
index 22c4379..a6a55cd 100644
--- a/lnst/Controller/SlavePool.py
+++ b/lnst/Controller/SlavePool.py
@@ -18,6 +18,7 @@ import os
import re
import copy
from xml.dom import minidom
+from multiprocessing import Process, Queue
from lnst.Common.Config import lnst_config
from lnst.Common.NetUtils import normalize_hwaddr
from lnst.Common.NetUtils import test_tcp_connection
@@ -45,24 +46,50 @@ class SlavePool:
logging.info("Checking machine pool availability.")
for pool_dir in pool_dirs:
self.add_dir(pool_dir)
+ self.check_availability()
+
+ def query_machine(self, machine, queue):
+ if self._pool_checks:
+ available = False
+ m_id = machine
+ hostname = self._pool[machine]["params"]["hostname"]
+ if "rpc_port" in self._pool[machine]["params"]:
+ port = self._pool[machine]["params"]["rpc_port"]
+ else:
+ port = lnst_config.get_option('environment', 'rpcport')
- def add_dir(self, pool_dir):
- logging.info("Processing pool dir '%s'" % pool_dir)
- dentries = os.listdir(pool_dir)
+ logging.debug("Querying machine '%s': %s:%s" %\
+ (m_id, hostname, port))
+ if test_tcp_connection(hostname, port):
+ available = True
- res = []
- for dirent in dentries:
- m_info = self.add_file("%s/%s" % (pool_dir, dirent))
- if m_info != None:
- res.append(m_info)
+ if 'libvirt_domain' in self._pool[machine]['params'] and \
+ not self._allow_virt:
+ logging.debug("libvirtd not running. Removing "\
+ "libvirt_domain from machine '%s'" % m_id)
+ del self._pool[machine]['params']['libvirt_domain']
+ else:
+ available = True
+ queue.put((m_id, available))
- if len(res) == 0:
- logging.warn("No machines found in this directory")
+ def check_availability(self):
max_len = 0
- for m_id, _ in res:
- if len(m_id) > max_len:
- max_len = len(m_id)
+ res = []
+ queue = Queue()
+ for machine in self._pool:
+ proc = Process(target=self.query_machine , args=(machine, queue,))
+ proc.start()
+
+ proc.join()
+
+ while not queue.empty():
+ res.append(queue.get())
+
+ for machine in res:
+ if len(machine) > max_len:
+ max_len = len(machine)
+
for m_id, available in res:
if available:
machine_spec = self._pool[m_id]
@@ -77,9 +104,23 @@ class SlavePool:
else:
msg = "%s%s [%s]" % (m_id, (max_len - len(m_id)) * " ",
decorate_with_preset("DOWN", "fail"))
+ del self._pool[m_id]
logging.info(msg)
+ def add_dir(self, pool_dir):
+ logging.info("Processing pool dir '%s'" % pool_dir)
+ dentries = os.listdir(pool_dir)
+
+ res = []
+ for dirent in dentries:
+ m_info = self.add_file("%s/%s" % (pool_dir, dirent))
+ if m_info != None:
+ res.append(m_info)
+
+ if len(res) == 0:
+ logging.warn("No machines found in this directory")
+
def add_file(self, filepath):
if os.path.isfile(filepath) and re.search("\.xml$", filepath, re.I):
dirname, basename = os.path.split(filepath)
@@ -105,31 +146,9 @@ class SlavePool:
"your pool ('%s' and '%s')." % (m_id, pm_id)
raise SlaveMachineError(msg)
- if self._pool_checks:
- available = False
+ self._pool[m_id] = machine_spec
- hostname = machine_spec["params"]["hostname"]
- if "rpc_port" in machine_spec["params"]:
- port = machine_spec["params"]["rpc_port"]
- else:
- port = lnst_config.get_option('environment', 'rpcport')
-
- logging.debug("Querying machine '%s': %s:%s" %\
- (m_id, hostname, port))
- if test_tcp_connection(hostname, port):
- available = True
-
- if 'libvirt_domain' in machine_spec['params'] and \
- not self._allow_virt:
- logging.debug("libvirtd not running. Removing "\
- "libvirt_domain from machine '%s'" % m_id)
- del machine_spec['params']['libvirt_domain']
- else:
- available = True
-
- if available:
- self._pool[m_id] = machine_spec
- return (m_id, available)
+ return m_id
def _process_machine_xml_data(self, m_id, machine_xml_data):
machine_spec = {"interfaces": {}, "params":{}}
--
1.9.3
9 years, 1 month
[PATCH] Logs: reset logging configuration on init
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
This patch makes sure that the python logging module is cleared of any
previously set log handlers. Without this we could have our logs appear
twice in a row as was experienced when deprecatin messages were added to
the current release of pyroute2.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Common/Logs.py | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/lnst/Common/Logs.py b/lnst/Common/Logs.py
index 89118c1..233f427 100644
--- a/lnst/Common/Logs.py
+++ b/lnst/Common/Logs.py
@@ -102,6 +102,16 @@ class LoggingCtl:
transmit_handler = None
def __init__(self, debug=False, log_dir=None, log_subdir="", colours=True):
+ #clear any previously set handlers
+ logger = logging.getLogger('')
+ for i in list(logger.handlers):
+ logger.removeHandler(i)
+ for key, logger in logging.Logger.manager.loggerDict.iteritems():
+ if type(logger) != type(logging.Logger):
+ continue
+ for i in list(logger.handlers):
+ logger.removeHandler(i)
+
self._origin_name = None
if log_dir != None:
--
1.9.3
9 years, 1 month
[PATCH] UnusedInterface: add forgotten method overide
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
The cleanup method wasn't overridden and the controller would try to
unmap unused interfaces.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/Machine.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py
index cfc4d77..26e475a 100644
--- a/lnst/Controller/Machine.py
+++ b/lnst/Controller/Machine.py
@@ -928,3 +928,6 @@ class UnusedInterface(Interface):
def down(self):
pass
+
+ def cleanup(self):
+ pass
--
1.9.3
9 years, 1 month
[PATCH] MessageDispatcherLite: fix missing import
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
Exception class NetTestError wasn't imported.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/MessageDispatcherLite.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/lnst/Controller/MessageDispatcherLite.py b/lnst/Controller/MessageDispatcherLite.py
index 8e26d17..e86c077 100644
--- a/lnst/Controller/MessageDispatcherLite.py
+++ b/lnst/Controller/MessageDispatcherLite.py
@@ -13,6 +13,7 @@ jpirko(a)redhat.com (Jiri Pirko)
from lnst.Common.ConnectionHandler import send_data, recv_data
from lnst.Common.ConnectionHandler import ConnectionHandler
+from lnst.Controller.NetTestController import NetTestError
class MessageDispatcherLite(ConnectionHandler):
def __init__(self):
--
1.9.3
9 years, 1 month