Automation

last person joined: 4 days ago 

Ask questions and share experiences about Apstra, Paragon, and all things network automation.
  • 1.  OP Ping from Routing-Instance

    Posted 11-05-2013 10:57

    Looking for a bit of help on an op script that will ping using a routing instance as the source of the ping. I get a lot of the script from here but I have yet to find how to include a routing-instance to source it from. Any help?



  • 2.  RE: OP Ping from Routing-Instance

    Posted 02-03-2014 21:17

     

    If you are not required to use an op script, you may get the same result using an RPM probe which allows you to ping based on a routing instance ... plus it gives you options for a lot of other features too... 

     

    An example below:

     

    yardiel@srx-14# show services rpm probe rm-srx-ge-0

    probe rm-srx-ge-0 {
    test if-ping-test {
    probe-type icmp-ping-timestamp;
    target address 10.10.10.2;
    probe-count 15;
    probe-interval 1;
    test-interval 60;
    routing-instance test-1;
    }
    }

     

    Yardiel

     



  • 3.  RE: OP Ping from Routing-Instance

     
    Posted 02-03-2014 21:22

    Have you tried routing-instance tag?

     

    ckim@wf-pacman-la> ping 10.13.110.1 routing-instance sysnet | display xml rpc 
    <rpc-reply xmlns:junos="http://xml.juniper.net/junos/12.3R5/junos">
        <rpc>
            <ping>
                    <routing-instance>sysnet</routing-instance>
                    <host>10.13.110.1</host>
            </ping>
             </rpc>
            <cli>
                <banner></banner>
            </cli>
        </rpc-reply>
    
    ckim@wf-pacman-la> 

     

    Thanks,

    /Charlie



  • 4.  RE: OP Ping from Routing-Instance

    Posted 02-04-2014 08:44

    Thanks for that. I built a script, not getting any errors when it runs, but not getting any output either. Here's what I have so far:

     

    /*
    * op script for ping (host) from routing-instance
    *
    */
    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 / {
    <op-script-output> {
    var $ping-target = "192.168.11";
    var $ping-rpc = {
    <ping> {
    <count> "5";
    <rapid>;
    <host> $ping-target;
    <routing-instance> "branch";
    }
    }
    var $results = jcs:invoke($ping-rpc);

    }
    }



  • 5.  RE: OP Ping from Routing-Instance
    Best Answer

     
    Posted 02-04-2014 10:29

    This was my test scrpt and result.

     

    ckim@wf-pacman-la> op url /var/home/ckim/test.slax    
    target-host: 192.168.27.2
    target-ip: 192.168.27.2
    packet-size: 56
    probe-result: 
    1
    
    0
    192.168.27.2
    64
    64
    141
    probe-result: 
    2
    
    1
    192.168.27.2
    64
    64
    144
    probe-results-summary: 
    2
    2
    0
    141
    144
    142
    1
    ping-success: 
    
    ckim@wf-pacman-la> file show test.slax
    /*
    * op script for ping (host) from routing-instance
    *
    */
    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 / {
      <op-script-output> {
        var $ping-target = "192.168.27.2";
        var $ping-rpc = {
          <ping> {
          <count> "2";
          <rapid>;
          <routing-instance> "sysnet";
            <host> $ping-target;
           }
        }
        var $results = jcs:invoke($ping-rpc);
     
        for-each($results/*){
          <output> name() _ ": " _ . ;
        }
      }
    }

    ckim@wf-pacman-la>

     

    Thanks,

    /Charlie

     



  • 6.  RE: OP Ping from Routing-Instance

    Posted 02-05-2014 12:24

    This works! I just have to clean up the output and all should be right as rain.