A customer asked for a script to disable a vcp-port in case there were flapping issues.
There is a cli command that does this
jnpr@EX4200-VC-2> request virtual-chassis vc-port set interface vcp-0 disable member 0
fpc0:
--------------------------------------------------------------------------
{master:0}
jnpr@EX4200-VC-2> show virtual-chassis vc-port
fpc0:
--------------------------------------------------------------------------
Interface Type Trunk Status Speed Neighbor
or ID (mbps) ID Interface
PIC / Port
vcp-0 Dedicated 1 Disabled 32000 <<<<<<<<<<<<<<<< HERE
vcp-1 Dedicated 2 Up 32000 1 vcp-0
fpc1:
--------------------------------------------------------------------------
Interface Type Trunk Status Speed Neighbor
or ID (mbps) ID Interface
PIC / Port
vcp-0 Dedicated 1 Up 32000 0 vcp-1
vcp-1 Dedicated 2 Down 32000
jnpr@EX4200-VC-2> request virtual-chassis vc-port set interface vcp-0 member 0
fpc0:
--------------------------------------------------------------------------
{master:0}
jnpr@EX4200-VC-2> show virtual-chassis vc-port
fpc0:
--------------------------------------------------------------------------
Interface Type Trunk Status Speed Neighbor
or ID (mbps) ID Interface
PIC / Port
vcp-0 Dedicated 1 Up 32000 1 vcp-1 <<<<<<<<<<< re-enabled
vcp-1 Dedicated 2 Up 32000 1 vcp-0
fpc1:
--------------------------------------------------------------------------
Interface Type Trunk Status Speed Neighbor
or ID (mbps) ID Interface
PIC / Port
vcp-0 Dedicated 1 Up 32000 0 vcp-1
vcp-1 Dedicated 2 Up 32000 0 vcp-0
----------------------
Demo of the script to disable vc-port
-----------------------
jnpr@EX4200-VC-2# run show virtual-chassis vc-port
fpc0:
--------------------------------------------------------------------------
Interface Type Trunk Status Speed Neighbor
or ID (mbps) ID Interface
PIC / Port
vcp-0 Dedicated 1 Up 32000 1 vcp-1
vcp-1 Dedicated 2 Up 32000 1 vcp-0
fpc1:
--------------------------------------------------------------------------
Interface Type Trunk Status Speed Neighbor
or ID (mbps) ID Interface
PIC / Port
vcp-0 Dedicated 1 Up 32000 0 vcp-1
vcp-1 Dedicated 2 Up 32000 0 vcp-0
{master:0}[edit]
jnpr@EX4200-VC-2# run op vcp ?
Possible completions:
<[Enter]> Execute this command
<name> Argument name
action 0 to enable, 1 to disable
detail Display detailed output
interface interface name.
| Pipe through a command
{master:0}[edit]
jnpr@EX4200-VC-2# run op vcp interface vcp-0 action 1
jnpr@EX4200-VC-2# run show virtual-chassis vc-port
fpc0:
--------------------------------------------------------------------------
Interface Type Trunk Status Speed Neighbor
or ID (mbps) ID Interface
PIC / Port
vcp-0 Dedicated 1 Disabled 32000
vcp-1 Dedicated 2 Up 32000 1 vcp-0
fpc1:
--------------------------------------------------------------------------
Interface Type Trunk Status Speed Neighbor
or ID (mbps) ID Interface
PIC / Port
vcp-0 Dedicated 1 Up 32000 0 vcp-1
vcp-1 Dedicated 2 Down 32000
{master:0}[edit]
jnpr@EX4200-VC-2# run op vcp interface vcp-0 action 0
{master:0}[edit]
jnpr@EX4200-VC-2# run show virtual-chassis vc-port
fpc0:
--------------------------------------------------------------------------
Interface Type Trunk Status Speed Neighbor
or ID (mbps) ID Interface
PIC / Port
vcp-0 Dedicated 1 Up 32000 1 vcp-1
vcp-1 Dedicated 2 Up 32000 1 vcp-0
fpc1:
--------------------------------------------------------------------------
Interface Type Trunk Status Speed Neighbor
or ID (mbps) ID Interface
PIC / Port
vcp-0 Dedicated 1 Up 32000 0 vcp-1
vcp-1 Dedicated 2 Up 32000 0 vcp-0
----------------------------
Source code
----------------------------
jnpr@EX4200-VC-2# run file show /var/db/scripts/op/vcp.slax
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> "interface";
<description> "interface name.";
}
<argument> {
<name> "action";
<description> "0 to enable, 1 to disable";
}
}
param $interface;
param $action =0;
match /
{
<event-op-results> {
if ($action = 1) {
var $interface-info = <command> "request virtual-chassis vc-port set interface " _ $interface _ " disable member 0";
var $interface-result = jcs:invoke($interface-info);
}
if ($action = 0) {
var $interface-info = <command> "request virtual-chassis vc-port set
interface " _ $interface _ " member 0";
var $interface-result = jcs:invoke($interface-info);
}
}
}