[j-nsp] NetConf - get_config filter

Serge Vautour sergevautour at yahoo.ca
Fri Jan 9 14:40:32 EST 2009


Hello,

I'm trying to use the NetConf Perl API provided on the Juniper site. I can successfully create a connection to the router and retrieve the entire configuration using "get_config".

Does anyone know if the NetConf Perl API provides a way to filter the request to retrieve a certain part of the config? Per the NetConf docs, the RPC request should look like:

<rpc>
 <get-config>
  <source>
    <!- - tag specifying the source configuration - ->
  </source>
  <filter type="subtree">
   <configuration>
    <!- - opening tags for each parent of the requested object type - ->
     <object-type/>
      <!- - closing tags for each parent of the requested object type - ->
   </configuration>
  </filter>
 </get-config>
</rpc>

The get_configuration perl function only seems to have the following attributes:

    get_configuration => {
        configuration => $DOM,
        format => $ATTRIBUTE,
        inherit => $ATTRIBUTE,
        database => $ATTRIBUTE,
    },

How does on request the "<filter type="subtree">"? Here's an example of the queryargs I use when calling get_config:

my $parser = new XML::DOM::Parser;
my %queryargs = (
 'source' => "running",
 'format' => "xml",
 'configuration' => $parser->parsefile("protocols.xml") ,
);

Where "protocols.xml" is a text file containing:

<configuration>
  <protocols>
    <bgp></bgp>
  </protocols>
</configuration>

When I run the script and echo the request, we get:

Server request: 
 <rpc message-id='1'><get-config> <source><running/> </source></get-config> </rpc>

The API is creating the RPC call correctly for the "source". How do I get it to create the filter section? I've tried:

my $parser = new XML::DOM::Parser;
my %queryargs = (
 'source' => "running",
 'format' => "xml",
 'filter' => "subtree",
 'configuration' => $parser->parsefile("protocols.xml") ,
);

However this creates:

Server request: 
 <rpc message-id='1'><get-config> <source><running/> </source>subtree</get-config> </rpc>

This generates an error as the xml isn't formatted correctly. I've tried several other combinations without any luck. 

Can anyone point me in the right direction to filter the config output to a certain section?

Thanks,
Serge Vautour
SergeVautour at yahoo.ca


      __________________________________________________________________
Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now at
http://ca.toolbar.yahoo.com.


More information about the juniper-nsp mailing list