[lnst] SlavePool: add information about pool machines
by Jiří Pírko
commit a41f03310800a894455d4545e08342b9f712eaed
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Thu Sep 19 13:46:34 2013 +0200
SlavePool: add information about pool machines
This commit changes how LNST presents information about loaded pool
machines.
* the query messages were moved to debug logs
* added info messages about which pool directory is being processed
* after a directory is loaded, a colorized summary of availability is
printed
I also adjusted what happens to virt machines when virtualization is
disabled but the machiens are available. In that case the libvirt_domain
attribute is ignored meaning that the machine will only be used in the
matching algorithm for static interfaces.
If a machine will be used in the dynamic interfaces matching algorithm
it will have its libvirt_domain printed in the summary described above.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Controller/SlavePool.py | 48 +++++++++++++++++++++++++++++++++--------
1 files changed, 38 insertions(+), 10 deletions(-)
---
diff --git a/lnst/Controller/SlavePool.py b/lnst/Controller/SlavePool.py
index d83de40..bd81f81 100644
--- a/lnst/Controller/SlavePool.py
+++ b/lnst/Controller/SlavePool.py
@@ -25,6 +25,7 @@ from lnst.Common.XmlProcessing import XmlProcessingError, XmlData
from lnst.Controller.Machine import Machine
from lnst.Controller.SlaveMachineParser import SlaveMachineParser
from lnst.Controller.SlaveMachineParser import SlaveMachineError
+from lnst.Common.Colours import decorate_with_preset
class SlavePool:
"""
@@ -44,14 +45,38 @@ class SlavePool:
def __init__(self, pool_dirs, allow_virtual=False, pool_checks=True):
self._allow_virt = allow_virtual
self._pool_checks = pool_checks
+ logging.info("Checking machine pool availability.")
for pool_dir in pool_dirs:
self.add_dir(pool_dir)
def add_dir(self, pool_dir):
+ logging.info("Processing pool dir '%s'" % pool_dir)
dentries = os.listdir(pool_dir)
+ res = []
for dirent in dentries:
- self.add_file("%s/%s" % (pool_dir, dirent))
+ res.append(self.add_file("%s/%s" % (pool_dir, dirent)))
+
+ max_len = 0
+ for m_id, _ in res:
+ if len(m_id) > max_len:
+ max_len = len(m_id)
+ for m_id, available in res:
+ if available:
+ machine_spec = self._pool[m_id]
+ if 'libvirt_domain' in machine_spec['params']:
+ libvirt_msg = " libvirt_domain: %s" %\
+ machine_spec['params']['libvirt_domain']
+ else:
+ libvirt_msg = ""
+ msg = "%s%s [%s] %s" % (m_id, (max_len - len(m_id)) * " ",
+ decorate_with_preset("UP", "pass"),
+ libvirt_msg)
+ else:
+ msg = "%s%s [%s]" % (m_id, (max_len - len(m_id)) * " ",
+ decorate_with_preset("DOWN", "fail"))
+
+ logging.info(msg)
def add_file(self, filepath):
if os.path.isfile(filepath) and re.search("\.xml$", filepath, re.I):
@@ -63,25 +88,28 @@ class SlavePool:
machine_spec = self._process_machine_xml_data(m_id, xml_data)
if self._pool_checks:
+ available = False
+
hostname = machine_spec["params"]["hostname"]
if "rpcport" in machine_spec:
port = machine_spec["params"]["rpcport"]
else:
port = lnst_config.get_option('environment', 'rpcport')
- logging.info("Querying slave machine %s." % m_id)
- if not test_tcp_connection(hostname, port):
- msg = "Machine '%s' not responding. Skipping." % m_id
- logging.warning(msg)
- return
+ 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:
- msg = "libvird not running. Skipping machine '%s'." % m_id
- logging.warning(msg)
+ logging.debug("libvirtd not running. Removing "\
+ "libvirt_domain from machine '%s'" % m_id)
+ del machine_spec['params']['libvirt_domain']
- logging.info("Adding slave machine %s to slave pool." % m_id)
- self._pool[m_id] = machine_spec
+ if available:
+ self._pool[m_id] = machine_spec
+ return (m_id, available)
def _process_machine_xml_data(self, m_id, machine_xml_data):
machine_spec = {"interfaces": {}, "params":{}}
9 years, 6 months
[lnst] Config: print information about loading a conf file
by Jiří Pírko
commit 0a7f11748972e2ffe49095753d6d1b57f72099e4
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Thu Sep 19 10:24:19 2013 +0200
Config: print information about loading a conf file
We agreed that it would be a good idea to print information about loaded
config files. The original idea was to print this information to the
debug logs. However config files are loaded before logging is
initialized so that is not possible. Instead I used a simple print.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst-ctl | 1 -
lnst/Common/Config.py | 1 +
2 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/lnst-ctl b/lnst-ctl
index a51b2d6..ac71925 100755
--- a/lnst-ctl
+++ b/lnst-ctl
@@ -172,7 +172,6 @@ def main():
print "File '%s' doesn't exist!" % config_path
usage(RETVAL_ERR)
else:
- print "Loading config file '%s'" % config_path
lnst_config.load_config(config_path)
if coloured_output:
diff --git a/lnst/Common/Config.py b/lnst/Common/Config.py
index 8c749c4..3255311 100644
--- a/lnst/Common/Config.py
+++ b/lnst/Common/Config.py
@@ -135,6 +135,7 @@ class Config():
exp_path = os.path.expanduser(path)
abs_path = os.path.abspath(exp_path)
parser = ConfigParser(dict_type=dict)
+ print "Loading config file '%s'" % abs_path
parser.read(abs_path)
sections = parser._sections
9 years, 6 months
[lnst] Config: skip empty options
by Jiří Pírko
commit 9dd9b0bfaead4be775a3ec04456c62746785df05
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Thu Sep 19 09:34:59 2013 +0200
Config: skip empty options
When a config file contained an option with an empty value this would
override the value loaded from previous config files and set it to
nothing. This resulted in some very weird behaviour when resource caches
were not being synchronized.
This commit fixes the problem by skipping options with no values
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Common/Config.py | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
---
diff --git a/lnst/Common/Config.py b/lnst/Common/Config.py
index 40e70da..8c749c4 100644
--- a/lnst/Common/Config.py
+++ b/lnst/Common/Config.py
@@ -154,6 +154,8 @@ class Config():
config.pop('__name__', None)
for opt in config:
+ if not config[opt]:
+ continue
option = self._find_option_by_name(section, opt)
if option != None:
if option[1]: #additive?
9 years, 6 months
[PATCH] SlavePool: add information about pool machines
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
This commit changes how LNST presents information about loaded pool
machines.
* the query messages were moved to debug logs
* added info messages about which pool directory is being processed
* after a directory is loaded, a colorized summary of availability is
printed
I also adjusted what happens to virt machines when virtualization is
disabled but the machiens are available. In that case the libvirt_domain
attribute is ignored meaning that the machine will only be used in the
matching algorithm for static interfaces.
If a machine will be used in the dynamic interfaces matching algorithm
it will have its libvirt_domain printed in the summary described above.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/SlavePool.py | 48 +++++++++++++++++++++++++++++++++++---------
1 file changed, 38 insertions(+), 10 deletions(-)
diff --git a/lnst/Controller/SlavePool.py b/lnst/Controller/SlavePool.py
index d83de40..dbdd2be 100644
--- a/lnst/Controller/SlavePool.py
+++ b/lnst/Controller/SlavePool.py
@@ -25,6 +25,7 @@ from lnst.Common.XmlProcessing import XmlProcessingError, XmlData
from lnst.Controller.Machine import Machine
from lnst.Controller.SlaveMachineParser import SlaveMachineParser
from lnst.Controller.SlaveMachineParser import SlaveMachineError
+from lnst.Common.Colours import decorate_with_preset
class SlavePool:
"""
@@ -44,14 +45,38 @@ class SlavePool:
def __init__(self, pool_dirs, allow_virtual=False, pool_checks=True):
self._allow_virt = allow_virtual
self._pool_checks = pool_checks
+ logging.info("Checking machine pool availability.")
for pool_dir in pool_dirs:
self.add_dir(pool_dir)
def add_dir(self, pool_dir):
+ logging.info("Processing pool dir '%s'" % pool_dir)
dentries = os.listdir(pool_dir)
+ res = []
for dirent in dentries:
- self.add_file("%s/%s" % (pool_dir, dirent))
+ res.append(self.add_file("%s/%s" % (pool_dir, dirent)))
+
+ max_len = 0
+ for m_id, _ in res:
+ if len(m_id) > max_len:
+ max_len = len(m_id)
+ for m_id, available in res:
+ if available:
+ machine_spec = self._pool[m_id]
+ if 'libvirt_domain' in machine_spec['params']:
+ libvirt_msg = "libvirt_domain: %s" %\
+ machine_spec['params']['libvirt_domain']
+ msg = "%s%s [%s] %s" % (m_id,
+ (max_len - len(m_id))*" ",
+ decorate_with_preset("OK", "pass"),
+ libvirt_msg)
+ else:
+ msg = "%s%s [%s]" % (m_id,
+ (max_len - len(m_id))*" ",
+ decorate_with_preset("FAIL", "fail"))
+
+ logging.info(msg)
def add_file(self, filepath):
if os.path.isfile(filepath) and re.search("\.xml$", filepath, re.I):
@@ -63,25 +88,28 @@ class SlavePool:
machine_spec = self._process_machine_xml_data(m_id, xml_data)
if self._pool_checks:
+ available = False
+
hostname = machine_spec["params"]["hostname"]
if "rpcport" in machine_spec:
port = machine_spec["params"]["rpcport"]
else:
port = lnst_config.get_option('environment', 'rpcport')
- logging.info("Querying slave machine %s." % m_id)
- if not test_tcp_connection(hostname, port):
- msg = "Machine '%s' not responding. Skipping." % m_id
- logging.warning(msg)
- return
+ 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:
- msg = "libvird not running. Skipping machine '%s'." % m_id
- logging.warning(msg)
+ logging.debug("libvirtd not running. Removing "\
+ "libvirt_domain from machine '%s'" % m_id)
+ del machine_spec['params']['libvirt_domain']
- logging.info("Adding slave machine %s to slave pool." % m_id)
- self._pool[m_id] = machine_spec
+ if available:
+ self._pool[m_id] = machine_spec
+ return (m_id, available)
def _process_machine_xml_data(self, m_id, machine_xml_data):
machine_spec = {"interfaces": {}, "params":{}}
--
1.8.3.1
9 years, 6 months
[PATCH] Config: print information about loading a conf file
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
We agreed that it would be a good idea to print information about loaded
config files. The original idea was to print this information to the
debug logs. However config files are loaded before logging is
initialized so that is not possible. Instead I used a simple print.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst-ctl | 1 -
lnst/Common/Config.py | 1 +
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/lnst-ctl b/lnst-ctl
index a51b2d6..ac71925 100755
--- a/lnst-ctl
+++ b/lnst-ctl
@@ -172,7 +172,6 @@ def main():
print "File '%s' doesn't exist!" % config_path
usage(RETVAL_ERR)
else:
- print "Loading config file '%s'" % config_path
lnst_config.load_config(config_path)
if coloured_output:
diff --git a/lnst/Common/Config.py b/lnst/Common/Config.py
index 8c749c4..3255311 100644
--- a/lnst/Common/Config.py
+++ b/lnst/Common/Config.py
@@ -135,6 +135,7 @@ class Config():
exp_path = os.path.expanduser(path)
abs_path = os.path.abspath(exp_path)
parser = ConfigParser(dict_type=dict)
+ print "Loading config file '%s'" % abs_path
parser.read(abs_path)
sections = parser._sections
--
1.8.3.1
9 years, 6 months
Running LNST with python2.6
by Jan Tluka
Hi everyone,
thanks to Ondrej Lichtner, we now have a clear solution how to run LNST on
older distros, e.g. RHEL6 that come with python2.6.
There's no need to rebuild python2.7 as I previously suggested, simply use
the following command to get python-pyroute2:
# /bin/easy_install pyroute2
easy_install is included in python-setuptools.
Hope this helps,
Jan
9 years, 6 months
[PATCH] Config: skip empty options
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
When a config file contained an option with an empty value this would
override the value loaded from previous config files and set it to
nothing. This resulted in some very weird behaviour when resource caches
were not being synchronized.
This commit fixes the problem by skipping options with no values
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Common/Config.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lnst/Common/Config.py b/lnst/Common/Config.py
index 40e70da..8c749c4 100644
--- a/lnst/Common/Config.py
+++ b/lnst/Common/Config.py
@@ -154,6 +154,8 @@ class Config():
config.pop('__name__', None)
for opt in config:
+ if not config[opt]:
+ continue
option = self._find_option_by_name(section, opt)
if option != None:
if option[1]: #additive?
--
1.8.3.1
9 years, 6 months
[lnst] TestIperf: Fix typo in res_data assignment
by Jiří Pírko
commit 795bc5ddf01df7bada7540c6b8d9ba3c3b0abc2e
Author: Jan Tluka <jtluka(a)redhat.com>
Date: Wed Sep 18 17:06:09 2013 +0200
TestIperf: Fix typo in res_data assignment
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
test_modules/TestIperf.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/test_modules/TestIperf.py b/test_modules/TestIperf.py
index 5aacea1..a58104d 100644
--- a/test_modules/TestIperf.py
+++ b/test_modules/TestIperf.py
@@ -147,7 +147,7 @@ class TestIperf(TestGeneric):
elif role == "client":
logging.debug("running as client ...")
(rv, message) = self.run_client(cmd)
- res_data = {"msg": mesage}
+ res_data = {"msg": message}
if rv == False:
return self.set_fail(res_data)
9 years, 6 months
[PATCH] TestIperf: Fix typo in res_data assignment
by Jan Tluka
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
test_modules/TestIperf.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test_modules/TestIperf.py b/test_modules/TestIperf.py
index 5aacea1..a58104d 100644
--- a/test_modules/TestIperf.py
+++ b/test_modules/TestIperf.py
@@ -147,7 +147,7 @@ class TestIperf(TestGeneric):
elif role == "client":
logging.debug("running as client ...")
(rv, message) = self.run_client(cmd)
- res_data = {"msg": mesage}
+ res_data = {"msg": message}
if rv == False:
return self.set_fail(res_data)
--
1.8.1.4
9 years, 6 months
[lnst] remove generate-recipes.sh
by Jiří Pírko
commit 29eb20d2454b8b692e145c741dcd174bb5746299
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Wed Sep 18 15:54:29 2013 +0200
remove generate-recipes.sh
file no longer needed as it was replaced by the generate-recipes.py file
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
recipes/smoke/generate-recipes.sh | 62 -------------------------------------
1 files changed, 0 insertions(+), 62 deletions(-)
9 years, 6 months