Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation

Example: Restarting an FPC Using an Op Script

This example uses an op script to restart a Flexible PIC Concentrator (FPC).

Requirements

This example uses a device running Junos OS that contains a Flexible PIC Concentrator (FPC) or equivalent component.

Overview and Op Script

The following script, which is shown in both XSLT and SLAX formats, restarts an FPC given the slot number in which the FPC resides. The user provides the slot number in the command-line interface (CLI) when the script is invoked. The script stores the slot number as the value of the parameter slot and constructs the request chassis fpc command string to include the slot number of the FPC to restart. There is no Junos Extensible Markup Language (XML) equivalent for the request chassis commands. Therefore, this script invokes the request chassis fpc command directly rather that using a remote procedure call (RPC).

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.";
        }
    }
}

Configuration

Step-by-Step Procedure

To download, enable, and test the script:

  1. Copy the XSLT or SLAX script into a text file, name the file restart-fpc.xsl or restart-fpc.slax as appropriate, and download it to the /var/db/scripts/op/ directory on the device.

    Only users who belong to the Junos OS super-user login class can access and edit files in this directory.

  2. In configuration mode, include the file statement at the [edit system scripts op] hierarchy level and restart-fpc.xsl or restart-fpc.slax as appropriate.

    [edit system scripts op]user@host# set file restart-fpc.(slax | xsl)
  3. Issue the commit and-quit command to commit the configuration and to return to operational mode.

    [edit]user@host# commit and-quit
  4. Execute the op script by issuing the op restart-fpc slot slot-number operational mode command.

Verification

Verifying Op Script Execution

Purpose

Verify that the FPC has been restarted and is currently online.

Action

Execute the op script by issuing the op filename operational mode command. Supply the slot number of the FPC as an argument.

user@host> op restart-fpc slot 0

When you execute the script, you should see output similar to the following:

Restarting the FPC in slot 0. To verify, issue the "show chassis fpc" command.

Issue the show chassis fpc detail fpc-slot operational mode command.

user@host> show chassis fpc detail 0
Slot 0 information:
  State                                 Online    
  Temperature                        36 degrees C / 96 degrees F
  Total CPU DRAM                   1024 MB
  Total RLDRAM                      256 MB
  Total DDR DRAM                   4096 MB
  Start time:                           2009-08-11 21:20:30 PDT
  Uptime:                               0 hours, 1 minutes, 50 seconds
  Max Power Consumption             335 Watts

Meaning

The show chassis fpc detail command output displays the state, start time, uptime, and characteristics for the FPC. Verify that the FPC was restarted by checking the start time and uptime of the FPC. Verify the status of the restarted FPC by checking the state. If the status is Present, the FPC is coming up but is not yet online. If the status is Online, the FPC is online and running.

Published: 2013-03-05

Published: 2013-03-05