[j-nsp] sequential commands in SLAX

Phil Shafer phil at juniper.net
Thu Jan 14 16:20:03 EST 2016


Martin T writes:
>    /* rlogin to second RE */
>    var $cmd_login_other_re = <command> "request routing-engine login
>other-routing-engine";
>    var $cmd_login_other_re_results = jcs:invoke( $cmd_login_other_re );

If you want to talk to the other RE (or any remote host), you'll need
jcs:open() which returns a connection.  To talk to the other RE, you'll
need to know its hostname or ip address.

    var $other-re = "re2";
    var $conn = jcs:open($other-re);
    var $res = jcs:execute($conn, $rpc);
    ...

>    /* print out the name of the second RE */
>    <output> $junos-context//routing-engine-name;

The $junos-context will remain the local machine's context values.

>    /* exit rlogin session */
>    var $cmd_quit_other_re = <command> "quit";
>    var $cmd_quit_other_re_results = jcs:invoke( $cmd_quit_other_re );
>Why doesn't such approach work?

The API is layered tightly over the CLI, but it's not the CLI.  It's
meant to be mode-less and RPC oriented.  Instead of passing commands
over a terminal, you pass RPCs to the host's MGD directly and get
XML back.  Details are available in the "Day One" guides:

    http://www.juniper.net/us/en/training/jnbooks/day-one/automation-series/

Thanks,
 Phil


More information about the juniper-nsp mailing list