[PATCH v2] ResultSerializer: update summary formatting
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
There are two updates to summary formating in this commit:
* shorten the alignment of command types to -9 from -14 the reason is
* that the longes command type is now 'ctl_wait' instead of
* 'system_config'
* add machine identification to each command in the format:
* 'machine id: cmd_type'
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Common/NetTestCommand.py | 8 ++++----
lnst/Common/TestsCommon.py | 2 +-
lnst/Controller/NetTestController.py | 2 +-
lnst/Controller/NetTestResultSerializer.py | 19 ++++++++++++++++---
4 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/lnst/Common/NetTestCommand.py b/lnst/Common/NetTestCommand.py
index abfa71a..47a3e4a 100644
--- a/lnst/Common/NetTestCommand.py
+++ b/lnst/Common/NetTestCommand.py
@@ -344,7 +344,7 @@ class NetTestCommandGeneric:
raise CommandException(msg)
def _format_cmd_res_header(self):
- return "%-14s" % self._command["type"]
+ return "%-9s" % self._command["type"]
def set_handle_intr(self):
pass
@@ -383,11 +383,11 @@ class NetTestCommandExec(NetTestCommandGeneric):
cmd_val = self._command["command"]
if "bg_id" in self._command:
- bg_id = " bg_id: %s" % self._command["bg_id"]
+ bg_id = "bg_id: %s " % self._command["bg_id"]
else:
bg_id = ""
- cmd = "%-14s%s cmd: \"%s\"" %(cmd_type, bg_id, cmd_val)
+ cmd = "%-9s%scmd: \"%s\"" %(cmd_type, bg_id, cmd_val)
return cmd
class NetTestCommandConfig(NetTestCommandGeneric):
@@ -454,7 +454,7 @@ class NetTestCommandControl(NetTestCommandGeneric):
def _format_cmd_res_header(self):
cmd_type = self._command["type"]
cmd_val = self._command["proc_id"]
- cmd = "%-14s id: %s" % (cmd_type, cmd_val)
+ cmd = "%-9sid: %s" % (cmd_type, cmd_val)
return cmd
class NetTestCommandWait(NetTestCommandControl):
diff --git a/lnst/Common/TestsCommon.py b/lnst/Common/TestsCommon.py
index 01ae678..8086121 100644
--- a/lnst/Common/TestsCommon.py
+++ b/lnst/Common/TestsCommon.py
@@ -146,5 +146,5 @@ class TestGeneric(NetTestCommandGeneric):
bg_id = " bg_id: %s" % self._command["bg_id"]
else:
bg_id = ""
- cmd = "%-14s%s%s" %(cmd_type, cmd_val, bg_id)
+ cmd = "%-9s%s%s" %(cmd_type, cmd_val, bg_id)
return cmd
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index ad5a2df..348c064 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -653,7 +653,7 @@ class NetTestController:
if command["type"] == "ctl_wait":
sleep(command["seconds"])
cmd_res = {"passed": True,
- "res_header": "%-14s%ss" % ("ctl_wait",
+ "res_header": "%-9s%ss" % ("ctl_wait",
command["seconds"]),
"msg": "",
"res_data": None}
diff --git a/lnst/Controller/NetTestResultSerializer.py b/lnst/Controller/NetTestResultSerializer.py
index 9c26dfc..7f2e6d1 100644
--- a/lnst/Controller/NetTestResultSerializer.py
+++ b/lnst/Controller/NetTestResultSerializer.py
@@ -84,17 +84,30 @@ class NetTestResultSerializer:
seq_num += 1
+ m_id_max = 0
for cmd, cmd_res in task:
- self._format_command(cmd, cmd_res, output_pairs)
+ if "machine" in cmd and\
+ len(cmd["machine"]) > m_id_max:
+ m_id_max = len(cmd["machine"])
+ for cmd, cmd_res in task:
+ self._format_command(cmd, cmd_res, output_pairs, m_id_max)
self._print_pairs(output_pairs)
- def _format_command(self, command, cmd_res, output_pairs):
+ def _format_command(self, command, cmd_res, output_pairs, m_id_max):
if cmd_res["passed"]:
res = "PASS"
else:
res = "FAIL"
- output_pairs.append((8*" " + cmd_res["res_header"], res))
+
+ if "machine" in command:
+ m_id = "host %s: " % command["machine"]
+ m_id += " " * (m_id_max - len(command["machine"]))
+ else:
+ #len("ctl") == 3; len("host ") == 5; 5-3 = 2
+ m_id = "ctl: " + " " * (m_id_max + 2)
+
+ output_pairs.append((8*" " + m_id + cmd_res["res_header"], res))
if "msg" in cmd_res and cmd_res["msg"] != "":
output_pairs.append((12*" " + "message: " + cmd_res["msg"], ""))
--
1.8.5.3
10 years
[lnst] InterfaceManager: send device update messages to ctl
by Jiří Pírko
commit 0eafd74d0aedc6b02f9efbe92a1fae75eb052a71
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Mon Mar 17 14:04:18 2014 +0100
InterfaceManager: send device update messages to ctl
This commit makes the InterfaceManager send update messages to the
controller. These contain changes in devname and hwaddress of network
devices. This fixes the regression that controller would use old
information when resolving template functions.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Controller/Machine.py | 13 +++++++------
lnst/Slave/InterfaceManager.py | 20 +++++++++++++++++---
lnst/Slave/NetTestSlave.py | 4 ++--
3 files changed, 26 insertions(+), 11 deletions(-)
---
diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py
index d73aedd..a849e3b 100644
--- a/lnst/Controller/Machine.py
+++ b/lnst/Controller/Machine.py
@@ -85,12 +85,13 @@ class Machine(object):
return iface
def interface_update(self, if_data):
- for iface in self._interfaces:
- try:
- if iface.get_devname() == if_data["devname"]:
- iface.set_hwaddr(if_data["hwaddr"])
- except:
- pass
+ try:
+ iface = self.get_interface(if_data["if_id"])
+ except:
+ iface = None
+ if iface:
+ iface.set_hwaddr(if_data["hwaddr"])
+ iface.set_devname(if_data["devname"])
#
# Factory methods for constructing interfaces on this machine. The
diff --git a/lnst/Slave/InterfaceManager.py b/lnst/Slave/InterfaceManager.py
index c120555..a69e4d4 100644
--- a/lnst/Slave/InterfaceManager.py
+++ b/lnst/Slave/InterfaceManager.py
@@ -26,7 +26,7 @@ class IfMgrError(Exception):
pass
class InterfaceManager(object):
- def __init__(self):
+ def __init__(self, server_handler):
self._devices = {}
self._id_mapping = {} #id from the ctl to device
@@ -35,6 +35,8 @@ class InterfaceManager(object):
self.rescan_devices()
+ self._server_handler = server_handler
+
def map_if(self, if_id, if_index):
if if_id in self._id_mapping:
raise IfMgrError("Interface already mapped.")
@@ -67,7 +69,14 @@ class InterfaceManager(object):
def _handle_netlink_msg(self, msg):
if msg['header']['type'] == RTM_NEWLINK:
if msg['index'] in self._devices:
- self._devices[msg['index']].update_netlink(msg)
+ update_msg = self._devices[msg['index']].update_netlink(msg)
+ if update_msg != None:
+ for if_id, dev in self._id_mapping.iteritems():
+ if dev.get_if_index() == msg['index']:
+ update_msg["if_id"] = if_id
+ break
+ if "if_id" in update_msg:
+ self._server_handler.send_data_to_ctl(update_msg)
else:
dev = None
for d in self._id_mapping.values():
@@ -194,7 +203,12 @@ class Device(object):
self._name = nl_msg.get_attr("IFLA_IFNAME")
self._ip = None #TODO
self._master = nl_msg.get_attr("IFLA_MASTER")
- #send update msg
+
+ #return an update message that will be sent to the controller
+ return {"type": "if_update",
+ "devname": self._name,
+ "hwaddr": self._hwaddr}
+ return None
def get_if_index(self):
return self._if_index
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index ef9e6ad..729878b 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -417,10 +417,10 @@ class NetTestSlave:
die_when_parent_die()
self._cmd_context = NetTestCommandContext()
- self._if_manager = InterfaceManager()
+ self._server_handler = ServerHandler(("", port))
+ self._if_manager = InterfaceManager(self._server_handler)
self._methods = SlaveMethods(self._cmd_context, log_ctl,
self._if_manager)
- self._server_handler = ServerHandler(("", port))
self.register_die_signal(signal.SIGHUP)
self.register_die_signal(signal.SIGINT)
10 years
[PATCH] InterfaceManager: send device update messages to ctl
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
This commit makes the InterfaceManager send update messages to the
controller. These contain changes in devname and hwaddress of network
devices. This fixes the regression that controller would use old
information when resolving template functions.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/Machine.py | 13 +++++++------
lnst/Slave/InterfaceManager.py | 20 +++++++++++++++++---
lnst/Slave/NetTestSlave.py | 4 ++--
3 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py
index d73aedd..a849e3b 100644
--- a/lnst/Controller/Machine.py
+++ b/lnst/Controller/Machine.py
@@ -85,12 +85,13 @@ class Machine(object):
return iface
def interface_update(self, if_data):
- for iface in self._interfaces:
- try:
- if iface.get_devname() == if_data["devname"]:
- iface.set_hwaddr(if_data["hwaddr"])
- except:
- pass
+ try:
+ iface = self.get_interface(if_data["if_id"])
+ except:
+ iface = None
+ if iface:
+ iface.set_hwaddr(if_data["hwaddr"])
+ iface.set_devname(if_data["devname"])
#
# Factory methods for constructing interfaces on this machine. The
diff --git a/lnst/Slave/InterfaceManager.py b/lnst/Slave/InterfaceManager.py
index c120555..a69e4d4 100644
--- a/lnst/Slave/InterfaceManager.py
+++ b/lnst/Slave/InterfaceManager.py
@@ -26,7 +26,7 @@ class IfMgrError(Exception):
pass
class InterfaceManager(object):
- def __init__(self):
+ def __init__(self, server_handler):
self._devices = {}
self._id_mapping = {} #id from the ctl to device
@@ -35,6 +35,8 @@ class InterfaceManager(object):
self.rescan_devices()
+ self._server_handler = server_handler
+
def map_if(self, if_id, if_index):
if if_id in self._id_mapping:
raise IfMgrError("Interface already mapped.")
@@ -67,7 +69,14 @@ class InterfaceManager(object):
def _handle_netlink_msg(self, msg):
if msg['header']['type'] == RTM_NEWLINK:
if msg['index'] in self._devices:
- self._devices[msg['index']].update_netlink(msg)
+ update_msg = self._devices[msg['index']].update_netlink(msg)
+ if update_msg != None:
+ for if_id, dev in self._id_mapping.iteritems():
+ if dev.get_if_index() == msg['index']:
+ update_msg["if_id"] = if_id
+ break
+ if "if_id" in update_msg:
+ self._server_handler.send_data_to_ctl(update_msg)
else:
dev = None
for d in self._id_mapping.values():
@@ -194,7 +203,12 @@ class Device(object):
self._name = nl_msg.get_attr("IFLA_IFNAME")
self._ip = None #TODO
self._master = nl_msg.get_attr("IFLA_MASTER")
- #send update msg
+
+ #return an update message that will be sent to the controller
+ return {"type": "if_update",
+ "devname": self._name,
+ "hwaddr": self._hwaddr}
+ return None
def get_if_index(self):
return self._if_index
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index dca0a59..eb1dcc9 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -417,10 +417,10 @@ class NetTestSlave:
die_when_parent_die()
self._cmd_context = NetTestCommandContext()
- self._if_manager = InterfaceManager()
+ self._server_handler = ServerHandler(("", port))
+ self._if_manager = InterfaceManager(self._server_handler)
self._methods = SlaveMethods(self._cmd_context, log_ctl,
self._if_manager)
- self._server_handler = ServerHandler(("", port))
self.register_die_signal(signal.SIGHUP)
self.register_die_signal(signal.SIGINT)
--
1.8.5.3
10 years
[lnst] fix incorrect handling of config command failure
by Jiří Pírko
commit ab32ea9906ee8ab4752b8c661969c1a26c088b4e
Author: Jan Tluka <jtluka(a)redhat.com>
Date: Tue Mar 11 18:41:56 2014 +0100
fix incorrect handling of config command failure
The patch fixes an unhandled exception in case a config command fails.
Instead of overwriting res_data we have to append to it since other keys
are expected to be there, even empty. Further, NetTestSlave expects that
run() method returns a result that's referenced later. I've also changed
"msg" key to "err_msg" since the latter is used in NetTestSlave.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Common/NetTestCommand.py | 10 ++++------
lnst/Slave/NetTestSlave.py | 2 +-
2 files changed, 5 insertions(+), 7 deletions(-)
---
diff --git a/lnst/Common/NetTestCommand.py b/lnst/Common/NetTestCommand.py
index 5b12221..abfa71a 100644
--- a/lnst/Common/NetTestCommand.py
+++ b/lnst/Common/NetTestCommand.py
@@ -411,18 +411,16 @@ class NetTestCommandConfig(NetTestCommandGeneric):
option_abspath[0:6] != "/proc/":
err = "Wrong config option %s. Only /proc or /sys paths are " \
"allowed." % option
- res_data = {"msg": err}
- self.set_fail(res_data)
- return
+ res_data["err_msg"] = err
+ return self.set_fail(res_data)
try:
prev_val = self._retrive_option(option)
self._set_option(option, value)
except ExecCmdFail:
err = "Unable to set %s config option!" % option
- res_data = {"msg": err}
- self.set_fail(res_data)
- return
+ res_data["err_msg"] = err
+ return self.set_fail(res_data)
if "persistent" in self._command:
res_data["persistent"] = self._command["persistent"]
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index dca0a59..ef9e6ad 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -239,7 +239,7 @@ class SlaveMethods:
command["persistent"])
else:
err = "Error occured while setting system "\
- "configuration (%s)" % res["err_msg"]
+ "configuration (%s)" % res["res_data"]["err_msg"]
logging.error(err)
return res
10 years
[PATCH] fix incorrect handling of config command failure
by Jan Tluka
The patch fixes an unhandled exception in case a config command fails.
Instead of overwriting res_data we have to append to it since other keys
are expected to be there, even empty. Further, NetTestSlave expects that
run() method returns a result that's referenced later. I've also changed
"msg" key to "err_msg" since the latter is used in NetTestSlave.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
lnst/Common/NetTestCommand.py | 10 ++++------
lnst/Slave/NetTestSlave.py | 2 +-
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/lnst/Common/NetTestCommand.py b/lnst/Common/NetTestCommand.py
index 5b12221..abfa71a 100644
--- a/lnst/Common/NetTestCommand.py
+++ b/lnst/Common/NetTestCommand.py
@@ -411,18 +411,16 @@ class NetTestCommandConfig(NetTestCommandGeneric):
option_abspath[0:6] != "/proc/":
err = "Wrong config option %s. Only /proc or /sys paths are " \
"allowed." % option
- res_data = {"msg": err}
- self.set_fail(res_data)
- return
+ res_data["err_msg"] = err
+ return self.set_fail(res_data)
try:
prev_val = self._retrive_option(option)
self._set_option(option, value)
except ExecCmdFail:
err = "Unable to set %s config option!" % option
- res_data = {"msg": err}
- self.set_fail(res_data)
- return
+ res_data["err_msg"] = err
+ return self.set_fail(res_data)
if "persistent" in self._command:
res_data["persistent"] = self._command["persistent"]
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index dca0a59..ef9e6ad 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -239,7 +239,7 @@ class SlaveMethods:
command["persistent"])
else:
err = "Error occured while setting system "\
- "configuration (%s)" % res["err_msg"]
+ "configuration (%s)" % res["res_data"]["err_msg"]
logging.error(err)
return res
--
1.8.1.4
10 years
[lnst] lnst-ctl man page add -r and deconfigure
by Jiří Pírko
commit 680c89b4c2098dd5ff48e0929444f8f378e3968f
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Tue Mar 4 12:53:15 2014 +0100
lnst-ctl man page add -r and deconfigure
This commit updates the lnst-ctl manual page to contain information on
the newly added deconfigure action and the -r (--reduce-sync) option.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
install/lnst-ctl.1.in | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/install/lnst-ctl.1.in b/install/lnst-ctl.1.in
index 97a186b..39064f2 100644
--- a/install/lnst-ctl.1.in
+++ b/install/lnst-ctl.1.in
@@ -52,6 +52,12 @@ during the test.
.BI "\-x, \-\-result" =file
Write results in XML format to the specified
.IR file .
+.TP
+.B "\-r, \-\-reduce-sync"
+Disable synchronization of module and tool resources to slave machines,
+when python tasks are used in the recipe. Instead the user can manually
+synchronize resources from the python task itself. This option has no effect if
+the recipe only contains xml tasks.
.PP
.I RECIPE
can be either a LNST recipe file or a directory containing recipe files.
@@ -64,7 +70,8 @@ bellow).
.I ACTION
can be one of
.BR "run",
-.BR "config_only" ", and"
+.BR "config_only",
+.BR "deconfigure" ", and"
.BR "match_setup".
When it is set to
@@ -81,6 +88,12 @@ cleanup phase is omitted as well. This mode of operation is useful if you
want to perform some specific actions or tests outside of LNST using
the configuration specified in a recipe file.
+In case of
+.BR "deconfigure",
+the configuration from a previous config_only run will be removed, including
+dynamically created devices on virtual machines. There is no need to specify a
+recipe for this action.
+
At last, when the
.I ACTION
is set to
10 years
[PATCH] lnst-ctl man page add -r and deconfigure
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
This commit updates the lnst-ctl manual page to contain information on
the newly added deconfigure action and the -r (--reduce-sync) option.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
install/lnst-ctl.1.in | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/install/lnst-ctl.1.in b/install/lnst-ctl.1.in
index 97a186b..39064f2 100644
--- a/install/lnst-ctl.1.in
+++ b/install/lnst-ctl.1.in
@@ -52,6 +52,12 @@ during the test.
.BI "\-x, \-\-result" =file
Write results in XML format to the specified
.IR file .
+.TP
+.B "\-r, \-\-reduce-sync"
+Disable synchronization of module and tool resources to slave machines,
+when python tasks are used in the recipe. Instead the user can manually
+synchronize resources from the python task itself. This option has no effect if
+the recipe only contains xml tasks.
.PP
.I RECIPE
can be either a LNST recipe file or a directory containing recipe files.
@@ -64,7 +70,8 @@ bellow).
.I ACTION
can be one of
.BR "run",
-.BR "config_only" ", and"
+.BR "config_only",
+.BR "deconfigure" ", and"
.BR "match_setup".
When it is set to
@@ -81,6 +88,12 @@ cleanup phase is omitted as well. This mode of operation is useful if you
want to perform some specific actions or tests outside of LNST using
the configuration specified in a recipe file.
+In case of
+.BR "deconfigure",
+the configuration from a previous config_only run will be removed, including
+dynamically created devices on virtual machines. There is no need to specify a
+recipe for this action.
+
At last, when the
.I ACTION
is set to
--
1.8.5.3
10 years
[lnst] NetTestController: add support for {module,tools}_dir
by Jiří Pírko
commit 617f770b2473e89a7dbc0545f1e37b92723d1010
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Mon Mar 3 16:00:42 2014 +0100
NetTestController: add support for {module,tools}_dir
This commit adds support for searching additional resource directories
specified by the module_dir and tools_dir attributes.
We create a deep copy of the original resource table and then update it
with the newly found modules or tools. After the task is processed we
restore the original resource table.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Controller/NetTestController.py | 29 ++++++++++++++++++++++++++++-
1 files changed, 28 insertions(+), 1 deletions(-)
---
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index 5adc8e9..ad5a2df 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -18,6 +18,7 @@ import re
import cPickle
import tempfile
import imp
+import copy
from time import sleep
from xmlrpclib import Binary
from lnst.Common.NetUtils import MacPool
@@ -217,10 +218,17 @@ class NetTestController:
recipe_name = os.path.basename(self._recipe_path)
machine.configure(recipe_name)
- res_table = self._resource_table
sync_table = {'module': {}, 'tools': {}}
if resource_sync:
for task in self._recipe['tasks']:
+ res_table = copy.deepcopy(self._resource_table)
+ if 'module_dir' in task:
+ modules = self._load_test_modules([task['module_dir']])
+ res_table['module'].update(modules)
+ if 'tools_dir' in task:
+ tools = self._load_test_tools([task['tools_dir']])
+ res_table['tools'].update(tools)
+
if 'commands' not in task:
if not self._reduce_sync:
sync_table = res_table
@@ -284,6 +292,12 @@ class NetTestController:
if "quit_on_fail" in task_data:
task["quit_on_fail"] = bool_it(task_data["quit_on_fail"])
+ if "module_dir" in task_data:
+ task["module_dir"] = task_data["module_dir"]
+
+ if "tools_dir" in task_data:
+ task["tools_dir"] = task_data["tools_dir"]
+
if "python" in task_data:
root = RecipePath(None, self._recipe_path).get_root()
path = "%s/%s" % (root, task_data["python"])
@@ -597,11 +611,24 @@ class NetTestController:
return overall_res
def _run_python_task(self, task):
+ #backup of resource table
+ res_table_bkp = copy.deepcopy(self._resource_table)
+ if 'module_dir' in task:
+ modules = self._load_test_modules([task['module_dir']])
+ self._resource_table['module'].update(modules)
+ if 'tools_dir' in task:
+ tools = self._load_test_tools([task['tools_dir']])
+ self._resource_table['tools'].update(tools)
+
# Initialize the API handle
Task.ctl = Task.ControllerAPI(self, self._machines)
name = os.path.basename(task["python"]).split(".")[0]
module = imp.load_source(name, task["python"])
+
+ #restore resource table
+ self._resource_table = res_table_bkp
+
return module.ctl._result
def _run_task(self, task):
10 years
[lnst] recipe xml format: add module_dir and tools_dir attributes
by Jiří Pírko
commit 793ca7ce20a1bb07974e8a468eeb5c641d0aa9a4
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Mon Mar 3 16:00:41 2014 +0100
recipe xml format: add module_dir and tools_dir attributes
These attributes can be used in <task> elements to specify additional
directory paths that should be searched for module and tool resources.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Controller/RecipeParser.py | 16 ++++++++++++++++
schema-recipe.rng | 16 ++++++++++++++++
2 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/lnst/Controller/RecipeParser.py b/lnst/Controller/RecipeParser.py
index 2e178e8..e3b6df9 100644
--- a/lnst/Controller/RecipeParser.py
+++ b/lnst/Controller/RecipeParser.py
@@ -152,6 +152,22 @@ class RecipeParser(XmlParser):
if self._has_attribute(task_tag, "quit_on_fail"):
task["quit_on_fail"] = self._get_attribute(task_tag, "quit_on_fail")
+ if self._has_attribute(task_tag, "module_dir"):
+ base_dir = os.path.dirname(task_tag.attrib["__file"])
+ dir_path = str(self._get_attribute(task_tag, "module_dir"))
+ exp_path = os.path.expanduser(dir_path)
+ abs_path = os.path.join(base_dir, exp_path)
+ norm_path = os.path.normpath(abs_path)
+ task["module_dir"] = norm_path
+
+ if self._has_attribute(task_tag, "tools_dir"):
+ base_dir = os.path.dirname(task_tag.attrib["__file"])
+ dir_path = str(self._get_attribute(task_tag, "tools_dir"))
+ exp_path = os.path.expanduser(dir_path)
+ abs_path = os.path.join(base_dir, exp_path)
+ norm_path = os.path.normpath(abs_path)
+ task["tools_dir"] = norm_path
+
if self._has_attribute(task_tag, "python"):
task["python"] = self._get_attribute(task_tag, "python")
return task
diff --git a/schema-recipe.rng b/schema-recipe.rng
index 7803849..129d7e7 100644
--- a/schema-recipe.rng
+++ b/schema-recipe.rng
@@ -59,6 +59,14 @@
</choice>
</attribute>
</optional>
+
+ <optional>
+ <attribute name="module_dir"/>
+ </optional>
+
+ <optional>
+ <attribute name="tools_dir"/>
+ </optional>
</element>
<ref name="xml_task"/>
</choice>
@@ -81,6 +89,14 @@
</attribute>
</optional>
+ <optional>
+ <attribute name="module_dir"/>
+ </optional>
+
+ <optional>
+ <attribute name="tools_dir"/>
+ </optional>
+
<oneOrMore>
<choice>
<ref name="run"/>
10 years
[lnst] XmlParser: save full filename in element objects
by Jiří Pírko
commit 6e10ff9206e8b114352a745a634e2d3107ad7746
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Mon Mar 3 16:00:40 2014 +0100
XmlParser: save full filename in element objects
I'm not exactly sure why we would only store the full path in the root
element and the following elements would only use the basename of the
file. This comit changes that so that the absolute path is stored in all
element objects.
This will be usefull when figuring out the point of reference for
non xinclude attributes that refer to files.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Controller/XmlParser.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/lnst/Controller/XmlParser.py b/lnst/Controller/XmlParser.py
index 32bbf2a..a342cf4 100644
--- a/lnst/Controller/XmlParser.py
+++ b/lnst/Controller/XmlParser.py
@@ -161,7 +161,7 @@ class XmlParser(object):
elem.attrib["__file"] = filename
for e in elem:
- self._init_loc(e, os.path.basename(filename))
+ self._init_loc(e, filename)
return elem
10 years