Limit b/w on a particular node
Sapan Bhatia [Thu, 12 Nov 2009 16:18:41 +0000 (16:18 +0000)]
sfatables/processors/max_node_kbps.xsl

index 17faf7c..89b4df8 100644 (file)
@@ -13,6 +13,7 @@
 
   <!-- Read in the value of the argument. -->
   <xsl:variable name="max-node-kbps" select="//RSpec//target-context/argument[name='max-node-kbps']/value"/>
+  <xsl:variable name="blacklist_suffix" select="//RSpec//target-context/argument[name='on-legacy-node']/value"/>
 
   <!-- Modify NodeSpec for which kbps > max-link-kbps -->
   <xsl:template match="NodeSpec/max_rate">
       
   <!-- Fill in missing kbps values --> 
   <xsl:template match="NodeSpec[not(max_rate)]">
-      <xsl:copy>
-          <xsl:copy-of select="@*"/>
-          <max_rate><xsl:value-of select="$max-node-kbps"/></max_rate>
-      </xsl:copy>
+      <xsl:choose>
+          <xsl:when test="(not($blacklist_suffix) or not(contains(@name,$blacklist_suffix)))"> 
+              <!-- We're OK on this node, simply copy the nodespec -->
+              <xsl:copy-of select="."/>
+          </xsl:when>
+          <xsl:otherwise>
+              <xsl:choose>
+                  <xsl:when test="not(max_rate)">
+                      <xsl:copy>
+                          <xsl:copy-of select="@*"/>
+                          <max_rate><xsl:value-of select="$max-node-kbps"/></max_rate>
+                      </xsl:copy>
+                  </xsl:when>
+                  <xsl:otherwise>
+                      <xsl:choose>
+                          <xsl:when test=". &gt; $max-node-kbps">
+                              <max_rate><xsl:value-of select="$max-node-kbps"/></max_rate>
+                          </xsl:when>
+                          <xsl:otherwise>
+                              <xsl:copy-of select="."/>
+                          </xsl:otherwise>
+                      </xsl:choose>
+                  </xsl:otherwise>
+              </xsl:choose>
+          </xsl:otherwise>
+      </xsl:choose>
   </xsl:template>
-  
   <xsl:template match="sfatables-input"/>
 </xsl:stylesheet>