Mailing List Archive

XML sample request
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C29562.8763897A
Content-Type: text/plain;
charset="iso-8859-1"

All,

I'm trying to learn XML with respect to JUNOscript, and as such would like
to pick the brains of people who have had some success in this area.

I've read the Juniper examples and a few XML books so I understand the tags
and DTD's, but don't understand the way to query a Juniper router.

I've read
http://www.juniper.net/techpubs/software/junos43/junoscript43/html/session-g
uide12.html, but need some clarification.
Specifically I need some help with establishing a connection to a Juniper
through the JUNOscript session and then using XML to query the router.

Any and all responses would be very welcome.

Thanks, Neil.

------_=_NextPart_001_01C29562.8763897A
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2655.35">
<TITLE>XML sample request</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2>All, </FONT>
</P>

<P><FONT SIZE=3D2>I'm trying to learn XML with respect to JUNOscript, =
and as such would like to pick the brains of people who have had some =
success in this area. </FONT></P>

<P><FONT SIZE=3D2>I've read the Juniper examples and a few XML books so =
I understand the tags and DTD's, but don't understand the way to query =
a Juniper router. </FONT></P>

<P><FONT SIZE=3D2>I've read <A =
HREF=3D"http://www.juniper.net/techpubs/software/junos43/junoscript43/ht=
ml/session-guide12.html" =
TARGET=3D"_blank">http://www.juniper.net/techpubs/software/junos43/junos=
cript43/html/session-guide12.html</A>, but need some =
clarification.</FONT></P>

<P><FONT SIZE=3D2>Specifically I need some help with establishing a =
connection to a Juniper through the JUNOscript session and then using =
XML to query the router.</FONT></P>

<P><FONT SIZE=3D2>Any and all responses would be very welcome.</FONT>
</P>

<P><FONT SIZE=3D2>Thanks, Neil.</FONT>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01C29562.8763897A--
XML sample request [ In reply to ]
Neil Stirling writes:
>Specifically I need some help with establishing a connection to a Juniper
>through the JUNOscript session and then using XML to query the router.

Neil,
I answered some of this in the response to your unicast email over
Thanksgiving vacation, but wanted to follow up on this specific request.

The Junoscript API allows a client application or script to connect
to the router over a number of protocols and perform a series of RPCs.
The client can use traditional login session (ssh, telnet) or a simple
SSL-based access mechanism. The RPCs are a representation of the JUNOS UI
in XML, where command line requests are represented as XML RPCs.

Here's an _extremely_ simple example: a shell script to activate the login
for juniper support personnel. No error handling, no output rendering, just
the connection and rpc basics. In a shell script, no less. (A shell script
is not really well suited for this sort of task, but it does makes for a
nice, simple, self-contained example).

#!/bin/sh
# invoke as: this.sh <router-name> <login> (active | inactive)

ROUTER=$1
LOGIN=$2
STATUS=$3

INFILE=/tmp/simple-in-$$.xml
OUTFILE=/tmp/simple-out-$$.xml

cat > $INFILE << LAST_LINE
<?xml version="1.0"?>
<junoscript version="1.0">
<rpc>
<lock-configuration/>
</rpc>
<rpc>
<load-configuration>
<configuration>
<system>
<login>
<user $STATUS="$STATUS">
<name>$LOGIN</name>
</user>
</login>
</system>
</configuration>
</load-configuration>
</rpc>
<rpc>
<commit-configuration/>
</rpc>
<rpc>
<unlock-configuration/>
</rpc>
</junoscript>
LAST_LINE

exec ssh $ROUTER xml-mode < $INFILE > $OUTFILE

The output file can be tested, etc using an xslt processor (like xsltproc).

Hope this helps.....

Thanks,
Phil