Junos Automation (Scripting)
Junos Automation (Scripting)

Troubleshooting commit script error messages

‎01-26-2011 07:59 AM

So, I'm still working my way through slax, and have a couple of successful scripts, but not really feeling confident in my level of understanding/familiarity yet.  I'm trying to modify one of my working commiit scripts to incorporate additional changes that uses the jcs:emit-change call.  Previously the location of the change was bridge-domains/domain[name == "CPEMGMT"], but now that I need to make changes under the protocols section, I need to move the $dot back to the top level.  I get the feeling that I've done more than one thing wrong here:

 

 

      /* variable to equal where to make the change */
      var $dot = "/";

      /* variable to equal the config added */
      var $content = {
        <bridge-domains> {
                <name> "CPEMGMT";
                <interface> $logical;
        }
        <protocols> {
                <oam> {
                        <ethernet> {
                                <link-fault-management> {
                                        <interface> {
                                                <name> $ifname;
                                                <pdu-interval> 1000;
                                        }
                                }
                        }
                }
        }
      }
      /* change function call */
      call jcs:emit-change($dot, $message, $content);

 

 

My immediate need is to fix this script, but I'm also very interested in what troubleshooting steps I could employ to help isolate WHERE in my script there is a problem, so I know where to focus.  If I could learn how to debug these better, I think I could learn much faster.  Here is the error message I'm seeing:

 

 

{master}[edit]
JoshTX@re0.router01# show | display commit-scripts                              
error: Invalid type
error: runtime error: file /var/db/scripts/import/junos.xsl line 152 element param
error: Failed to evaluate the expression of variable 'name'.
error: 3 errors reported by commit scripts
error: commit script failure

 

 

Pointers are appreciated,

Josh

5 REPLIES 5
Junos Automation (Scripting)

Re: Troubleshooting commit script error messages

‎01-26-2011 11:20 AM

You are getting that error because your $dot variable is being assigned as a string (due to the quotes) rather than a node-set. The main reason for Invalid Type errors is that you are trying to perform a location path on a variable that is not a node-set, so anytime you see that, double-check that you didn't accidently cause the variable to be a string or result tree fragment data-type rather than a node-set.

 

var $dot = "/"; /* STRING */

var $dot = /; /* node-set */

 

Either way, you wouldn't want to set the $dot to be the root node, because the configuration is actually buried a little bit within the source tree's XML hierarchy. If you really want to move the $dot back to the upper level then do this:

 

var $dot = /commit-script-input/configuration;

 

Or, alternatively, save the intial context node into a variable at the beginning of the match configuration template:

 

var $configuration = .;

 

And then just set $dot to that:

 

var $dot = $configuration;

Highlighted
Junos Automation (Scripting)

Re: Troubleshooting commit script error messages

‎01-26-2011 04:16 PM

Thank you for the explanation. 

 

I've called out the configuration level for $dot, which eliminates the script error, but now a commit error crops up IF a config change is made by the script.

 

 

{master}[edit]
JoshTX@re0.router01# show | display commit-scripts    
[edit interfaces interface ge-0/0/6 unit 99]
  warning: Adding ge-0/0/6 to OAM and CPE MGMT
[edit interfaces interface ge-0/0/7 unit 99]
  warning: Adding ge-0/0/7 to OAM and CPE MGMT
[edit interfaces interface ge-0/1/0 unit 99]
  warning: Adding ge-0/1/0 to OAM and CPE MGMT
[edit interfaces interface ge-0/1/1 unit 99]
  warning: Adding ge-0/1/1 to OAM and CPE MGMT
[edit interfaces interface ge-0/1/2 unit 99]
  warning: Adding ge-0/1/2 to OAM and CPE MGMT
[edit interfaces interface ge-0/1/3 unit 99]
  warning: Adding ge-0/1/3 to OAM and CPE MGMT
[edit interfaces interface ge-0/1/9 unit 99]
  warning: Adding ge-0/1/9 to OAM and CPE MGMT
error: load of commit script changes failed

 This brings me back to my initial question of...  do you have any tips that would help me isolate the issue?  I'm guessing something is wrong with my 'var $content = {' statement, but without the error calling out a line number, or some context of what is causing the error, I don't know where to start looking.  I've tried several different changes of what I had in the OP, but haven't been able to nail it down with trial and error. 

 

Any pointers?

 

Junos Automation (Scripting)

Re: Troubleshooting commit script error messages

‎01-26-2011 04:32 PM

Enable commit-script traceoptions and flag all, then take a look at the trace file after a commit is attempted. I believe it shows you the configuration change you attempt, but I'm not sure if it points out the error within the trace file so you might have to compare the XML config within your change to the valid XML configuration.

Junos Automation (Scripting)

Re: Troubleshooting commit script error messages

‎01-26-2011 04:48 PM

OK, thats helpful.  So, take a peak at this snippet:

 

 

<commit-script-output xmlns:junos="http://xml.juniper.net/junos/*/junos" xmlns:xnm="http://xml.juniper.net/xnm/1.1/xnm" xmlns:jcs="http://xml.juniper.net/junos/commit-scripts/1.0">
  <xnm:warning>
    <edit-path>[edit interfaces interface ge-0/0/6 unit 99]</edit-path>
    <message>Adding ge-0/0/6 to OAM and CPE MGMT</message>
  </xnm:warning>
  <change>
    <bridge-domains>
      <name>CPEMGMT</name>
      <interface>ge-0/0/6.99</interface>
    </bridge-domains>
    <protocols>
      <oam>
        <ethernet>
          <link-fault-management>
            <interface>
              <name>ge-0/0/6</name>
              <pdu-interval>1000</pdu-interval>
            </interface>
          </link-fault-management>
        </ethernet>
      </oam>
    </protocols>    
  </change> 

...

Jan 26 18:36:58 error or warning node
Jan 26 18:36:58 begin dump
<xnm:warning>
  <edit-path>[edit interfaces interface ge-0/0/6 unit 99]</edit-path>
  <message>Adding ge-0/0/6 to OAM and CPE MGMT</message>
</xnm:warning>Jan 26 18:36:58 end dump

 

Is the edit-path being burried in the interface and not at the top the clue that I'm looking for?

 

Junos Automation (Scripting)
Solution
Accepted by topic author JoshTX
‎08-26-2015 01:27 AM

Re: Troubleshooting commit script error messages

‎01-26-2011 05:33 PM

Your bridge-domains XML syntax is incorrect, take a look at this example:


            <bridge-domains>
                <domain>
                    <name>test</name>
                    <interface>
                        <name>ge-1/3/1.0</name>
                    </interface>
                </domain>
            </bridge-domains>

 

You need to add the <domain> tag.

 

BTW, edit-path shows the incorrect hierarchy due to a bug in jcs:emit-change. Basically you don't want to set the $message if you are also setting the $dot. Instead, manually do a xnm:warning message apart from the change.