Added max link bandwidth target for VINI.
authorSapan Bhatia <sapanb@cs.princeton.edu>
Mon, 14 Sep 2009 03:29:18 +0000 (03:29 +0000)
committerSapan Bhatia <sapanb@cs.princeton.edu>
Mon, 14 Sep 2009 03:29:18 +0000 (03:29 +0000)
sfatables/targets/MAX_LINK_BW.xml [new file with mode: 0644]
sfatables/targets/__init__.py
sfatables/targets/example_vini_rspec.xml [new file with mode: 0644]
sfatables/targets/max_link_bandwidth.xsl [new file with mode: 0644]

diff --git a/sfatables/targets/MAX_LINK_BW.xml b/sfatables/targets/MAX_LINK_BW.xml
new file mode 100644 (file)
index 0000000..3564529
--- /dev/null
@@ -0,0 +1,13 @@
+<target name="MAX_LINK_BANDWIDTH">
+    <!-- The context is empty, since this target does not require any input from SFA -->
+    <context select=""/>
+    <rule>
+        <argument>
+            <name>max-link-bandwidth</name>
+            <help>Maximum link bandwidth.</help>
+            <operand>bps</operand>
+        </argument>
+        </argument>
+    </rule>
+    <processor filename="max_link_banwidth.xsl"/>
+</target>
index 8f4e850..3a5e632 100644 (file)
@@ -2,4 +2,5 @@ all="""
 RESTRICT_TO_NODES
 ACCEPT
 REJECT
+MAX_LINK_BW
 """.split()
diff --git a/sfatables/targets/example_vini_rspec.xml b/sfatables/targets/example_vini_rspec.xml
new file mode 100644 (file)
index 0000000..a693dd1
--- /dev/null
@@ -0,0 +1,75 @@
+<RSpec name="vini">
+    <sfatables-input>
+        <rule>
+            <argument>
+                <name>max-link-bandwidth</name>
+                <value>1000001</value>
+            </argument>
+        </rule>
+    </sfatables-input>
+
+        <Request>
+            <NetSpec name="default_topology">
+                <LinkSpec>
+                    <endpoint>i2atla1</endpoint>
+                    <endpoint>i2chic1</endpoint>
+                    <bw>1000000</bw>
+                </LinkSpec>
+                <LinkSpec>
+                    <endpoint>i2atla1</endpoint>
+                    <endpoint>i2hous1</endpoint>
+                    <bw>1000000</bw>
+                </LinkSpec>
+                <LinkSpec>
+                    <endpoint>i2atla1</endpoint>
+                    <endpoint>i2wash1</endpoint>
+                    <bw>1000000</bw>
+                </LinkSpec>
+                <LinkSpec>
+                    <endpoint>i2chic1</endpoint>
+                    <endpoint>i2kans1</endpoint>
+                    <bw>1000000</bw>
+                </LinkSpec>
+                <LinkSpec>
+                    <endpoint>i2chic1</endpoint>
+                    <endpoint>i2wash1</endpoint>
+                    <bw>1000000</bw>
+                </LinkSpec>
+                <LinkSpec>
+                    <endpoint>i2hous1</endpoint>
+                    <endpoint>i2kans1</endpoint>
+                    <bw>1000000</bw>
+                </LinkSpec>
+                <LinkSpec>
+                    <endpoint>i2hous1</endpoint>
+                    <endpoint>i2losa1</endpoint>
+                    <bw>1000000</bw>
+                </LinkSpec>
+                <LinkSpec>
+                    <endpoint>i2kans1</endpoint>
+                    <endpoint>i2salt1</endpoint>
+                    <bw>1000000</bw>
+                </LinkSpec>
+                <LinkSpec>
+                    <endpoint>i2losa1</endpoint>
+                    <endpoint>i2salt1</endpoint>
+                    <bw>1000000</bw>
+                </LinkSpec>
+                <LinkSpec>
+                    <endpoint>i2losa1</endpoint>
+                    <endpoint>i2seat1</endpoint>
+                    <bw>1000000</bw>
+                </LinkSpec>
+                <LinkSpec>
+                    <endpoint>i2newy1</endpoint>
+                    <endpoint>i2wash1</endpoint>
+                    <bw>1000000</bw>
+                </LinkSpec>
+                <LinkSpec>
+                    <endpoint>i2salt1</endpoint>
+                    <endpoint>i2seat1</endpoint>
+                    <bw>1000000</bw>
+                </LinkSpec>
+            </NetSpec>
+        </Request>
+    </RSpec>
diff --git a/sfatables/targets/max_link_bandwidth.xsl b/sfatables/targets/max_link_bandwidth.xsl
new file mode 100644 (file)
index 0000000..fe3ee24
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+    <!-- Magic sauce copied from a manual. This fragment basically copies everything except for
+    stuff that explicitly matches with the templates defined below. In the case of such a match,
+    the matched node is treated differently.-->
+    <xsl:template match="@* | node()">
+        <xsl:copy>
+            <xsl:apply-templates select="@* | node()"/>
+        </xsl:copy>
+    </xsl:template>
+    <!-- End of magic sauce -->
+
+    <!-- Read in the value of the argument. See 'example_vini_rspec.xml' for an example of such an argument -->
+    <xsl:variable name="max-link-bandwidth" select="//RSpec//rule/argument[name='max-link-bandwidth']/value"/>
+
+    <!-- Drop Linkspecs for which bw > max-link-bandwidth -->
+    <xsl:template match="LinkSpec">
+            <xsl:choose>
+                <xsl:when test="bw &lt; $max-link-bandwidth">
+                    <xsl:copy-of select="."/>
+                </xsl:when>
+                <xsl:otherwise/>
+            </xsl:choose> 
+    </xsl:template>
+
+    <xsl:template match="sfatables-input"/>
+</xsl:stylesheet>