commit e640b88ae10dfdbd85bd937bf42132f41d76fe11 Author: Ondrej Lichtner olichtne@redhat.com Date: Tue Sep 9 15:59:26 2014 +0200
signal commands no longer use the netns attribute
This patch improves the usability of signal commands by storing information about running background commands of the machine. The controller can then use this information to send the signal command to the correct network namespace without requiring this information from the user. Because of this the 'netns' attribute (recipe) is no longer accepted for signal commands.
RecipeParser also sets the 'netns' attribute of the internal command structure to the default value 'None'.
Signed-off-by: Ondrej Lichtner olichtne@redhat.com Signed-off-by: Jiri Pirko jiri@resnulli.us
lnst/Controller/Machine.py | 8 ++++++++ lnst/Controller/RecipeParser.py | 1 + schema-recipe.rng | 4 ---- 3 files changed, 9 insertions(+), 4 deletions(-) --- diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py index 1fab2ac..62a23e3 100644 --- a/lnst/Controller/Machine.py +++ b/lnst/Controller/Machine.py @@ -71,6 +71,7 @@ class Machine(object):
self._interfaces = [] self._namespaces = [] + self._bg_cmds = {}
def _add_interface(self, if_id, if_type, cls): if if_id != None: @@ -247,6 +248,13 @@ class Machine(object):
prev_handler = signal.signal(signal.SIGALRM, self._timeout_handler)
+ if 'bg_id' in command: + self._bg_cmds[command['bg_id']] = command + if command["type"] in ["wait", "intr", "kill"]: + bg_cmd = self._bg_cmds[command["proc_id"]] + if bg_cmd["netns"] != None: + command["netns"] = bg_cmd["netns"] + if command["type"] == "wait": logging.debug("Get remaining time of bg process with bg_id == %s" % command["proc_id"]) diff --git a/lnst/Controller/RecipeParser.py b/lnst/Controller/RecipeParser.py index 159b1bc..c68fe54 100644 --- a/lnst/Controller/RecipeParser.py +++ b/lnst/Controller/RecipeParser.py @@ -396,4 +396,5 @@ class RecipeParser(XmlParser): cmd["type"] = cmd_tag.tag cmd["host"] = self._get_attribute(cmd_tag, "host") cmd["bg_id"] = self._get_attribute(cmd_tag, "bg_id") + cmd["netns"] = None return cmd diff --git a/schema-recipe.rng b/schema-recipe.rng index 490b86b..2391085 100644 --- a/schema-recipe.rng +++ b/schema-recipe.rng @@ -578,10 +578,6 @@ <define name="signal_command"> <attribute name="host"/> <attribute name="bg_id"/> - - <optional> - <attribute name="netns"/> - </optional> </define>
<define name="ctl_wait">