Junos API
From neil.tappsville.com
Jump to navigationJump to searchUltimately I did not go this way as the statistics we needed could only be gleemed from the cli using expect scripts.
perl module
- http://search.cpan.org/~junos/junoscript-perl-6.4I0/
- http://www.juniper.net/techpubs/software/junos/junos102/junoscript-guide/section-junoscript-perl-client-unpacking.html
- http://www.juniper.net/techpubs/software/junos/junos95/junoscript-guide/id-10828395.html
Info from
Juniper CLI commands are turned into XML which is passed to the engine to run commands.
You can get the query in the following way:
user@host> show chassis alarms | display xml rpc
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/10.4B1/junos">
<rpc>
<get-alarm-information>
</get-alarm-information>
</rpc>
<cli>
<banner></banner>
</cli>
</rpc-reply>
you can get the response in the following way:
user@host> show chassis alarms
No alarms currently active
user@host> show chassis alarms | display xml
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/10.4B1/junos">
<alarm-information xmlns="http://xml.juniper.net/junos/10.4B1/junos-alarm">
<alarm-summary>
<no-active-alarms/>
</alarm-summary>
</alarm-information>
<cli>
<banner></banner>
</cli>
</rpc-reply>
Some commands have no RPC XML equiv... thus can use the following
<xsl:variable name="query">
<command>
<xsl:value-of select="concat('show host ', $hostname)"/>
</command>
</xsl:variable>
<xsl:variable name="result" select="jcs:invoke($query)"/>
<xsl:variable name="host" select="$result"/>
<output>
<xsl:value-of select="concat('Name: ', $host)"/>
</output>
Nice lookup for cli --> xml commands [1]