Automation

What does the vstp-check-new script do?

By Elevate posted 08-11-2015 02:46

  
This applies to SLAX version 1.0 and higher.

Overview

Prevent a VLAN from inadvertently being trunked and potentially causing a bridge-loop. This works with the new 9.2 style MX trunking/access configs only.

 

Description

This commit-script ensures that any trunked VLANs (on "xe-*" interfaces in this case) are configured for VSTP and have a bridge-domain associated with it. This script errors if the VLAN is not in VSTP or in a bridge-domain and warns if the VLAN is in VSTP, but does not have a priority associated with it.

Source Code

 

GitHub Links

 

The source code below is also available from GitHub at the following locations:

SLAX Script Contents


001	version 1.0;
002	ns junos = "http://xml.juniper.net/junos/*/junos";
003	ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
004	ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";
005	ns ext = "http://xmlsoft.org/XSLT/namespace";
006	 
007	import "../import/junos.xsl";
008	 
009	match configuration {
010	    var $vstpConfRaw = { call vstpConfTemplate(); }
011	    var $vstpConf = ext:node-set($vstpConfRaw);
012	 
013	    var $bridgeConfRaw = { call bridgeConfTemplate(); }
014	    var $bridgeConf = ext:node-set($bridgeConfRaw);
015	 
016	    for-each (interfaces/interface[starts-with(name, "xe-")]/unit[name == 0]/family/bridge/vlan-id-list) {
017	        var $intName = ../../../../name;
018	        var $vlanRaw = .;
019	    if (contains($vlanRaw, "\-")) {
020	            var $low = substring-before($vlanRaw, "-");
021	            var $high = substring-after($vlanRaw, "-");
022	 
023	            var $vlanListRaw = { call genList ($low, $high); }
024	            var $vlanList = ext:node-set($vlanListRaw);
025	             
026	            for-each ($vlanList/vlanList) {
027	                var $vlanID = 

#Slax
#vlan
#How-To
#commit-script
0 comments
0 views

Permalink