O'Reilly logo

JUNOS Automation Cookbook by Adam Chappell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

First of all, we declare the subnet parameter and give it a default value. We also provide some help text to be digested by mgd so that the CLI looks helpful to an unenlightened user. Then we use the <get-interface-information> RPC in order to get the operational state of the interfaces on the system.

But then things get interesting. We use jcs:parse-ip() in order to break down the simple IP address string provided by the user into five helpfully distinct components. We store this in a new variable: $subnet-ip. Take a look at the following figure:

Figure 3.1 Illustration of jcs:parse-ip

After printing the header using the usual ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required