Force10 XML API Fun

Using Force10 XML for switch port reclamation reporting

If you’re running Force10 switching gear, chances are you’re running a firmware version that supports Force10’s XML API. That being said, unless you have the absolute newest firmware version (I don’t think they have yet released anything with a SOAP/REST interface), you have to access that XML API through SSH. See the documentation for the details on the “display xml” option, and get comfortable with expect and sed for retrieving the command output and massaging it into well-formed XML. The schema XSDs are available here.

What follows is a snip from an XSL useful for interface reclamation…

<xsl:template match="/">
  <html>
   <head>
       <title>Switch Port Reclamation</title>
   </head>
   <body>
       <div>
       <h1>Interfaces</h1>
       <br />
           <div style="padding:10px;">            
           <ul>
            <xsl:for-each select="/response/action/interface">
               <!-- Set variables -->
               <xsl:variable name="ifName" select="ifName" />
               <xsl:variable name="ifDescription" select="ifDescr" />
               <xsl:variable name="ifPartOfLag" select="ifPartOfLag" />
               <xsl:variable name="ifAdminStatus" select="ifAdminStatus" />
               <xsl:variable name="ifOperStatus" select="ifOperStatus" />
               <xsl:variable name="ifPortDownCause" select="ifPortDownCause" />
               <xsl:variable name="ifStatusAge" select="ifTimeSinceLastChanged" />
               <xsl:variable name="weekDelimiter">w</xsl:variable>
               <xsl:variable name="ifWarn" select="substring-before($ifStatusAge,$weekDelimiter)"/>
               <!-- Labeling logic -->
               <xsl:variable name="cssClass">
               <xsl:choose>
                   <xsl:when test="$ifAdminStatus='down'">shutdown</xsl:when>
                   <xsl:when test="$ifOperStatus='up'">operational</xsl:when>
                   <xsl:when test="$ifWarn>1">reclaimNow</xsl:when>
                   <xsl:otherwise>reclaimSoon</xsl:otherwise>
               </xsl:choose>
               </xsl:variable>
               <xsl:text disable-output-escaping="yes">&lt;li class=&quot;</xsl:text>
               <xsl:value-of select="$cssClass"/>
               <xsl:text disable-output-escaping="yes">&quot;&gt;</xsl:text>
               <xsl:value-of select="$ifName"/>
                               <xsl:text disable-output-escaping="yes"> / </xsl:text>
               <xsl:value-of select="$ifDescription"/>
                               <xsl:text disable-output-escaping="yes">    </xsl:text>
               <xsl:value-of select="$ifAdminStatus"/>
               <xsl:text disable-output-escaping="yes"> / </xsl:text>
               <xsl:value-of select="$ifOperStatus"/>
                               <xsl:text disable-output-escaping="yes">    </xsl:text>
               <xsl:value-of select="$ifStatusAge"/>
               <xsl:text disable-output-escaping="yes">&lt;/li&gt; </xsl:text>
           </xsl:for-each>
           </ul>
           </div>
       </div>
   </body>
 </html>
</xsl:template>

Set your CSS in the XSL, or in whatever portal you feel like presenting it through… the state of the interface determines the CSS class assigned to the line containing the interface information.

Enjoy!