[netcf-devel] [PATCH 1/1] schema: move addressing related elements into <protocol> tag

David Lutterkort lutter at redhat.com
Sat Jun 20 00:31:14 UTC 2009


  * data/xml/interface.rng (interface-addressing): use <protocol> container
    tag
  * data/xml/initscripts-get.xsl (interface-addressing): look for
    <ip>, <dhcp>, and <route> in <protocol family="ipv4"> container
  * data/xml/initscripts-put.xsl (interface-addressing): produce
    <protocol> container for IPv4 address related elements
  * tests/interface/*.xml: adjust to new schema
---
 data/xml/initscripts-get.xsl                  |    6 +++
 data/xml/initscripts-put.xsl                  |   48 ++++++++++++++-----------
 data/xml/interface.rng                        |   28 ++++++++++----
 tests/interface/bond-arp.xml                  |    6 ++-
 tests/interface/bond.xml                      |    6 ++-
 tests/interface/bridge.xml                    |    4 ++-
 tests/interface/ethernet-dhcp.xml             |    4 ++-
 tests/interface/ethernet-static-no-prefix.xml |    6 ++-
 tests/interface/ethernet-static.xml           |    6 ++-
 9 files changed, 75 insertions(+), 39 deletions(-)

diff --git a/data/xml/initscripts-get.xsl b/data/xml/initscripts-get.xsl
index 9eca3e7..ef8a5d8 100644
--- a/data/xml/initscripts-get.xsl
+++ b/data/xml/initscripts-get.xsl
@@ -131,6 +131,12 @@
   </xsl:template>
 
   <xsl:template name="interface-addressing">
+    <xsl:for-each select="protocol[@family='ipv4']">
+      <xsl:call-template name="protocol-ipv4"/>
+    </xsl:for-each>
+  </xsl:template>
+
+  <xsl:template name="protocol-ipv4">
     <xsl:choose>
       <xsl:when test="dhcp">
         <node label="BOOTPROTO" value="dhcp"/>
diff --git a/data/xml/initscripts-put.xsl b/data/xml/initscripts-put.xsl
index 8baae34..41499bd 100644
--- a/data/xml/initscripts-put.xsl
+++ b/data/xml/initscripts-put.xsl
@@ -125,28 +125,34 @@
   </xsl:template>
 
   <xsl:template name="interface-addressing">
-    <xsl:choose>
-      <xsl:when test="node[@label = 'BOOTPROTO']/@value = 'dhcp'">
-        <dhcp>
-          <xsl:if test="node[@label = 'PEERDNS']">
-            <xsl:attribute name="peerdns"><xsl:value-of select="node[@label = 'PEERDNS']/@value"></xsl:value-of></xsl:attribute>
-          </xsl:if>
-        </dhcp>
-      </xsl:when>
-      <xsl:when test="node[@label = 'BOOTPROTO']/@value = 'none'">
-        <ip>
-          <xsl:attribute name="address"><xsl:value-of select="node[@label = 'IPADDR']/@value"/></xsl:attribute>
-          <xsl:if test="node[@label = 'NETMASK']">
-            <xsl:attribute name="prefix"><xsl:value-of select="ipcalc:prefix(node[@label = 'NETMASK']/@value)"/></xsl:attribute>
+    <xsl:call-template name="protocol-ipv4"/>
+  </xsl:template>
+
+  <xsl:template name="protocol-ipv4">
+    <protocol family="ipv4">
+      <xsl:choose>
+        <xsl:when test="node[@label = 'BOOTPROTO']/@value = 'dhcp'">
+          <dhcp>
+            <xsl:if test="node[@label = 'PEERDNS']">
+              <xsl:attribute name="peerdns"><xsl:value-of select="node[@label = 'PEERDNS']/@value"></xsl:value-of></xsl:attribute>
+            </xsl:if>
+          </dhcp>
+        </xsl:when>
+        <xsl:when test="node[@label = 'BOOTPROTO']/@value = 'none'">
+          <ip>
+            <xsl:attribute name="address"><xsl:value-of select="node[@label = 'IPADDR']/@value"/></xsl:attribute>
+            <xsl:if test="node[@label = 'NETMASK']">
+              <xsl:attribute name="prefix"><xsl:value-of select="ipcalc:prefix(node[@label = 'NETMASK']/@value)"/></xsl:attribute>
+            </xsl:if>
+          </ip>
+          <xsl:if test="node[@label = 'GATEWAY']">
+            <route>
+              <xsl:attribute name="gateway"><xsl:value-of select="node[@label = 'GATEWAY']/@value"/></xsl:attribute>
+            </route>
           </xsl:if>
-        </ip>
-        <xsl:if test="node[@label = 'GATEWAY']">
-          <route>
-            <xsl:attribute name="gateway"><xsl:value-of select="node[@label = 'GATEWAY']/@value"/></xsl:attribute>
-          </route>
-        </xsl:if>
-      </xsl:when>
-    </xsl:choose>
+        </xsl:when>
+      </xsl:choose>
+    </protocol>
   </xsl:template>
 
   <xsl:template name="basic-ethernet-content">
diff --git a/data/xml/interface.rng b/data/xml/interface.rng
index 340eb1f..2afc824 100644
--- a/data/xml/interface.rng
+++ b/data/xml/interface.rng
@@ -145,7 +145,7 @@
           </element>
           <element name="arpmon">
             <attribute name="interval"><ref name="uint"/></attribute>
-            <attribute name="target"><ref name="ip-addr"/></attribute>
+            <attribute name="target"><ref name="ipv4-addr"/></attribute>
             <optional>
               <attribute name="validate">
                 <choice>
@@ -189,8 +189,20 @@
     </attribute>
   </define>
 
-  <!-- Assignment of IP address to an interface -->
+  <!--
+       Assignment of addresses to an interface, allowing for
+       different protocols
+  -->
   <define name="interface-addressing">
+    <element name="protocol">
+      <ref name="protocol-ipv4"/>
+    </element>
+  </define>
+
+  <define name="protocol-ipv4">
+    <attribute name="family">
+      <value>ipv4</value>
+    </attribute>
     <choice>
       <element name="dhcp">
         <optional>
@@ -208,14 +220,14 @@
       -->
       <group>
         <element name="ip">
-          <attribute name="address"><ref name="ip-addr"/></attribute>
+          <attribute name="address"><ref name="ipv4-addr"/></attribute>
           <optional>
-            <attribute name="prefix"><ref name="prefix-pat"/></attribute>
+            <attribute name="prefix"><ref name="ipv4-prefix"/></attribute>
           </optional>
         </element>
         <optional>
           <element name="route">
-            <attribute name="gateway"><ref name="ip-addr"/></attribute>
+            <attribute name="gateway"><ref name="ipv4-addr"/></attribute>
           </element>
         </optional>
       </group>
@@ -300,15 +312,15 @@
     </data>
   </define>
 
-  <define name='ip-addr'>
+  <define name='ipv4-addr'>
     <data type='string'>
       <param name="pattern">([0-2]?[0-9]?[0-9]\.){3}[0-2]?[0-9]?[0-9]</param>
     </data>
   </define>
 
-  <define name='prefix-pat'>
+  <define name='ipv4-prefix'>
     <data type='string'>
-      <param name="pattern">[0-9]|[12][0-9]|3[0-2]</param>
+      <param name="pattern">[1-9]|[12][0-9]|3[0-2]</param>
     </data>
   </define>
 
diff --git a/tests/interface/bond-arp.xml b/tests/interface/bond-arp.xml
index fe550ca..1206b1b 100644
--- a/tests/interface/bond-arp.xml
+++ b/tests/interface/bond-arp.xml
@@ -1,7 +1,9 @@
 <interface type="bond" startmode="none">
   <name>bond0</name>
-  <ip address="192.168.50.7" prefix="24"/>
-  <route gateway="192.168.50.1"/>
+  <protocol family="ipv4">
+    <ip address="192.168.50.7" prefix="24"/>
+    <route gateway="192.168.50.1"/>
+  </protocol>
   <bond mode="active-backup">
     <arpmon interval="100" target="192.168.50.1" validate="active"/>
     <interface type="ethernet">
diff --git a/tests/interface/bond.xml b/tests/interface/bond.xml
index df37de1..640ad52 100644
--- a/tests/interface/bond.xml
+++ b/tests/interface/bond.xml
@@ -1,7 +1,9 @@
 <interface type="bond" startmode="none">
   <name>bond0</name>
-  <ip address="192.168.50.7" prefix="24"/>
-  <route gateway="192.168.50.1"/>
+  <protocol family="ipv4">
+    <ip address="192.168.50.7" prefix="24"/>
+    <route gateway="192.168.50.1"/>
+  </protocol>
   <bond mode="active-backup">
     <miimon freq="100" updelay="10" carrier="ioctl"/>
     <interface type="ethernet">
diff --git a/tests/interface/bridge.xml b/tests/interface/bridge.xml
index adfbee5..583dcf6 100644
--- a/tests/interface/bridge.xml
+++ b/tests/interface/bridge.xml
@@ -1,7 +1,9 @@
 <interface type="bridge" startmode="onboot">
   <name>br0</name>
   <mtu size="1500"/>
-  <dhcp/>
+  <protocol family="ipv4">
+    <dhcp/>
+  </protocol>
   <bridge stp="off">
     <interface type="ethernet">
       <name>eth0</name>
diff --git a/tests/interface/ethernet-dhcp.xml b/tests/interface/ethernet-dhcp.xml
index d554f57..66b91de 100644
--- a/tests/interface/ethernet-dhcp.xml
+++ b/tests/interface/ethernet-dhcp.xml
@@ -2,5 +2,7 @@
   <name>eth0</name>
   <mtu size="1492"/>
   <mac address="aa:bb:cc:dd:ee:ff"/>
-  <dhcp peerdns="no"/>
+  <protocol family="ipv4">
+    <dhcp peerdns="no"/>
+  </protocol>
 </interface>
\ No newline at end of file
diff --git a/tests/interface/ethernet-static-no-prefix.xml b/tests/interface/ethernet-static-no-prefix.xml
index 999adf8..a578677 100644
--- a/tests/interface/ethernet-static-no-prefix.xml
+++ b/tests/interface/ethernet-static-no-prefix.xml
@@ -1,5 +1,7 @@
 <interface type="ethernet" startmode="onboot">
   <name>eth1</name>
-  <ip address="192.168.0.5"/>
-  <route gateway="192.168.0.1"/>
+  <protocol family="ipv4">
+    <ip address="192.168.0.5"/>
+    <route gateway="192.168.0.1"/>
+  </protocol>
 </interface>
diff --git a/tests/interface/ethernet-static.xml b/tests/interface/ethernet-static.xml
index 91599c2..eb285f6 100644
--- a/tests/interface/ethernet-static.xml
+++ b/tests/interface/ethernet-static.xml
@@ -1,5 +1,7 @@
 <interface type="ethernet" startmode="onboot">
   <name>eth1</name>
-  <ip address="192.168.0.5" prefix="24"/>
-  <route gateway="192.168.0.1"/>
+  <protocol family="ipv4">
+    <ip address="192.168.0.5" prefix="24"/>
+    <route gateway="192.168.0.1"/>
+  </protocol>
 </interface>
-- 
1.6.0.6



More information about the netcf-devel mailing list