Junos API

From neil.tappsville.com
Revision as of 02:08, 8 September 2019 by Gonzo (talk | contribs) (Created page with " 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-un...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

perl module [1] [2] [3]


stolen from [4]

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 [5]