Automation

 View Only
last person joined: 4 days ago 

Ask questions and share experiences about Apstra, Paragon, and all things network automation.
  • 1.  Displaying commit-script inheritance using JUNOScript API

    Posted 02-02-2010 15:05

    Hello-

     

    I have a question about querying a device configuration with JUNOScript and having it include any changes made to the configuration by commit-scripts (equivalent to "show | display commit-scripts" CLI command). Is it possible to do this, and if so is it documented anywhere?


    The latest available (9.6) JUNOScript API documentation does not contain any references to "commit-scripts", and so if it IS supported it's definitely not documented there.

     

    Currently I use the following command to fetch a configuration with apply-group inheritances:


    <get-configuration database="committed" inherit="inherit"/>


    My Juniper rep suggested I try this based on an educated guess:


    <get-configuration database="committed" commit-scripts="commit-scripts"/>


    Which was accepted by the device without errors, but did not change the output. The output was the same as if I had passed inherit="inherit".  So the verdict is still out... Is it possible, and if so, how do we call it?


    Any assistance on this is appreciated!


    #junoscript
    #get-configuration
    #xml
    #commit-scripts


  • 2.  RE: Displaying commit-script inheritance using JUNOScript API
    Best Answer

    Posted 02-02-2010 21:07

    There is no current option to provide this, but there is a workaround that might work for you.  The following works for local Junos scripts so you can try it through Junoscript:

     

    <command> "show configuration | display xml | display commit-scripts"

     

    The returned XML is not what you'll expect though, it will be enclosed within a <pipe> element.



  • 3.  RE: Displaying commit-script inheritance using JUNOScript API

    Posted 02-03-2010 10:09

    Whoops, deleted my initial response instead of editing!

     

    First of all, thank you for this suggestion.  I tested it out and it did indeed work, although I had to remove the quotes from the command string. My rpc call looked like this:

     

    <rpc><command>show configuration interfaces | display xml | display commit-scripts</command></rpc>

     

    Testing on JUNOS 9.5R2.7 it doesn't actually wrap the entire response in <pipe>, it just includes it as an extra element. So in the short-term this is usable.  Long-term I will work to convince Juniper to do the right thing and make this available in the API.

     

    Just for completeness, the response looks like this:

     

    <rpc-reply xmlns:junos="http://xml.juniper.net/junos/9.5R2/junos">

    <pipe>

    <display-xml>

    </display-xml>

    </pipe>

    <configuration junos:changed-seconds="1265218655" junos:changed-localtime="2010-02-03 12:37:35 EST">    

        <interfaces>

            ...

        </interfaces>

    </configuration>

    </rpc-reply>

     

    This is progress, so thanks again.



  • 4.  RE: Displaying commit-script inheritance using JUNOScript API

    Posted 05-11-2010 04:13

    Is it possible to show configuration with inheritance of both groups and commit-scripts (via junoscript or cli)?

    Command

    show configuration | display inheritance | display commit-scripts

    replies

    error: file copy of database failed

    JunOS 10.0R2.10.

    Thanks.



  • 5.  RE: Displaying commit-script inheritance using JUNOScript API

    Posted 05-11-2010 06:20

    This is PR 519304 - show configuration cannot display both commit script results and inheritance together.

     

    In the meantime, a workaround op script has been created which can display the configuration with both transient changes and inheritance, but it can only be used by users that have access to edit the full configuration, and only when there is no pending candidate configuration changes that need to be committed. I'm attaching the script.



  • 6.  RE: Displaying commit-script inheritance using JUNOScript API

    Posted 05-12-2010 01:04

    Thanks!



  • 7.  RE: Displaying commit-script inheritance using JUNOScript API

    Posted 04-05-2012 23:54

    Hi Curtis

     

    Looks like this one is not yet fixed, and op script show-transient-inheritance is also not

    working in my case, am I doing something wrong?

     

    [edit]
    lab@srxA-1# show | display inheritance | display commit-scripts 
    error: file copy of database failed
    
    [edit]
    lab@srxA-1# exit 
    Exiting configuration mode
    
    lab@srxA-1> op show-transient-inheritance 
    xnm:rpc results:141:(7) Opening and ending tag mismatch: routing-engine line 7 and rpc-reply
    xnm:rpc results:143:(6) Opening and ending tag mismatch: rpc-reply line 6 and junoscript
    xnm:rpc results:144:(2) Premature end of data in tag junoscript line 2
    error: commit script: xml-mode: could not read content
    error: xmlXPathCompiledEval: evaluation failed
    error: runtime error: file /var/db/scripts/op/show-transient-inheritance.slax line 24 element variable
    error: Failed to evaluate the expression of variable 'commit-script-config'.
    
    lab@srxA-1> show version 
    Hostname: srxA-1
    Model: srx240h
    JUNOS Software Release [10.4R4.5]