Example: Restarting an FPC Using an Op Script

This example simply restarts a Flexible PIC Concentrator (FPC) and slightly modifies the output of the request chassis fpc command to include the FPC number that is restarting.

There is no Junos Extensible Markup Language (XML) equivalent for the request chassis commands. Therefore, this script uses the request chassis fpc command directly rather that using a remote procedure call (RPC). For more information, see Using RPCs and Operational Mode Commands in Op Scripts.

XSLT Syntax

<?xml version="1.0" standalone="yes"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:junos="http://xml.juniper.net/junos/*/junos"
    xmlns:xnm="http://xml.juniper.net/xnm/1.1/xnm"
    xmlns:jcs="http://xml.juniper.net/junos/commit-scripts/1.0">
    <xsl:import href="../import/junos.xsl"/>
 
    <xsl:variable name="arguments">
        <argument>
            <name>slot</name>
            <description>Slot number of the FPC</description>
        </argument>
    </xsl:variable>
    <xsl:param name="slot"/>
    <xsl:template match="/">
        <op-script-results>
            <xsl:variable name="restart">
                <command>
                    <xsl:value-of select="concat('request chassis fpc slot ', $slot,'
                                                                                                       restart')"/>
                </command>
            </xsl:variable>
            <xsl:variable name="result" select="jcs:invoke($restart)"/>
            <output>
                <xsl:text>Restarting the FPC in slot </xsl:text>
                <xsl:value-of select="$slot"/>
                <xsl:text>. </xsl:text>
                <xsl:text>To verify, issue the "show chassis fpc" command.</xsl:text>
            </output>
        </op-script-results>
    </xsl:template>
</xsl:stylesheet>

SLAX Syntax

version 1.0;
ns junos = "http://xml.juniper.net/junos/*/junos";
ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";
import "../import/junos.xsl";
 
var $arguments = {
    <argument> {
        <name> "slot";
        <description> "Slot number of the FPC";
    }
}
param $slot;
match / {
    <op-script-results> {
        var $restart = {
            <command> 'request chassis fpc slot ' _ $slot _ ' restart';
        }
        var $result = jcs:invoke($restart);
        <output> {
            expr "Restarting the FPC in slot ";
            expr $slot;
            expr ". ";
            expr "To verify, issue the \"show chassis fpc\" command.";
        }
    }
}

Testing the ex-fpc Script

To test the ex-fpc script, perform the following steps:

  1. Copy the XSLT or SLAX script from Example: Restarting an FPC Using an Op Script into a text file, name the file ex-fpc.xsl or ex-fpc.slax as appropriate, and copy it to the /var/db/scripts/op directory on the device.
  2. In configuration mode, include the file ex-fpc.extension statement at the [edit system scripts op] hierarchy level, substituting .slax or .xsl for extension as appropriate.

    [edit system scripts op]file ex-fpc.(slax | xsl);
  3. Issue the commit and-quit command.

    [edit]user@host# commit and-quit

When you issue the op ex-fpc slot number operational command, you should see output similar to the following:


user@host> op ex-fpc slot 0
Restarting the FPC in slot 0. To verify, issue the "show chassis fpc" command.