Junos OS

last person joined: yesterday 

Ask questions and share experiences about Junos OS.
  • 1.  When I change a script from op script to event script, error was met.

    Posted 06-08-2009 04:06

    1)I do following config change:

    delete system scripts op file test.xsl
    set event-options event-script file test.xsl

     

    2)errors in /var/log/escript.log:

    Jun  8 00:00:00 reading event script 'test.xls'
    Jun  8 00:00:03 error: [filename: xmn:rpc results] [line: 17] [column: 11] [input: routing-engine] Opening and ending tag mismatch: routing-engine line 11 and load-configuration-results
     
    Jun  8 00:00:04 error: [filename: xmn:rpc results] [line: 18] [column: 7] [input: commit-results] Opening and ending tag mismatch: commit-results line 7 and routing-engine
     
    Jun  8 00:00:04 error: [filename: xmn:rpc results] [line: 27] [column: 6] [input: rpc-reply] Opening and ending tag mismatch: rpc-reply line 6 and commit-results

     

    Jun  8 00:00:04 error: [filename: xmn:rpc results] [line: 28] [column: 2] [input: junoscript] Opening and ending tag mismatch: junoscript line 2 and rpc-reply
     
    Jun  8 00:00:04 error: [filename: xmn:rpc results] [line: 30] Extra content at the end of the document
     
    Jun  8 00:00:04 commit script: xml-mode: could not read content
    Jun  8 00:00:04 xmlXPathCompiledEval: evaluation failed

     

    3)If I use test.xls as op script and call it in event policy, every thing is ok.

     

    4) junos is 9.2R2.15 running on TX.


    Another question is when I put this test.xsl in event script, I shoud put it in the event script's directory of all lcc's REs. Othes, it can't be passed by commit check, why?



  • 2.  RE: When I change a script from op script to event script, error was met.

    Posted 06-08-2009 09:00

    Event Scripts can be stored/enabled in two ways:

     

    1. Store in /var/db/scripts/op, enable via set system scripts op file ...

     

    2. Store in /var/db/scripts/event, enable via set event-options event-scripts file ...

     

    Either way they can be called through event policy and treated as event scripts with a couple of differences between the two approaches.  First, option #2 (which is the preferred method) is only supported in JUNOS 9.0 and beyond.  One of the capabilities that was released in 9.0, and which is only available if you use option #2, is the ability to embed event policy within the event script itself.

     

    It is because of the ability to embed event policy that the commit process differs a little between the two options.  If you use option #2, then JUNOS must read through the event script to look for any embedded event policy which it will then add to the configuration as part of the commit process.  This means that when you enable an event script in this way it has to exist (on all REs) and will cause an error message otherwise.  In contrast, there is no requirement for an op script file to actually be present.  It won't work when you want it to, but it doesn't have to be there in order for a commit to happen.

     

    Regarding the error messages that you are seeing, does the script work when run as an op script from the command line?  My assumption is that these are script syntax errors and the reason they only appear when you enable it via event options is because JUNOS will automatically try to read it as part of the commit process when done in that way.  But if you just enable it as an op script then no check will be made, it will still complain when the event is actually triggered, but it won't say anything upon commit.



  • 3.  RE: When I change a script from op script to event script, error was met.

    Posted 06-08-2009 09:46

    I know option#1 and option#2 to call script in event policy.

     

    When I use test.xsl as op script, the event policy is doing what as I wish.

    But when I use test.xsl as event script, the event policy doesn't work usually, only sometimes it works normally.

    When it doesn't work, following n /var/log/escript.log:

    Jun  8 00:00:00 running event script 'test.xsl'
    Jun  8 00:00:00 opening event script '/var/db/scripts/event/test.xsl'

    Jun  8 00:00:00 reading event script 'test.xls'
    Jun  8 00:00:03 error: [filename: xmn:rpc results] [line: 17] [column: 11] [input: routing

    -engine] Opening and ending tag mismatch: routing-engine line 11 and load-configuration-

    results
    Jun  8 00:00:04 error: [filename: xmn:rpc results] [line: 18] [column: 7] [input: commit-

    results] Opening and ending tag mismatch: commit-results line 7 and routing-engine
    Jun  8 00:00:04 error: [filename: xmn:rpc results] [line: 27] [column: 6] [input: rpc-

    reply] Opening and ending tag mismatch: rpc-reply line 6 and commit-results

    Jun  8 00:00:04 error: [filename: xmn:rpc results] [line: 28] [column: 2] [input:

    junoscript] Opening and ending tag mismatch: junoscript line 2 and rpc-reply
    Jun  8 00:00:04 error: [filename: xmn:rpc results] [line: 30] Extra content at the end of

    the document
    Jun  8 00:00:04 commit script: xml-mode: could not read content
    Jun  8 00:00:04 xmlXPathCompiledEval: evaluation failed

     

    But when I use test.xsl as op scrtipt, there's no error in /var/log/op-script.log,it always works right.

     

     

     

    Message Edited by pepeng on 06-08-2009 09:54 AM


  • 4.  RE: When I change a script from op script to event script, error was met.

    Posted 06-08-2009 09:48
    Can you post your script?


  • 5.  RE: When I change a script from op script to event script, error was met.

    Posted 06-08-2009 10:05

    I put it on M10i with two RE, it woks normally.

    But I when put it on TX, it can't work usually,only several times it  works right when I use it as event script.

     

    If I use it as op script on M10i and TX ,it works always right.

     

    test.xsl convert slax as following: ......

    Message Edited by pepeng on 06-08-2009 10:57 AM


  • 6.  RE: When I change a script from op script to event script, error was met.
    Best Answer

    Posted 06-08-2009 10:38

    Are the $keyword and $filter parameters being populated by the event policy?  I don't see anything in your script that would account for the error messages shown so it might be a script PR rather than a syntax problem.  You can open a case with JTAC if you want to narrow down the exact PR and when it was resolved.

     

    One thing to mention though is that the script as written is unsafe.  You are performing unprotected configuration commits, meaning that your script loads the configuration and commits it without any knowledge of whether the configuration is currently being edited or not.  Unfortunately it's not possible to do a safe commit through an op or event script until JUNOS 9.3.  At that point you are able to perform exclusive and private commits and not worry about interference with other configuration changes.

     

    Something else to point out is that event scripts are run on the backup routing-engine as well as the master.  So if your script is making configuration changes then both REs are going to try to change the configuration, sometimes at the exact same time.  It might be prudent to have the script detect if it is running on the Master RE or not and to only make changes when it is the master.



  • 7.  RE: When I change a script from op script to event script, error was met.

    Posted 06-08-2009 10:56

    I call it with arguments in event policy.

     

    You're right! When the script is doing commit, if someone is doing commit at the same time, it maybe not finish commit.

     

    Your suggesting is great. I have changed the script in two RE that script will only  change config  if it is running on the Master RE, when it runs on backup RE, it does't change config.

     

    Also I think it maybe a script PR.Thanks!

    Message Edited by pepeng on 06-08-2009 10:59 AM
    Message Edited by pepeng on 06-08-2009 11:18 AM


  • 8.  RE: When I change a script from op script to event script, error was met.

    Posted 06-22-2009 00:03

    Can you post a sample config for

    (a) safe commit and

    (b) master RE check please.



  • 9.  RE: When I change a script from op script to event script, error was met.

    Posted 06-22-2009 10:27

    There are two SLAX script files attached.

     

    deactivate-mpls-lsp.slax - This script demonstrates the four different ways to commit configurations.  Using the "unprotected" approach is the unsafe way to commit, the other three options are all performed safely.

     

    re-templates.slax - This script includes templates which can be used to determine RE mastership.  They should work with M, T, and MX, as well as EX4200 virtual chassis.  I haven't looked into the J series or SRX chassis clusters or  TX matrix though so these templates would likely need to be enhanced to handle those devices.