[PATCH 2/2] RecipeParse: restrict bg_id usage

olichtne at redhat.com olichtne at redhat.com
Fri May 31 11:15:42 UTC 2013


From: Ondrej Lichtner <olichtne at redhat.com>

The previous commit changed the execution of the system_config command,
which now cannot run in the background as it would break the
application. This commit adds a check to the recipe parser that will not
allow bg_id to be used in commands of type system_config, wait, intr and
kill.

This commit also updates the recipe schema accordingly.

Signed-off-by: Ondrej Lichtner <olichtne at redhat.com>
---
 lnst/Controller/RecipeParse.py |  5 +++++
 recipe-schema.rng              | 48 ++++++++++++++++++++++++++++++++----------
 2 files changed, 42 insertions(+), 11 deletions(-)

diff --git a/lnst/Controller/RecipeParse.py b/lnst/Controller/RecipeParse.py
index 8cac525..d2d1171 100644
--- a/lnst/Controller/RecipeParse.py
+++ b/lnst/Controller/RecipeParse.py
@@ -458,6 +458,11 @@ class CommandParse(LnstParser):
         if self._has_attribute(node, "bg_id"):
             command["bg_id"] = self._get_attribute(node, "bg_id")
 
+            if command["type"] in ["system_config", "wait", "intr", "kill"]:
+                msg = "Command %s cannot be run in the background!" \
+                        % command["type"]
+                raise XmlProcessingError(msg, node)
+
         if self._has_attribute(node, "desc"):
             command["desc"] = self._get_attribute(node, "desc")
 
diff --git a/recipe-schema.rng b/recipe-schema.rng
index aa6d375..57445b4 100644
--- a/recipe-schema.rng
+++ b/recipe-schema.rng
@@ -319,7 +319,8 @@
                 <ref name="ctl_wait"/>
                 <ref name="exec"/>
                 <ref name="system_config"/>
-                <ref name="other_commands"/>
+                <ref name="test"/>
+                <ref name="control_commands"/>
             </choice>
 
             <optional>
@@ -386,10 +387,6 @@
         </attribute>
 
         <optional>
-            <attribute name="bg_id"/>
-        </optional>
-
-        <optional>
             <attribute name="value"/>
         </optional>
 
@@ -421,12 +418,45 @@
         </optional>
     </define>
 
-    <define name="other_commands">
+    <define name="test">
+        <attribute name="machine_id"/>
+
+        <attribute name="type">
+            <value>test</value>
+        </attribute>
+
+        <optional>
+            <attribute name="bg_id"/>
+        </optional>
+
+        <optional>
+            <attribute name="value"/>
+        </optional>
+
+        <optional>
+            <attribute name="timeout">
+                <data type="integer"/>
+            </attribute>
+        </optional>
+
+        <optional>
+            <attribute name="option"/>
+        </optional>
+
+        <optional>
+            <attribute name="desc"/>
+        </optional>
+
+        <optional>
+            <attribute name="source"/>
+        </optional>
+    </define>
+
+    <define name="control_commands">
         <attribute name="machine_id"/>
 
         <attribute name="type">
             <choice>
-                <value>test</value>
                 <value>wait</value>
                 <value>intr</value>
                 <value>kill</value>
@@ -434,10 +464,6 @@
         </attribute>
 
         <optional>
-            <attribute name="bg_id"/>
-        </optional>
-
-        <optional>
             <attribute name="value"/>
         </optional>
 
-- 
1.8.1.4



More information about the LNST-developers mailing list