[PATCH 1/4] lnst-pool-wizard: add _parse_host method
by Jiri Prochazka
this methods parses host in touple hostname,port. Created to avoid
code duplication when support for hostlist in interactive mode
will be released.
Signed-off-by: Jiri Prochazka <jprochaz(a)redhat.com>
---
lnst/Controller/Wizard.py | 46 ++++++++++++++++++++++++++++------------------
1 file changed, 28 insertions(+), 18 deletions(-)
diff --git a/lnst/Controller/Wizard.py b/lnst/Controller/Wizard.py
index 562efe1..a917949 100644
--- a/lnst/Controller/Wizard.py
+++ b/lnst/Controller/Wizard.py
@@ -96,24 +96,9 @@ class Wizard:
for host in hostlist:
print("Processing host '%s'" % host)
- # Check if port was entered along with hostname
- if host.find(":") != -1:
- hostname = host.split(":")[0]
- if hostname == "":
- msg = "'%s' does not contain valid hostname\n" % host
- sys.stderr.write(msg)
- sys.stderr.write("Skipping host '%s'\n" % host)
- continue
- try:
- port = int(host.split(":")[1])
- except:
- port = DefaultRPCPort
- msg = "Invalid port entered, "\
- "using '%s' instead\n" % port
- sys.stderr.write(msg)
- else:
- hostname = host
- port = DefaultRPCPort
+ hostname, port = self._parse_host(host)
+ if hostname == -1:
+ continue
if not self._check_hostname(hostname):
sys.stderr.write("Hostname '%s' is not translatable into a "
@@ -353,6 +338,31 @@ class Wizard:
if data["type"] == "result":
return data["result"]
+ def _parse_host(self, host):
+ """ Parses hostname:port string
+ @param host String where hostname and optionally port is stored
+ @return touple with string hostname and int port
+ """
+ if host.find(":") != -1:
+ hostname = host.split(":")[0]
+ if hostname == "":
+ msg = "'%s' does not contain valid hostname\n" % host
+ sys.stderr.write(msg)
+ sys.stderr.write("Skipping host '%s'\n" % host)
+ return -1, -1
+ try:
+ port = int(host.split(":")[1])
+ except:
+ port = DefaultRPCPort
+ msg = "Invalid port entered, "\
+ "using '%s' instead\n" % port
+ sys.stderr.write(msg)
+ else:
+ hostname = host
+ port = DefaultRPCPort
+
+ return hostname, port
+
def _query_continuation(self):
""" Queries user for adding next machine
@return True if user wants to add another machine, False otherwise
--
2.4.3
8 years, 3 months
[PATCH] use dump-pools option in regression-tests script
by Jan Tluka
We have recently changed handling of pool dirs and machine_pool_dirs is
no more available. The fix is to use lnst-ctl --dump-pools sent in
previous patch.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
regression-tests/run-test.sh | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/regression-tests/run-test.sh b/regression-tests/run-test.sh
index 329491e..fba47ca 100755
--- a/regression-tests/run-test.sh
+++ b/regression-tests/run-test.sh
@@ -59,9 +59,10 @@ function usage
function get_pool_dirs
{
if [ "$use_user_conf" = "true" ]; then
- command lnst-ctl --dump-config | grep 'machine_pool_dirs' | cut -d = -f2
+ command lnst-ctl --dump-pools 2>/dev/null | cut -d = -f2
else
- command lnst-ctl -c $repo/lnst-ctl.conf --dump-config | grep 'machine_pool_dirs' | cut -d = -f2
+ command lnst-ctl -c $repo/lnst-ctl.conf --dump-pools 2>/dev/null |
+ cut -d = -f2
fi
}
@@ -133,7 +134,7 @@ cp -r env/* $repo/
pool_dirs=`PATH="$repo:$PATH" get_pool_dirs`
# Scan the pool and prepare the machines in it
-for pool_dir in "$pool_dirs"; do
+for pool_dir in $pool_dirs; do
for machine in `ls -1 $pool_dir`; do
hostname=`get_hostname $pool_dir/$machine`
--
2.4.3
8 years, 3 months
[patch lnst] Task: add get_id method to HostAPI class
by Jiri Pirko
From: Jiri Pirko <jiri(a)mellanox.com>
If task needs to know machine id.
Signed-off-by: Jiri Pirko <jiri(a)mellanox.com>
---
lnst/Controller/Task.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lnst/Controller/Task.py b/lnst/Controller/Task.py
index e354180..3033960 100644
--- a/lnst/Controller/Task.py
+++ b/lnst/Controller/Task.py
@@ -190,6 +190,9 @@ class HostAPI(object):
self._bg_id_seq = 0
+ def get_id(self):
+ return self._m.get_id()
+
def config(self, option, value, persistent=False, netns=None):
"""
Configure an option in /sys or /proc on the host.
--
2.4.3
8 years, 3 months
[PATCH 1/3] setup.py: Add Custom module
by Ido Schimmel
Fixes: 30b3f0923de0 ("test_modules: introduce "Custom" test module")
Signed-off-by: Ido Schimmel <idosch(a)mellanox.com>
---
setup.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/setup.py b/setup.py
index c884ba9..7bc98b2 100755
--- a/setup.py
+++ b/setup.py
@@ -125,7 +125,8 @@ TEST_MODULES = [
"test_modules/PacketAssert.py",
"test_modules/PktCounter.py",
"test_modules/PktgenTx.py",
- "test_modules/LinkNeg.py"]
+ "test_modules/LinkNeg.py",
+ "test_modules/Custom.py"]
)
]
--
2.4.10
8 years, 3 months
[patch lnst] NetTestResultSerializer: check if desc is None
by Jiri Pirko
From: Jiri Pirko <jiri(a)mellanox.com>
Fixes: 23aca15b1 ("NetTestResultSerializer: include description of command in summary")
Signed-off-by: Jiri Pirko <jiri(a)mellanox.com>
---
lnst/Controller/NetTestResultSerializer.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lnst/Controller/NetTestResultSerializer.py b/lnst/Controller/NetTestResultSerializer.py
index 54390ff..fbe4392 100644
--- a/lnst/Controller/NetTestResultSerializer.py
+++ b/lnst/Controller/NetTestResultSerializer.py
@@ -156,7 +156,7 @@ class NetTestResultSerializer:
output_pairs.append((8*" " + m_id + cmd_res["res_header"], res))
- if "desc" in command:
+ if "desc" in command and command["desc"] != None:
output_pairs.append((12*" " + "description: " + command["desc"], ""))
if "msg" in cmd_res and cmd_res["msg"] != "":
--
2.4.3
8 years, 3 months
Running LNST on virtual setups without root user
by Jan Tluka
Hi, recently my colleague gave me a hint how to manage virtual machines
on the system using non-root user. It's very simple so I'd like to share
it here.
1. first you need to use policy kit to tweak libvirtd.
# echo 'polkit.addRule(function(action, subject) {
if (action.id == "org.libvirt.unix.manage" && subject.isInGroup("wheel")) {
return polkit.Result.YES;
}
});
' > /etc/polkit-1/rules.d/80-libvirt.rules
then (re)start libvirtd service,
# systemctl enable libvirtd
# systemctl start libvirtd
2. add the non-root user to group 'wheel'.
3. the last bit is to run lnst-ctl with following environment variable
exported:
LIBVIRT_DEFAULT_URI=qemu:///system lnst-ctl ...
Hope I did not forget anything. Feel free to ping me if this does not
work for you.
-Jan
8 years, 3 months
[PATCH v2] lnst-ctl: add parameter to dump available pools
by Jan Tluka
User can run lnst-ctl with parameter --dump-pools that will print
available machine pools based on config files.
V2: fixed forgotten initialization of dump_pools variable
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
lnst-ctl | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/lnst-ctl b/lnst-ctl
index bf97c1f..6d656f8 100755
--- a/lnst-ctl
+++ b/lnst-ctl
@@ -45,6 +45,8 @@ def usage(retval=0):
print " -d, --debug emit debugging messages"
print " --dump-config dumps the join of all loaded " \
"configuration files on stdout and exits"
+ print " --dump-pools dumps the available machine " \
+ "pools and exits"
print " -h, --help print this message"
print " -m, --no-colours disable coloured terminal output"
print " -o, --disable-pool-checks don't check the availability of " \
@@ -203,7 +205,8 @@ def main():
"html=",
"multi-match",
"result=",
- "pools="
+ "pools=",
+ "dump-pools"
]
)
except getopt.GetoptError as err:
@@ -243,6 +246,7 @@ def main():
reduce_sync = False
multi_match = False
dump_config = False
+ dump_pools = False
pools = []
for opt, arg in opts:
if opt in ("-d", "--debug"):
@@ -279,6 +283,8 @@ def main():
dump_config = True
elif opt in ("--pools"):
pools.extend(arg.split(","))
+ elif opt in ("--dump-pools"):
+ dump_pools = True
if xslt_url != None:
lnst_config.set_option("environment", "xslt_url", xslt_url)
@@ -287,6 +293,11 @@ def main():
print lnst_config.dump_config()
return RETVAL_PASS
+ if dump_pools:
+ for pool_name, pool_path in lnst_config.get_pools().items():
+ print pool_name + ' = ' + pool_path
+ return RETVAL_PASS
+
if coloured_output:
coloured_output = not lnst_config.get_option("colours",
"disable_colours")
--
2.4.3
8 years, 3 months
[PATCH] lnst-ctl: add parameter to dump available pools
by Jan Tluka
User can run lnst-ctl with parameter --dump-pools that will print
available machine pools based on config files.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
lnst-ctl | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/lnst-ctl b/lnst-ctl
index bf97c1f..e6be46f 100755
--- a/lnst-ctl
+++ b/lnst-ctl
@@ -45,6 +45,8 @@ def usage(retval=0):
print " -d, --debug emit debugging messages"
print " --dump-config dumps the join of all loaded " \
"configuration files on stdout and exits"
+ print " --dump-pools dumps the available machine " \
+ "pools and exits"
print " -h, --help print this message"
print " -m, --no-colours disable coloured terminal output"
print " -o, --disable-pool-checks don't check the availability of " \
@@ -203,7 +205,8 @@ def main():
"html=",
"multi-match",
"result=",
- "pools="
+ "pools=",
+ "dump-pools"
]
)
except getopt.GetoptError as err:
@@ -279,6 +282,8 @@ def main():
dump_config = True
elif opt in ("--pools"):
pools.extend(arg.split(","))
+ elif opt in ("--dump-pools"):
+ dump_pools = True
if xslt_url != None:
lnst_config.set_option("environment", "xslt_url", xslt_url)
@@ -287,6 +292,11 @@ def main():
print lnst_config.dump_config()
return RETVAL_PASS
+ if dump_pools:
+ for pool_name, pool_path in lnst_config.get_pools().items():
+ print pool_name + ' = ' + pool_path
+ return RETVAL_PASS
+
if coloured_output:
coloured_output = not lnst_config.get_option("colours",
"disable_colours")
--
2.4.3
8 years, 3 months
[PATCH 2/2] result_xslt: add command description to html output
by Jan Tluka
Html output now contains command description if it was specified when running
command.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
result_xslt/xml_to_html.xsl | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/result_xslt/xml_to_html.xsl b/result_xslt/xml_to_html.xsl
index c31de36..d1e8acc 100644
--- a/result_xslt/xml_to_html.xsl
+++ b/result_xslt/xml_to_html.xsl
@@ -21,7 +21,7 @@
<xsl:apply-templates select="pool_match"/>
<table class="lnst_results">
<tr><th colspan="5">Task</th></tr>
- <tr><th>Host</th><th>Bg ID</th><th>Command</th><th>Result</th><th>Result message</th></tr>
+ <tr><th>Host</th><th>Bg ID</th><th>Command</th><th>Result</th><th>Result message</th><th>Description</th></tr>
<xsl:apply-templates select="task"/>
</table>
</xsl:template>
@@ -75,7 +75,7 @@
</xsl:template>
<xsl:template match="task">
- <tr class="task_header"><th colspan="5">Task <xsl:value-of select="position()"/></th></tr>
+ <tr class="task_header"><th colspan="6">Task <xsl:value-of select="position()"/></th></tr>
<xsl:apply-templates select="command">
<xsl:with-param name="task_id" select="position()"/>
</xsl:apply-templates>
@@ -115,6 +115,11 @@
</xsl:choose>
<xsl:apply-templates select="result"/>
+ <td>
+ <xsl:if test="@desc">
+ <xsl:value-of select="@desc"/>
+ </xsl:if>
+ </td>
</tr>
<xsl:call-template name="res_data">
--
2.4.3
8 years, 3 months
[PATCH 1/2] NetTestResultSerializer: include description of command
in summary
by Jan Tluka
User specified description is printed in log only. It's more useful to
include this also in summary report.
The output will be similar to this:
INFO: host 1: exec cmd: "sleep 1" PASS
INFO: description: short sleep to give some time to settle
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
lnst/Controller/NetTestResultSerializer.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lnst/Controller/NetTestResultSerializer.py b/lnst/Controller/NetTestResultSerializer.py
index 3650981..54390ff 100644
--- a/lnst/Controller/NetTestResultSerializer.py
+++ b/lnst/Controller/NetTestResultSerializer.py
@@ -156,6 +156,9 @@ class NetTestResultSerializer:
output_pairs.append((8*" " + m_id + cmd_res["res_header"], res))
+ if "desc" in command:
+ output_pairs.append((12*" " + "description: " + command["desc"], ""))
+
if "msg" in cmd_res and cmd_res["msg"] != "":
output_pairs.append((12*" " + "message: " + cmd_res["msg"], ""))
--
2.4.3
8 years, 3 months