Junos Automation (Scripting)
Highlighted
Junos Automation (Scripting)

no-split-detection only for 2-member virtual-chassis

‎10-22-2015 12:44 AM

Hey,

 

I am surprised that seemingly nobody else has ran into this before. 

Juniper recommends running "no-split-detection" for two-member virtual chassis, however its very easily forgetten when adding/removing members, resulting nasty outages later on.

 

Maybe this could be done via space script to add/remove the stanza when necessary?

(IMHO this could be checked in standard commit checks or AIS commit checks)

 

So basically

if configured VC-members == 2, then add no-split-detection. 

if configured VC-members != 2, then remove no-split-detection (if exists)

 

Opinions?

 

7 REPLIES 7
Highlighted
Junos Automation (Scripting)

Re: no-split-detection only for 2-member virtual-chassis

‎10-22-2015 06:04 AM

If that's the behavior you want, it's certainly do-able as a commit script (on-box).

You could use Space to deploy that script to the desired members.

 

/doug

--
"There he goes. One of God's own prototypes. A high-powered mutant of some kind never even considered for mass production. Too weird to live, and too rare to die." --HST
Highlighted
Junos Automation (Scripting)

Re: no-split-detection only for 2-member virtual-chassis

‎10-22-2015 10:06 AM

It was easy enough,
Here's a simple commit script that does what you asked.  No warranty expressed or implied. Novelty use only:

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

match configuration {
    <xnm:warning> { <message> "Running VC split-detection commit script."; };

    /* If we need it, add it.*/
    if ( (count(virtual-chassis/member) == 2) && (jcs:empty(virtual-chassis/no-split-detection)) ) {  
        var $change = { 
            <virtual-chassis> { 
                <no-split-detection>; 
            } 
        }
        call jcs:emit-change($content = $change, $message = "Setting no-split-detection for virtual-chassis." ); 
    }

    /* If we don't need it (and it's in there), take it out. */
    else if ( (count(virtual-chassis/member) != 2) && (virtual-chassis/no-split-detection) ) { 
        var $change = { 
            <virtual-chassis> { 
                <no-split-detection delete="delete">; 
            }
        }
        call jcs:emit-change($content = $change, $message = "Deleting no-split-detection for virtual-chassis." );        
    } 
}
--
"There he goes. One of God's own prototypes. A high-powered mutant of some kind never even considered for mass production. Too weird to live, and too rare to die." --HST
Highlighted
Junos Automation (Scripting)

Re: no-split-detection only for 2-member virtual-chassis

[ Edited ]
‎10-22-2015 11:56 PM

Very nice, thank you. 

 

I tried if this can be done via JUISE but I end up with a unworking spaghetti of jcs: open() and jcs: execute()'s 😞

 

Highlighted
Junos Automation (Scripting)

Re: no-split-detection only for 2-member virtual-chassis

‎10-23-2015 06:00 AM

Expected behavior: it's a commit script.  

 

It's intended to be run on a real junos device -- not under juise.

Try it on a real VC with commit check.

 

/doug

--
"There he goes. One of God's own prototypes. A high-powered mutant of some kind never even considered for mass production. Too weird to live, and too rare to die." --HST
Highlighted
Junos Automation (Scripting)

Re: no-split-detection only for 2-member virtual-chassis

‎10-23-2015 06:05 AM

Hey,

 

The commit script works very well,

I was just trying to create op-script to work via JUISE but couldnt figure out how 🙂

 

Highlighted
Junos Automation (Scripting)

Re: no-split-detection only for 2-member virtual-chassis

[ Edited ]
‎10-23-2015 06:11 AM

I think I misunderstood what you were saying, re: Juise..

If you wanted to do this via juise, then you'd need to change from commit script behavior. I.e.your script would:

  • open a connection to device
  • get the virtual-chassis bit of the config
  • examine the member count
  • apply your logic check
  • (if needed) : build the config change
  • (if needed) : apply the config change
  • close the connection

You could recycle the previous commit script code for some of that.

--
"There he goes. One of God's own prototypes. A high-powered mutant of some kind never even considered for mass production. Too weird to live, and too rare to die." --HST
Highlighted
Junos Automation (Scripting)

Re: no-split-detection only for 2-member virtual-chassis

‎10-23-2015 06:18 AM

Also, just to skin this cat another way... If you were using Junos Space, you could write a small configlet to check/set that, if you wanted.   

--
"There he goes. One of God's own prototypes. A high-powered mutant of some kind never even considered for mass production. Too weird to live, and too rare to die." --HST
Feedback