Juniper JUNOS OS 10.3 - XML MANAGEMENT PROTOCOL GUIDE 6-30-2010 Manual
Juniper JUNOS OS 10.3 - XML MANAGEMENT PROTOCOL GUIDE 6-30-2010 Manual

Juniper JUNOS OS 10.3 - XML MANAGEMENT PROTOCOL GUIDE 6-30-2010 Manual

Junos xml management protocol guide
Hide thumbs Also See for JUNOS OS 10.3 - XML MANAGEMENT PROTOCOL GUIDE 6-30-2010:
Table of Contents

Advertisement

Quick Links

®
JUNOS
OS
Junos XML Management Protocol Guide
Release
10.3
Published: 2010-06-30
Copyright © 2010, Juniper Networks, Inc.

Advertisement

Table of Contents
loading

Summary of Contents for Juniper JUNOS OS 10.3 - XML MANAGEMENT PROTOCOL GUIDE 6-30-2010

  • Page 1 ® JUNOS Junos XML Management Protocol Guide Release 10.3 Published: 2010-06-30 Copyright © 2010, Juniper Networks, Inc.
  • Page 2 Products made or sold by Juniper Networks or components thereof might be covered by one or more of the following patents that are owned by or licensed to Juniper Networks: U.S. Patent Nos. 5,473,599, 5,905,725, 5,909,440, 6,192,051, 6,333,650, 6,359,479, 6,406,312, 6,429,706, 6,459,579, 6,493,347, 6,538,518, 6,538,899, 6,552,918, 6,567,902, 6,578,186, and 6,590,785.
  • Page 3 REGARDING LICENSE TERMS. 1. The Parties. The parties to this Agreement are (i) Juniper Networks, Inc. (if the Customer’s principal office is located in the Americas) or Juniper Networks (Cayman) Limited (if the Customer’s principal office is located outside the Americas) (such applicable entity being referred to herein as “Juniper”), and (ii) the person or organization that originally purchased from Juniper or an authorized Juniper reseller the applicable...
  • Page 4 Customer shall be liable for any such violations. The version of the Software supplied to Customer may contain encryption or other capabilities restricting Customer’s ability to export the Software without an export license. Copyright © 2010, Juniper Networks, Inc.
  • Page 5 (including Juniper modifications, as appropriate) available upon request for a period of up to three years from the date of distribution. Such request can be made in writing to Juniper Networks, Inc., 1194 N. Mathilda Ave., Sunnyvale, CA http://www.gnu.org/licenses/gpl.html...
  • Page 6 Copyright © 2010, Juniper Networks, Inc.
  • Page 7 Index of Statements and Commands ....... 257 Copyright © 2010, Juniper Networks, Inc.
  • Page 8 Junos 10.3 Junos XML Management Protocol Guide viii Copyright © 2010, Juniper Networks, Inc.
  • Page 9: Table Of Contents

    Mapping for Single-Value and Fixed-Form Leaf Statements ....17 Mapping for Leaf Statements with Multiple Values ..... 18 Copyright © 2010, Juniper Networks, Inc.
  • Page 10 Displaying CLI Output as XML Tag Elements ......56 Copyright © 2010, Juniper Networks, Inc.
  • Page 11 Elements ..........107 Copyright © 2010, Juniper Networks, Inc.
  • Page 12 <abort-acknowledgement/> ......... 150 Copyright © 2010, Juniper Networks, Inc.
  • Page 13 ............201 Copyright © 2010, Juniper Networks, Inc.
  • Page 14 Index of Statements and Commands ........257 Copyright © 2010, Juniper Networks, Inc.
  • Page 15 Requesting Information ..........61 Table 7: Regular Expression Operators for the matching Attribute ... . . 91 Copyright © 2010, Juniper Networks, Inc.
  • Page 16 Junos 10.3 Junos XML Management Protocol Guide Copyright © 2010, Juniper Networks, Inc.
  • Page 17: About This Guide

    Juniper Networks website at http://www.juniper.net/techpubs/ Juniper Networks supports a technical book program to publish books by Juniper Networks engineers and subject matter experts with book publishers around the world. These books go beyond the technical documentation to explore the nuances of network architecture, deployment, and administration using the Junos operating system (Junos OS) and Juniper Networks devices.
  • Page 18: Audience

    This guide is designed for network administrators who are configuring and monitoring a Juniper Networks M Series, MX Series, T Series, EX Series, or J Series router or switch. This guide is designed for Juniper Networks customers who want to write custom applications for configuring or monitoring a Juniper Networks device that runs the Junos OS.
  • Page 19: Supported Platforms

    Alerts you to the risk of personal injury or death. Laser warning Alerts you to the risk of personal injury from a laser. Table 2 on page xx defines the text and syntax conventions used in this guide. Copyright © 2010, Juniper Networks, Inc.
  • Page 20: Table 2: Text And Syntax Conventions

    Indention and braces ( { } ) Identify a level in the configuration [edit] hierarchy. routing-options { static { route default { ; (semicolon) Identifies a leaf statement at a nexthop address; configuration hierarchy level. retain; J-Web GUI Conventions Copyright © 2010, Juniper Networks, Inc.
  • Page 21: Documentation Feedback

    7 days a week, 365 days a year. Self-Help Online Tools and Resources For quick and easy problem resolution, Juniper Networks has designed an online self-service portal called the Customer Support Center (CSC) that provides you with the following features: Find CSC offerings: http://www.juniper.net/customers/support/...
  • Page 22: Opening A Case With Jtac

    Download the latest versions of software and review release notes: http://www.juniper.net/customers/csc/software/ Search technical bulletins for relevant hardware and software notifications: https://www.juniper.net/alerts/ Join and participate in the Juniper Networks Community Forum: http://www.juniper.net/company/communities/ Open a case online in the CSC Case Management tool: http://www.juniper.net/cm/...
  • Page 23: Overview

    PART 1 Overview Introduction to the Junos XML Management Protocol and Junos XML API on page 3 Using Junos XML Management Protocol and Junos XML Tag Elements on page 9 Copyright © 2010, Juniper Networks, Inc.
  • Page 24 Junos 10.3 Junos XML Management Protocol Guide Copyright © 2010, Juniper Networks, Inc.
  • Page 25: Introduction To The Junos Xml Management Protocol And Junos Xml

    The Junos XML protocol server directs the request to the appropriate software modules within the device, encodes the response in Junos XML and Junos XML protocol tag elements, and returns the result to the client application. For example, to request Copyright © 2010, Juniper Networks, Inc.
  • Page 26: Xml Overview

    If a tag element is empty—has no contents—it can be represented either as paired opening and closing tags with nothing between them, or as a single tag with a forward slash after the tag name. For example, the notation <snmp-trap-flag/> is equivalent to <snmp-trap-flag></snmp-trap-flag> Copyright © 2010, Juniper Networks, Inc.
  • Page 27: Document Type Definition

    Junos XML protocol tag element in its opening and closing tags. This is an XML convention, and the brackets are a required part of the complete tag element name. They are not to be confused with the angle brackets used in Juniper Networks documentation to indicate optional parts of CLI command strings.
  • Page 28: Overview Of A Junos Xml Protocol Session

    Junos XML DTDs for the kind of information they encode. Client applications must produce a well-formed XML document for each request by emitting tag elements in the required order and only in the legal contexts. Copyright © 2010, Juniper Networks, Inc.
  • Page 29 The client application sends one or more requests to the Junos XML protocol server and parses its responses. The client application closes the Junos XML protocol session and the connection to the Junos XML protocol server. Copyright © 2010, Juniper Networks, Inc.
  • Page 30 Junos 10.3 Junos XML Management Protocol Guide Copyright © 2010, Juniper Networks, Inc.
  • Page 31: Using Junos Xml Management Protocol And Junos Xml Tag Elements

    XML document (the Junos XML protocol server obeys XML and Junos XML management protocol conventions). The following sections describe Junos XML management protocol conventions: Request and Response Tag Elements on page 10 Child Tag Elements of a Request Tag Element on page 10 Copyright © 2010, Juniper Networks, Inc.
  • Page 32: Request And Response Tag Elements

    62. Child Tag Elements of a Request Tag Element Some request tag elements contain child tag elements. For configuration requests, each child tag element represents a configuration element (hierarchy level or configuration Copyright © 2010, Juniper Networks, Inc.
  • Page 33: Child Tag Elements Of A Response Tag Element

    A client application can ignore or discard the white space, particularly if it does not store responses for later review by human users. However, it Copyright © 2010, Juniper Networks, Inc.
  • Page 34: Xml Comments

    In the string value assigned to an attribute of an opening tag When including a disallowed character in either context, client applications must substitute the equivalent predefined entity reference, which is a string of characters that Copyright © 2010, Juniper Networks, Inc.
  • Page 35: Table 3: Predefined Entity Reference Substitutions For Tag Content Values

    <condition>if (a&lt;b &amp;&amp; b&gt;c) return "Peer’s not \ responding"</condition> Similarly, if the value for the tag element’s attribute is <example> heading Peer’s "age" <> 40 , the opening tag looks like this: <example heading="Peer&apos;s &quot;age&quot; &lt;&gt; 40"> Copyright © 2010, Juniper Networks, Inc.
  • Page 36: Mapping Commands To Junos Xml Tag Elements

    The following example shows the Junos XML tag elements for the show isis adjacency command, which has a fixed-form option called detail Copyright © 2010, Juniper Networks, Inc.
  • Page 37: Mapping Configuration Statements To Junos Xml Tag Elements

    The following example shows the Junos XML tag elements for two statements at the top level of the configuration hierarchy. Note that a closing brace in a CLI configuration statement corresponds to a closing Junos XML tag. Copyright © 2010, Juniper Networks, Inc.
  • Page 38: Mapping For Objects That Have An Identifier

    [edit protocols bgp group] hierarchy level has an associated name (the identifier) and can have leaf statements for other characteristics such as type, peer autonomous system (AS) number, and neighbor address. For information about the Copyright © 2010, Juniper Networks, Inc.
  • Page 39: Mapping For Single-Value And Fixed-Form Leaf Statements

    The following example shows the Junos XML tag elements for two leaf statements that have a keyword and a value: the message statement at the [edit system login] hierarchy level and the statement at the hierarchy level. preference [edit protocols ospf] Copyright © 2010, Juniper Networks, Inc.
  • Page 40: Mapping For Leaf Statements With Multiple Values

    Junos XML tag elements for a CLI statement with multiple user-defined values. The import statement imports two routing policies defined elsewhere in the configuration. For complete information about changing routing platform configuration, see “Changing Configuration Information” on page 103. Copyright © 2010, Juniper Networks, Inc.
  • Page 41: Mapping For Multiple Options On One Or More Lines

    Junos XML API defines a separate tag element for each option. The following example shows Junos XML tag elements for a statement at the traceoptions [edit protocols isis] hierarchy level. The statement has three child statements, each with multiple options. Copyright © 2010, Juniper Networks, Inc.
  • Page 42: Mapping For Comments About Configuration Statements

    ) results in the comment appearing on its own line in the configuration file. There are no newline characters in the contents of the second tag element, so in the configuration file the comment directly follows <junos:comment> the associated statement on the same line. Copyright © 2010, Juniper Networks, Inc.
  • Page 43: Using The Same Configuration Tag Elements In Requests And Responses

    For more information, see “Requesting Configuration Information” on page 64. Copyright © 2010, Juniper Networks, Inc.
  • Page 44 The tag streams emitted by the Junos XML protocol server and by a client application can differ in the use of white space, as described in “Spaces, Newline Characters, and Other White Space” on page 11. Copyright © 2010, Juniper Networks, Inc.
  • Page 45: Using The Junos Xml Management Protocol

    Requesting Information on page 61 Changing Configuration Information on page 103 Committing a Configuration on page 133 Summary of Junos XML Protocol Tag Elements on page 149 Summary of Attributes in Junos XML Tags on page 183 Copyright © 2010, Juniper Networks, Inc.
  • Page 46 Junos 10.3 Junos XML Management Protocol Guide Copyright © 2010, Juniper Networks, Inc.
  • Page 47: Controlling The Junos Xml Management Protocol Session

    Creating a private copy of the configuration enables the application to make changes without affecting the candidate or active configuration until the copy is committed. Copyright © 2010, Juniper Networks, Inc.
  • Page 48: Establishing A Junos Xml Management Protocol Session

    Starting the Junos XML Protocol Session on page 38 Authenticating with the Junos XML Protocol Server on page 43 For an example of a complete Junos XML protocol session, see “Example of a Junos XML Protocol Session” on page 56. Copyright © 2010, Juniper Networks, Inc.
  • Page 49: Supported Access Protocols

    Junos XML protocol server. The following instructions explain how to create a Junos login account for the application; for detailed information, see the chapter about configuring user access in the Junos System Basics Configuration Guide. Copyright © 2010, Juniper Networks, Inc.
  • Page 50 To enter a password as text, issue the following command. You are prompted for the password, which is encrypted before being stored. [edit system login user account-name authentication] user@host# set plain-text-password New password: password Retype new password: password Copyright © 2010, Juniper Networks, Inc.
  • Page 51: Prerequisites For Clear-Text Connections

    Configure the device running Junos OS to accept clear-text connections from client applications on port 3221 by including the xnm-clear-text statement at the [edit hierarchy level: system services] [edit] user@host# set system services xnm-clear-text Copyright © 2010, Juniper Networks, Inc.
  • Page 52: Prerequisites For Ssh Connections

    SSH version 2. For more information, see the man page provided by your SSH vendor for the ssh-keygen command. The Junos OS uses SSH version 2 by default but also supports version 1. % ssh-keygen options Copyright © 2010, Juniper Networks, Inc.
  • Page 53: Prerequisites For Outbound Ssh Connections

    TCP/IP connections are blocked (for example, when the device is behind a firewall). To configure outbound SSH, you add an configuration statement to the device. outbound-ssh Once configured and committed, the device running Junos OS will begin to initiate Copyright © 2010, Juniper Networks, Inc.
  • Page 54 [edit system services] outbound-ssh client { application-id { device-id device-id; secret secret; keep-alive { retry number; timeout number; reconnect-strategy (sticky | in-order) ; services netconf; address { port destination-port; retry number; timeout number; Copyright © 2010, Juniper Networks, Inc.
  • Page 55 You can list multiple clients by adding each client's IP address or host name along with the connection parameters listed below. —Outbound SSH port for the client. The default is port 22. port destination-port Copyright © 2010, Juniper Networks, Inc.
  • Page 56 If the secret attribute is not configured, the device does not send its public SSH key along with the initialization sequence. You need to manually install the current public SSH key for the device. MSG-ID: DEVICE-CONN-INFO\r\n MSG-VER: V1\r\n DEVICE-ID: <device-id>\r\n Copyright © 2010, Juniper Networks, Inc.
  • Page 57: Prerequisites For Ssl Connections

    URL to its location on the client computer or a pathname on the local disk (if you have already used another method to copy the certificate file to the device’s local disk). For more information about specifying URLs and pathnames, see the Junos CLI User Guide. Copyright © 2010, Juniper Networks, Inc.
  • Page 58 Configuration Guide. Commit the configuration: [edit] user@host# commit Repeat Step 1 on each computer where the client application runs, and Step 2 through Step 6 on each device to which the client application connects. Copyright © 2010, Juniper Networks, Inc.
  • Page 59: Prerequisites For Telnet Connections

    When the prerequisites are satisfied, an application written in Perl can most efficiently establish a connection and open a session by using the Junos XML protocol Perl module provided by Juniper Networks. For more information, see “Writing Junos XML Protocol Perl Client Applications” on page 205.
  • Page 60: Connecting To The Junos Xml Protocol Server From The Cli

    Each Junos XML protocol session begins with a handshake in which the Junos XML protocol server and the client application specify the version of XML and the version of the Junos XML management protocol they are using. Each party parses the version Copyright © 2010, Juniper Networks, Inc.
  • Page 61: Emitting The Initialization Pi And Tag

    PI before emitting the opening <?xml?> tag, the Junos XML protocol server emits an error message and immediately <junoscript> closes the session and connection. For more information, see “Emitting the Opening <junoscript> Tag” on page 40. Copyright © 2010, Juniper Networks, Inc.
  • Page 62 . The attribute indicates that the switch, router, or security client1 release="10.3R1" device is running the initial version of Junos OS Release 10.3. <junoscript version="1.0" hostname="client1" release="10.3R1"> Copyright © 2010, Juniper Networks, Inc.
  • Page 63: Server

    Parsing the Junos XML Protocol Server’s Opening <junoscript> Tag After emitting the PI, the server then emits its opening tag, which <?xml?> <junoscript> has the following form (the tag appears on multiple lines only for legibility): <junoscript xmlns="namespace-URL" xmlns:junos="namespace-URL" \ Copyright © 2010, Juniper Networks, Inc.
  • Page 64 It is presumably in use on the device where the Junos XML protocol server is running. The value of the release attribute uses the standard notation for Juniper Networks software version numbers. For example, the value 10.3R1 represents the initial version of Junos OS Release 10.3.
  • Page 65: Verifying Software Compatibility

    Junos XML protocol server. (Applications that use the SSH or Telnet protocol use the protocol’s built-in authentication mechanism before emitting initialization tag elements, as described in “Connecting to the Junos XML Protocol Server” on page 37.) Copyright © 2010, Juniper Networks, Inc.
  • Page 66: Submitting An Authentication Request

    The tag sequence is as follows: <rpc-reply xmlns:junos="URL"> <challenge echo="no">Password:</challenge> </rpc-reply> The client application obtains the password and emits the following tag sequence to forward it to the Junos XML protocol server: <rpc> Copyright © 2010, Juniper Networks, Inc.
  • Page 67: Interpreting The Authentication Response

    Exchanging Information with the Junos XML Protocol Server The session continues when the client application sends a request to the Junos XML protocol server. The Junos XML protocol server does not emit any tag elements after Copyright © 2010, Juniper Networks, Inc.
  • Page 68: Sending A Request To The Junos Xml Protocol Server

    Operational requests are requests for information about the status of a device running Junos OS. Operational requests correspond to the CLI operational mode commands listed in the Junos OS command references. The Junos XML API defines a request tag Copyright © 2010, Juniper Networks, Inc.
  • Page 69 Junos OS. The Junos XML protocol defines the <load-configuration> operation for changing configuration information. The Junos XML API defines a tag element for every CLI configuration statement described in the Junos OS configuration guides. Copyright © 2010, Juniper Networks, Inc.
  • Page 70: Including Attributes In The Opening Tag

    “xmlns:junos Attribute” on page 49. The tag element occurs only <rpc-reply> within the <junoscript> tag element. Client applications must include code for parsing Copyright © 2010, Juniper Networks, Inc.
  • Page 71: Xmlns:junos Attribute

    Junos OS Release 10.3. <rpc-reply xmlns:junos="http://xml.juniper.net/junos/10.3R1/junos"> <interface-information xmlns="http://xml.juniper.net/junos/10.3R1/junos-interface"> <physical-interface> <name>ge-2/3/0</name> <!-- other data tag elements for the ge-2/3/0 interface -??-> </physical-interface> Copyright © 2010, Juniper Networks, Inc.
  • Page 72: Using A Standard Api To Parse Response Tag Elements

    Using a Standard API to Parse Response Tag Elements Client applications can handle incoming XML tag elements by feeding them to a parser that implements a standard API such as the Document Object Model (DOM) or Simple Copyright © 2010, Juniper Networks, Inc.
  • Page 73: Handling An Error Or Warning

    Processing an operational request submitted by a client application (discussed in “Requesting Information” on page 61) Copyright © 2010, Juniper Networks, Inc.
  • Page 74: Halting A Request

    Create a private copy of the candidate configuration, which enables the application to view or change configuration data without affecting the candidate or active configuration until the private copy is committed (equivalent to the CLI configure private command). Copyright © 2010, Juniper Networks, Inc.
  • Page 75: Locking The Candidate Configuration

    Reasons <xnm:error> for the failure can include the following: Another user or application has already locked the candidate configuration. The error message reports the login identity of the user or application. Copyright © 2010, Juniper Networks, Inc.
  • Page 76: Unlocking The Candidate Configuration

    After making changes to the private copy, the client application can commit the changes to the active configuration on the device running Junos OS by emitting the tag element, as for the regular candidate configuration. However, <commit-configuration> Copyright © 2010, Juniper Networks, Inc.
  • Page 77: Ending A Junos Xml Protocol Session And Closing The Connection

    The client application waits to receive this reply before emitting its closing </junoscript> tag: </junoscript> For an example of the exchange of closing tags, see “Closing the Junos XML Protocol Session” on page 59. Copyright © 2010, Juniper Networks, Inc.
  • Page 78: Displaying Cli Output As Xml Tag Elements

    The client application begins by establishing a connection to a Junos XML protocol server. See the following sections: Exchanging Initialization PIs and Tag Elements on page 57 Sending an Operational Request on page 57 Copyright © 2010, Juniper Networks, Inc.
  • Page 79: Exchanging Initialization Pis And Tag Elements

    <!- - tags for other chassis modules- -> </chassis> </chassis-inventory> </rpc-reply> Locking the Configuration The client application then prepares to create a new privilege class called network-mgmt at the hierarchy level. It begins by using the [edit system login class] <lock-configuration/> Copyright © 2010, Juniper Networks, Inc.
  • Page 80: Changing The Configuration

    The client application commits the candidate configuration. The Junos XML protocol server returns the tag element to enclose tag elements that report the <commit-results> outcome of the commit operation (for information about these tag elements, see “Committing a Configuration” on page 133). Copyright © 2010, Juniper Networks, Inc.
  • Page 81: Unlocking The Configuration

    <rpc-reply xmlns:junos="URL "> </rpc-reply> Closing the Junos XML Protocol Session The client application closes the Junos XML protocol session. Client Application Junos XML Protocol Server <rpc> <request-end-session/> </rpc> <rpc-reply xmlns:junos="URL "> <end-session/> </rpc-reply> </junoscript> </junoscript> Copyright © 2010, Juniper Networks, Inc.
  • Page 82 Junos 10.3 Junos XML Management Protocol Guide Copyright © 2010, Juniper Networks, Inc.
  • Page 83: Requesting Information

    Requesting an XML Schema for the Configuration Hierarchy on page 94 Requesting a Previous (Rollback) Configuration on page 97 Comparing Two Previous (Rollback) Configurations on page 99 Requesting the Rescue Configuration on page 100 Copyright © 2010, Juniper Networks, Inc.
  • Page 84: Overview Of The Request Procedure

    “Mapping Between Operational Tag Elements, Perl Methods, and CLI Commands” and “Summary of Operational Request Tag Elements.” The application encloses the request tag element in an tag element. The syntax <rpc> depends on whether the corresponding CLI command has any options: <rpc> Copyright © 2010, Juniper Networks, Inc.
  • Page 85: Parsing The Tag Element

    The tag element’s contents are usually one or more lines of <output> formatted ASCII output like that displayed by the CLI on the computer screen For a reference page for the <output> tag element, see the Junos XML API Operational Reference. Copyright © 2010, Juniper Networks, Inc.
  • Page 86: Requesting Configuration Information

    <configuration junos:(changed | commit)-seconds="seconds" \ junos:(changed | commit)-localtime="YYYY-MM-DD hh:mm:ss TZ" \ [junos:commit-user="username"]> <!-- Junos XML tag elements representing configuration elements --> </configuration> <!-- If the application requests formatted ASCII text --> <configuration-text> <!-- formatted ASCII configuration statements --> Copyright © 2010, Juniper Networks, Inc.
  • Page 87: Specifying The Source And Output Format Of Configuration Information

    <undocumented> corresponding configuration element is not documented in the Junos OS configuration guides or officially supported by Juniper Networks. Most often, the enclosed element is used for debugging only by support personnel. In a smaller number of cases, the element is no longer supported or has been moved to another area of the configuration hierarchy, but appears in the current location for backward compatibility.
  • Page 88 (they appear on multiple lines here only for legibility): <rpc-reply xmlns:junos="URL"> <configuration junos:commit-seconds="seconds" \ junos:commit-localtime="YYYY-MM-DD hh:mm:ss TZ" \ junos:commit-user="username"> <!-- Junos XML tag elements representing configuration elements --> </configuration> Copyright © 2010, Juniper Networks, Inc.
  • Page 89 <get-configuration database="committed"/> </rpc> <rpc-reply xmlns:junos="URL "> <configuration \ junos:commit-seconds="seconds " \ junos:commit-localtime="timestamp" \ junos:commit-user="username"> <version>JUNOS-version </version> <system> <host-name>big-router</host-name> <!- - other children of <system>- -> </system> <!- - other children of <configuration>- -> </configuration> </rpc-reply> Copyright © 2010, Juniper Networks, Inc.
  • Page 90: Requesting Output As Formatted Ascii Text Or Junos Xml Tag Elements

    “Requesting Information <configuration> from the Committed or Candidate Configuration” on page 65. <rpc-reply xmlns:junos="URL"> <configuration attributes> <!-- Junos XML tag elements representing configuration elements --> </configuration> </rpc-reply> Copyright © 2010, Juniper Networks, Inc.
  • Page 91 “Specifying the Scope of Configuration Information to Return” on page 81. The following example shows how to request formatted ASCII output from the hierarchy level in the candidate configuration. [edit policy-options] Copyright © 2010, Juniper Networks, Inc.
  • Page 92: Requesting A Change Indicator For Configuration Elements

    If the changed element is represented by a container tag element, the attribute appears in the opening container tag and also in the junos:changed="changed" opening tag for each child tag element enclosed in the container tag element. Copyright © 2010, Juniper Networks, Inc.
  • Page 93 Elements added to the candidate configuration after the last commit operation are marked with the junos:changed="changed" attribute. Copyright © 2010, Juniper Networks, Inc.
  • Page 94 <rpc-reply xmlns:junos="URL "> <configuration junos:changed-seconds=" seconds " \ junos:changed-localtime="timestamp" junos:changed="changed"> <system junos:changed="changed"> <syslog junos:changed="changed"> <file> <name>messages</name> <contents> <name>any</name> <info/> </contents> </file> <file junos:changed="changed"> <name junos:changed="changed">interactive-commands</name> <contents> <name junos:changed="changed">interactive-commands</name> <notice junos:changed="changed"/> </contents> </file> </syslog> </system> </configuration> </rpc-reply> Copyright © 2010, Juniper Networks, Inc.
  • Page 95: Requesting An Indicator For Identifiers

    Junos XML-tagged output, which is the default output format. The following example shows how indicators for identifiers appear on configuration elements at the hierarchy level in the candidate configuration when the [edit interfaces] Copyright © 2010, Juniper Networks, Inc.
  • Page 96: Specifying The Output Format For Configuration Groups

    Junos XML protocol server for the <get-configuration> tag element. For more information about user-defined configuration groups and the group, see the Junos CLI User Guide. junos-defaults Copyright © 2010, Juniper Networks, Inc.
  • Page 97: Specifying Whether Configuration Groups Are Displayed Separately

    CLI configuration mode command, and does not include configuration elements inherited from the junos-defaults group: user@host# show | display inheritance | except ## Copyright © 2010, Juniper Networks, Inc.
  • Page 98: Displaying The Source Group For Inherited Configuration Elements

    It encloses the request in an <rpc> tag element: <rpc> <get-configuration inherit="(defaults | inherit)" groups="groups"/> <!-- OR --> <get-configuration inherit="(defaults | inherit)" groups="groups"> <!-- tag elements for the configuration elements to return --> </get-configuration> Copyright © 2010, Juniper Networks, Inc.
  • Page 99 If the output is formatted ASCII text (the attribute is included), the format="text" Junos XML protocol server encloses its response in <configuration-text> tag elements, and inserts three commented lines immediately above <rpc-reply> each inherited element, as in the following: <rpc-reply xmlns:junos="URL"> Copyright © 2010, Juniper Networks, Inc.
  • Page 100: Examples: Specifying Output Format For Configuration Groups

    The placement of the tag element directly above the <apply-groups> <interfaces> element indicates that the [edit interfaces] hierarchy inherits the statements defined in configuration group. interface-group Copyright © 2010, Juniper Networks, Inc.
  • Page 101 </interfaces> </configuration> </rpc-reply> When the attribute is included in the tag, the inherit <get-configuration/> <interfaces> tag element encloses the tag elements defined in the interface-group configuration group. tag elements are not displayed. <groups> <apply-groups> Copyright © 2010, Juniper Networks, Inc.
  • Page 102 </rpc> <rpc-reply xmlns:junos="URL "> <configuration junos:changed-seconds=" seconds " \ junos:changed-localtime="timestamp"> <interfaces> <interface> <name>fxp0</name> <unit> <name>0</name> <family> <inet> <address> <name>192.168.4.207/24</name> </address> </inet> </family> </unit> </interface> <interface junos:group="interface-group"> <name junos:group="interface-group">so-1/1/1</name> <encapsulation junos:group="interface-group">ppp</encapsulation> </interface> </interfaces> </configuration> </rpc-reply> Copyright © 2010, Juniper Networks, Inc.
  • Page 103: Specifying The Scope Of Configuration Information To Return

    The following example shows how to request the complete candidate configuration tagged with Junos XML tag elements (the default). In actual output, the JUNOS-version variable is replaced by a value such as for the initial version of Junos OS Release 10.3R1 10.3. Copyright © 2010, Juniper Networks, Inc.
  • Page 104: Requesting A Hierarchy Level Or Container Object Without An Identifier

    (for example, formatted ASCII text or an indicator for identifiers), the application can include attributes in the opening tag, <get-configuration> its opening <junoscript> tag, or both. For more information, see “Specifying the Source and Output Format of Configuration Information” on page 65. Copyright © 2010, Juniper Networks, Inc.
  • Page 105: Requesting All Configuration Objects Of A Specified Type

    Container Object Without an Identifier” on page 82). <rpc> <get-configuration> <configuration> <!-- opening tags for each parent of the object type --> <object-type/> <!-- closing tags for each parent of the object type --> Copyright © 2010, Juniper Networks, Inc.
  • Page 106: Requesting A Specified Number Of Configuration Objects

    (If the application is requesting only the first object in the hierarchy, it includes the attribute and omits the attribute.) The application encloses the entire count="1" start request in an tag element: <rpc> <rpc> <get-configuration> <configuration> Copyright © 2010, Juniper Networks, Inc.
  • Page 107 The application can also request additional configuration elements of the same or other types by including the appropriate tag elements in the same <get-configuration> element. For more information, see “Requesting Multiple Configuration Elements Simultaneously” on page 93. Copyright © 2010, Juniper Networks, Inc.
  • Page 108: Requesting Identifiers Only

    <rpc> <get-configuration> <configuration> <!-- opening tags for each parent of the object type --> <object-type recurse="false"/> <!-- closing tags for each parent of the object type --> </configuration> </get-configuration> </rpc> Copyright © 2010, Juniper Networks, Inc.
  • Page 109 The application can also request additional configuration elements of the same or other types by including the appropriate tag elements in the same <get-configuration> element. For more information, see “Requesting Multiple Configuration Elements Simultaneously” on page 93. Copyright © 2010, Juniper Networks, Inc.
  • Page 110: Requesting One Configuration Object

    In the following, the identifier tag element is called <rpc> name <rpc> <get-configuration> <configuration> <!-- opening tags for each parent of the object --> <object> <name>identifier</name> </object> <!-- closing tags for each parent of the object --> </configuration> </get-configuration> </rpc> Copyright © 2010, Juniper Networks, Inc.
  • Page 111 [edit routing-options multicast] desired object, the client application emits the identifier tag <name>local</name> element as the innermost tag element. The output is from the candidate configuration and is tagged with Junos XML tag elements (the default). Copyright © 2010, Juniper Networks, Inc.
  • Page 112: Requesting A Subset Of Objects By Using Regular Expressions

    The angle brackets around tag element names are omitted, and the opening tag is used to represent the entire tag element. For example, the following XPath: configuration/system/radius-server/name is equivalent to the following tagged representation: <configuration> <system> <radius-server> <name/> </radius-server> </system> </configuration> Copyright © 2010, Juniper Networks, Inc.
  • Page 113: Table 7: Regular Expression Operators For The Matching Attribute

    The start of a line, when the caret appears outside square brackets. One instance of any character that does not follow it within square brackets, when the caret is the first character inside square brackets. Copyright © 2010, Juniper Networks, Inc.
  • Page 114 The application can request additional configuration elements of the same or other types in the same tag element by including the appropriate tag elements. <get-configuration> For more information, see “Requesting Multiple Configuration Elements Simultaneously” on page 93. Copyright © 2010, Juniper Networks, Inc.
  • Page 115: Requesting Multiple Configuration Elements Simultaneously

    <!-- both requests in one parent tag element --> <rpc> <get-configuration> <configuration> <system> <services/> <radius-server> <name/> </radius-server> </system> </configuration> </get-configuration> </rpc> <!-- separate parent tag element for each request --> <rpc> <get-configuration> <configuration> Copyright © 2010, Juniper Networks, Inc.
  • Page 116: Requesting An Xml Schema For The Configuration Hierarchy

    <get-software-information> XML API Operational Reference.) Client applications can use the schema to validate the configuration on a device, or simply to learn which configuration statements are available in the version of the Junos OS Copyright © 2010, Juniper Networks, Inc.
  • Page 117: Creating The Junos.xsd File

    Junos OS running on the device (for example, for the 10.3R1 first release of Junos OS 10.3). <?xml version="1.0" encoding="us-ascii"?> <xsd:schema elementFormDefault="qualified" \ attributeFormDefault="unqualified" \ xmlns:xsd="http://www.w3.org/2001/XMLSchema" \ targetNamespace="http://xml.juniper.net/junos/Junos-version/junos"> <xsd:element name="comment" type="xsd:string"/> </xsd:schema> Copyright © 2010, Juniper Networks, Inc.
  • Page 118: Example: Requesting An Xml Schema

    Junos <xsd:element> tag element. It encloses the statement that defines <configuration> <xsd:element> <system> tag element, which corresponds to the [edit system] hierarchy level. The statements corresponding to other hierarchy levels are omitted for brevity. Copyright © 2010, Juniper Networks, Inc.
  • Page 119: Requesting A Previous (Rollback) Configuration

    “Requesting Information from the <configuration> Committed or Candidate Configuration” on page 65. <rpc-reply xmlns:junos="URL"> <rollback-information> <load-success/> <configuration attributes> <!-- tag elements representing the complete previous configuration --> </configuration> Copyright © 2010, Juniper Networks, Inc.
  • Page 120 <rollback-information> <load-success/> <configuration junos:changed-seconds="seconds " \ junos:changed-localtime="timestamp" > <version>JUNOS-ver sion</ver sion> <system> <host-name>big-router</host-name> <!- - other children of <system>- -> </system> <!- - other children of <configuration> - -> </configuration> </rollback-infor mation> </r pc-reply> Copyright © 2010, Juniper Networks, Inc.
  • Page 121: Comparing Two Previous (Rollback) Configurations

    The following example shows how to request a comparison of the rollback configurations that have indexes of Copyright © 2010, Juniper Networks, Inc.
  • Page 122: Requesting The Rescue Configuration

    API Operational Reference or the Junos System Basics and Services Command Reference.) To request Junos XML-tagged output, the application either includes the <format> element with the value or omits the <format> tag element (Junos XML tag elements are the default): <rpc> <get-rescue-information/> </rpc> Copyright © 2010, Juniper Networks, Inc.
  • Page 123 ASCII output is formatted, see “Requesting Output as Formatted ASCII Text or Junos XML Tag Elements” on page 68. <rpc-reply xmlns:junos="URL"> <rescue-information> <load-success/> <configuration-information> <configuration-output> <!-- formatted ASCII text representing the rescue configuration --> </configuration-output> </configuration-information> </rescue-information> </rpc-reply> Copyright © 2010, Juniper Networks, Inc.
  • Page 124 Junos 10.3 Junos XML Management Protocol Guide Copyright © 2010, Juniper Networks, Inc.
  • Page 125: Changing Configuration Information

    “Locking the Candidate Configuration” on page 53 and “Creating a Private Copy of the Configuration” on page 54. Locking the configuration prevents other users or applications from changing it at the same time. Creating a private copy enables the Copyright © 2010, Juniper Networks, Inc.
  • Page 126 (Optional) Verifies the syntactic correctness of a configuration before attempting to commit it, as described in “Verifying a Configuration Before Committing It” on page 133. Commits changes made to the configuration, as described in “Committing a Configuration” on page 133. Copyright © 2010, Juniper Networks, Inc.
  • Page 127: Specifying The Source And Format Of New Configuration Data

    —File on the local drive. The default path is (the a:filename a:path/filename root-level directory). The removable media can be in MS-DOS or UNIX (UFS) format. A filename on an FTP server has the following form: Copyright © 2010, Juniper Networks, Inc.
  • Page 128: Providing Configuration Data As A Data Stream

    </configuration> </load-configuration> </rpc> To define the configuration elements to change as formatted ASCII text, the application encloses them in a tag element and includes the <configuration-text> format="text" attribute in the opening tag: <load-configuration> <rpc> Copyright © 2010, Juniper Networks, Inc.
  • Page 129: Elements

    When providing new data as ASCII text, the application also includes the format="text" attribute in the tag or opening tag. <load-configuration/> <load-configuration> <rpc> <load-configuration url="file-location" format="text"/> </rpc> <rpc> <load-configuration format="text"> <configuration-text> Copyright © 2010, Juniper Networks, Inc.
  • Page 130: Replacing The Entire Configuration

    The following example shows how to specify that the contents of the file /tmp/new.conf replace the entire candidate configuration. The file contains Junos XML tag elements (the default), so the attribute is omitted. format Copyright © 2010, Juniper Networks, Inc.
  • Page 131: Rolling Back To A Previous Or Rescue Configuration

    <name>identifier</name> <!-- if the element has an identifier --> <!-- other child tag elements --> <!-- if appropriate for the operation --> </container-tag> <!-- closing tag for each parent of the element --> </configuration> Copyright © 2010, Juniper Networks, Inc.
  • Page 132: Merging Configuration Elements

    If a child statement exists in the loaded configuration but not in the candidate, it is added to the candidate. If a child statement exists in both configurations, the value in the loaded configuration replaces the value in the candidate. Copyright © 2010, Juniper Networks, Inc.
  • Page 133 The following example shows how to merge in a new interface called at the so-3/0/0 [edit interfaces] hierarchy level in the candidate configuration. The information is provided as Junos XML tag elements (the default). Copyright © 2010, Juniper Networks, Inc.
  • Page 134 Client Application Junos XML Protocol Server <rpc> <load-configuration action="merge" format="text"> <configuration-text> interfaces { so-3/0/0 { unit 0 { family inet { address 10.0.0.1/8; </configuration-text> </load-configuration> </rpc> <rpc-reply xmlns:junos="URL "> <load-configuration-results> <load-success/> </load-configuration-results> </rpc-reply> Copyright © 2010, Juniper Networks, Inc.
  • Page 135: Replacing Configuration Elements

    /* closing braces for parent levels for the element */ </configuration-text> The following example shows how to grant new permissions for the object named operator at the hierarchy level. The information is provided in Junos [edit system login class] XML-tagged format (the default). Copyright © 2010, Juniper Networks, Inc.
  • Page 136: Creating New Configuration Elements

    New elements can be created in either merge mode or replace mode, which are described in “Merging Configuration Elements” on page 110 and “Replacing Configuration Elements” on page 113. In replace mode, the application includes the attribute in action="replace" tag or opening tag. <load-configuration/> <load-configuration> Copyright © 2010, Juniper Networks, Inc.
  • Page 137: Replacing Configuration Elements Only If They Have Changed

    When the configuration is later committed, only system processes that are affected by the changed configuration elements parse the new configuration. Copyright © 2010, Juniper Networks, Inc.
  • Page 138: Deleting Configuration Elements

    Deleting a Configuration Object That Has an Identifier on page 117 Deleting a Single-Value or Fixed-Form Option from a Configuration Object on page 118 Deleting Values from a Multivalue Option of a Configuration Object on page 120 Copyright © 2010, Juniper Networks, Inc.
  • Page 139: Deleting A Hierarchy Level Or Container Object

    To delete a configuration object that has an identifier, a client application includes the basic tag elements or configuration statements for its parent levels, as described in “Creating, Modifying, or Deleting Configuration Elements” on page 109. Copyright © 2010, Juniper Networks, Inc.
  • Page 140: Object

    Deleting a Single-Value or Fixed-Form Option from a Configuration Object To delete from a configuration object either a fixed-form option or an option that takes just one value, a client application includes the basic tag elements or configuration Copyright © 2010, Juniper Networks, Inc.
  • Page 141 [edit forwarding-options sampling] Client Application Junos XML Protocol Server <rpc> <load-configuration> <configuration> <forwarding-options> <sampling> <disable delete="delete"/> </sampling> </forw arding-options> </configuration> </load-configuration> </r pc> <rpc-reply xmlns:junos="URL "> <load-configuration-results> <load-success/> </load-configuration-results> </r pc-reply> Copyright © 2010, Juniper Networks, Inc.
  • Page 142: Deleting Values From A Multivalue Option Of A Configuration Object

    /* closing braces for parent levels of the parent object */ </configuration-text> The following example shows how to remove two of the permissions granted to the user-accounts login class. Copyright © 2010, Juniper Networks, Inc.
  • Page 143: Reordering Elements In Configuration Objects

    In the following, the elements in the set have one identifier, called <name> <configuration> <!-- opening tag for each parent of the set --> <ordered-set insert="(before | after)" name="referent-value"> <name>identifier-for-moving-object</name> </ordered-set> <!-- closing tag for each parent of the set --> </configuration> Copyright © 2010, Juniper Networks, Inc.
  • Page 144 . This operation is equivalent to the following neighbor-id 192.168.0.5 transit-area 1.1.1.2 configuration mode command (which appears on two lines for legibility only): [edit protocols ospf area area] Copyright © 2010, Juniper Networks, Inc.
  • Page 145: Renaming A Configuration Object

    <configuration> <!-- opening tag for each parent of the object --> <object rename="rename" changing-identifier="new-name" \ unchanging-identifier="current-name"> <changing-identifier>current-name</changing-identifier> <unchanging-identifier>current-name</unchanging-identifier> </object> <!-- closing tag for each parent of the object --> </configuration> Copyright © 2010, Juniper Networks, Inc.
  • Page 146 (which appears on two lines for legibility only): [edit protocols ospf area area] user@host# rename filter virtual-link neighbor-id 192.168.0.3 transit-area \ 1.1.1.1 to virtual-link neighbor-id 192.168.0.7 transit-area 1.1.1.5 Copyright © 2010, Juniper Networks, Inc.
  • Page 147: Changing A Configuration Element's Activation State

    <!-- opening tag for each parent of the element --> <element inactive="inactive"> <name>identifier</name> <!-- if the element has an identifier --> <!-- tag elements for each child of the element --> </element> <!-- closing tag for each parent of the element --> </configuration> Copyright © 2010, Juniper Networks, Inc.
  • Page 148: Deactivating Or Reactivating An Existing Element

    (even though in the existing configuration it is followed by curly braces that enclose its child statements): <configuration-text> /* statements for parent levels */ /* For an object with an identifier */ (inactive | active): Copyright © 2010, Juniper Networks, Inc.
  • Page 149: Changing A Configuration Element's Activation State Simultaneously With Other

    Replacing an Element and Setting Its Activation State on page 128 Reordering an Element and Setting Its Activation State on page 129 Renaming an Object and Setting Its Activation State on page 129 Example: Replacing an Object and Deactivating It on page 130 Copyright © 2010, Juniper Networks, Inc.
  • Page 150: Replacing An Element And Setting Its Activation State

    <load-configuration/> opening tag: <load-configuration> <rpc> <!-- For a file --> <load-configuration action="replace" format="text" url="file"/> <!-- For a data stream --> <load-configuration action="replace" format="text"> <!-- formatted ASCII configuration statements --> </load-configuration> </rpc> Copyright © 2010, Juniper Networks, Inc.
  • Page 151: Reordering An Element And Setting Its Activation State

    ), the syntax is as follows (the opening <name> tag appears on two lines for legibility only): <configuration> <!-- opening tag for each parent of the object --> <object rename="rename" name="new-name" \ (inactive="inactive” | active="active")> <name>current-name</name> Copyright © 2010, Juniper Networks, Inc.
  • Page 152: Example: Replacing An Object And Deactivating It

    <name>G3</name> <type>external</type> <peer-as>58</peer-as> <neighbor> <name>10.0.20.1</name> </neighbor> </group> </bgp> </protocols> </configuration> </load-configuration> </rpc> <rpc-reply xmlns:junos="URL "> <load-configuration-results> <load-success/> </load-configuration-results> </rpc-reply> The following example shows how to use formatted ASCII text to make the same changes: Copyright © 2010, Juniper Networks, Inc.
  • Page 153 Junos XML Protocol Server <rpc> <load-configuration action="replace" format="text"> <configuration-text> protocols { bgp { replace: inactive: group G3 { type external; peer-as 58; neighbor 10.0.20.1; </configuration-text> </load-configuration> </rpc> <rpc-reply xmlns:junos="URL "> <load-configuration-results> <load-success/> </load-configuration-results> </rpc-reply> Copyright © 2010, Juniper Networks, Inc.
  • Page 154 Junos 10.3 Junos XML Management Protocol Guide Copyright © 2010, Juniper Networks, Inc.
  • Page 155: Committing A Configuration

    Routing Engine on which the check succeeded ( routing platforms that use a single Routing Engine, and either on routing platforms that can have two Routing Engines): <rpc-reply xmlns:junos="URL"> <commit-results> <routing-engine> <name>(re0 | re1)</name> Copyright © 2010, Juniper Networks, Inc.
  • Page 156: Committing The Candidate Configuration

    </routing-engine> </commit-results> </rpc-reply> If the commit operation fails, an tag element encloses tag elements that <xnm:error> describe the error. The most common causes of failure are semantic or syntactic errors in the candidate configuration. Copyright © 2010, Juniper Networks, Inc.
  • Page 157: Committing A Private Copy Of The Configuration

    Most of the variants of the commit operation are available for a private copy. The variants are described in subsequent sections in this chapter: Scheduling the commit for a later time, as described in “Committing a Configuration at a Specified Time” on page 136. Copyright © 2010, Juniper Networks, Inc.
  • Page 158: Committing A Configuration At A Specified Time

    2006-08-21 15:30:00 The time is interpreted relative to the clock and time zone settings on the device. NOTE: The specified time must be more than 1 minute later than the current time on the device. Copyright © 2010, Juniper Networks, Inc.
  • Page 159: Committing The Candidate Configuration Only After Confirmation

    Committing the Candidate Configuration Only After Confirmation To commit the candidate configuration but require an explicit confirmation for the commit to become permanent, a client application encloses the empty tag in <confirmed/> tag elements: <commit-configuration> <rpc> <rpc> Copyright © 2010, Juniper Networks, Inc.
  • Page 160 10 minutes. The application can delay the rollback indefinitely by emitting the <confirmed/> tag repeatedly in this way. Copyright © 2010, Juniper Networks, Inc.
  • Page 161 “Committing and Synchronizing a Configuration on Redundant Control Planes” on page 140 and “Logging a Message About a Commit Operation” on page 145. The following example shows how to commit the candidate configuration on Routing Engine 1 with a rollback deadline of 20 seconds. Copyright © 2010, Juniper Networks, Inc.
  • Page 162: Committing And Synchronizing A Configuration On Redundant Control

    Routing Engine architectures. Further, configuration groups must be defined on each routing, swtiching, or security platform. For more information about configuration groups, see the Junos CLI User Guide. Copyright © 2010, Juniper Networks, Inc.
  • Page 163: Synchronizing The Configuration On Both Routing Engines

    <name>(re0 | re1)</name> <commit-success/> </routing-engine> If the commit operation fails, an <xnm:error> tag element encloses a description of the error. The most common causes of failure are semantic or syntactic errors in the configuration. Copyright © 2010, Juniper Networks, Inc.
  • Page 164: Example: Synchronizing The Configuration On Both Routing Engines

    NOTE: When you use a command, any uncommitted changes to the force-synchronize configuration will be lost. To force a synchronization, enclose the empty <synchronize/> <force-synchronize/> tags in the <commit-configuration> <rpc> tag elements: <rpc> <commit-configuration> <synchronize/> <force-synchronize/> </commit-configuration> </rpc> Copyright © 2010, Juniper Networks, Inc.
  • Page 165: Example: Forcing A Synchronization

    Verifying the Configuration on Both Routing Engines To check the syntactic correctness of a local configuration on both Routing Engines without committing it, the application encloses the <synchronize/> <check/> elements in <commit-configuration> <rpc> tag elements: <rpc> <commit-configuration> Copyright © 2010, Juniper Networks, Inc.
  • Page 166: Scheduling Synchronization For A Specified Time

    The same rollback deadline applies to both Routing Engines and can be extended on both at once by again emitting the , and (optionally) <synchronize/> <confirmed/> <confirm-timeout> tag elements on the Routing Engine where the tag elements were emitted the first time. Copyright © 2010, Juniper Networks, Inc.
  • Page 167: Logging A Message About Synchronized Configurations

    <confirm-timeout> <synchronize/> the operation. When the <log> tag element is emitted by itself, the associated commit operation begins immediately. The following example shows how to log a message as the candidate configuration is committed. Copyright © 2010, Juniper Networks, Inc.
  • Page 168 Junos XML API Operational Reference. <rpc-reply xmlns:junos="URL"> <commit-information> <!-- tag elements representing the commit log --> </commit-information> </rpc-reply> The following example shows how to request the commit log. Copyright © 2010, Juniper Networks, Inc.
  • Page 169 <rpc-reply xmlns:junos="URL "> <commit-information> <commit-history> <sequence-number>0</sequence-number> <user>barbara</user> <client>other</client> <date-time junos:seconds="1058370173">2003-07-16 08:42:53 PDT</date-time> <log>Enable xnm-ssl service</log> </commit-history> <commit-history> <sequence-number>1</sequence-number> <user>root</user> <client>other</client> <date-time junos:seconds="1058322166">2003-07-15 19:22:46 PDT</date-time> </commit-history> <commit-history> <sequence-number>2</sequence-number> <user>root</user> <client>cli</client> <date-time junos:seconds="1058219717">2003-07-14 14:55:17 PDT</date-time> </commit-history> </commit-information> </rpc-reply> Copyright © 2010, Juniper Networks, Inc.
  • Page 170 Junos 10.3 Junos XML Management Protocol Guide Copyright © 2010, Juniper Networks, Inc.
  • Page 171: Summary Of Junos Xml Protocol Tag Elements

    The client application must discard those tag elements. Usage Guidelines See “Halting a Request” on page 52. Related Topics <abort-acknowledgement/> on page 150 <rpc> on page 176 Copyright © 2010, Juniper Networks, Inc.
  • Page 172: Abort-Acknowledgement

    <abort/> them. Usage Guidelines See “Halting a Request” on page 52. Related Topics <rpc-reply> on page 177 <xnm:error> on page 179 Copyright © 2010, Juniper Networks, Inc.
  • Page 173: Authentication-Response

    —The attempt succeeded. An authenticated connection to the Junos XML success protocol server is established. Usage Guidelines See “Interpreting the Authentication Response” on page 45. Related Topics <challenge> on page 152 <request-login> on page 174 <rpc-reply> on page 177 Copyright © 2010, Juniper Networks, Inc.
  • Page 174: Challenge

    —Specifies whether the password string typed by the user appears on the screen. echo The value specifies that it does not. Usage Guidelines See “Submitting an Authentication Request” on page 44. Related Topics <authentication-response> on page 151 <request-login> on page 174 <rpc-reply> on page 177 Copyright © 2010, Juniper Networks, Inc.
  • Page 175: Checksum-Information

    —Checksum algorithm used. Currently, all checksum computations use the MD5 algorithm; thus, the only possible value is MD5. —Resulting value from the checksum computation. <checksum> Usage Guidelines See the Junos XML API Operational Reference. Related Topics <get-checksum-information> on page 162 Copyright © 2010, Juniper Networks, Inc.
  • Page 176: Close-Configuration

    Usage Guidelines See “Creating a Private Copy of the Configuration” on page 54. Related Topics <open-configuration> on page 172 <request-end-session/> on page 173 <rpc> on page 176 Copyright © 2010, Juniper Networks, Inc.
  • Page 177: Commit-Configuration

    <commit-configuration> <at-time>time-specification</at-time> <log>log-message</log> </commit-configuration> <commit-configuration> <confirmed/> <confirm-timeout>rollback-delay</confirm-timeout> <log>log-message</log> </commit-configuration> <commit-configuration> <synchronize/> <log>log-message</log> </commit-configuration> <commit-configuration> <synchronize/> <at-time>time-specification</at-time> <log>log-message</log> </commit-configuration> <commit-configuration> <synchronize/> <check/> <log>log-message</log> </commit-configuration> <commit-configuration> <synchronize/> <confirmed/> <confirm-timeout>rollback-delay</confirm-timeout> <log>log-message</log> </commit-configuration> <commit-configuration> <synchronize/> <force-synchronize/> </commit-configuration> </rpc> Copyright © 2010, Juniper Networks, Inc.
  • Page 178 NOTE: The confirmed commit operation is not available for a private copy of the configuration. On a device with two Routing Engines, commit the candidate configuration stored on the local Routing Engine on both Routing Engines. Combine tag elements as indicated in the following: Copyright © 2010, Juniper Networks, Inc.
  • Page 179 To force the same synchronized commit operation as invoked by the <synchronize/> tag to succeed, even if there are open configuration sessions or uncommitted configuration changes on the remote machine, enclose the <force-synchronize/> tag in the <commit-configuration> tag element. Copyright © 2010, Juniper Networks, Inc.
  • Page 180 Routing Engines. <force-synchronize> —On dual control plane systems, forces the candidate configuration on one control plane to be copied to the other control plane. Copyright © 2010, Juniper Networks, Inc.
  • Page 181: Commit-Results

    Routing Engine. <routing-engine> tag element is described separately. Usage Guidelines See “Committing a Configuration” on page 133. Related Topics <commit-configuration> on page 155 <routing-engine> on page 175 <rpc-reply> on page 177 Copyright © 2010, Juniper Networks, Inc.
  • Page 182: Database-Status

    —Identifies the UNIX terminal assigned to the user’s connection. <terminal> —Specifies the Junos OS login ID of the user whose login to the configuration <user> database caused the error. Usage Guidelines See “Handling an Error or Warning” on page 51. Copyright © 2010, Juniper Networks, Inc.
  • Page 183: Database-Status-Information

    Most often, the reason is that the client application has sent <request-end-session/> tag. Usage Guidelines See “Ending a Junos XML Protocol Session and Closing the Connection” on page 55. Related Topics <request-end-session/> on page 173 <rpc-reply> on page 177 Copyright © 2010, Juniper Networks, Inc.
  • Page 184: Get-Checksum-Information

    Enclose all tag elements in a request generated by a client application. Contents —The name and path of the file to check. <path> Usage Guidelines See the Junos XML API Operational Reference. Related Topics <checksum-information> on page 153 Copyright © 2010, Juniper Networks, Inc.
  • Page 185: Get-Configuration

    When the active configuration is requested (the attribute is database="candidate" included), elements added to the active configuration by the most recent commit are marked with the junos:changed="changed" attribute. Copyright © 2010, Juniper Networks, Inc.
  • Page 186 If the attribute is omitted, the output uses the inherit <groups> , and tag elements to represent user-defined <apply-groups> <apply-groups-except> configuration groups and does not include tag elements for statements defined in the group. junos-defaults Copyright © 2010, Juniper Networks, Inc.
  • Page 187 Usage Guidelines See “Requesting Configuration Information” on page 64. Related Topics junos:changed on page 188 junos:group on page 192 <rpc> on page 176 <xnm:warning> on page 181 Junos XML API Configuration Reference Copyright © 2010, Juniper Networks, Inc.
  • Page 188: Junoscript

    The value is a URL of the form <junoscript> junos: , where is the standard string http://xml.juniper.net/junos/release-code/junos release-code that represents a release of the Junos OS, such as 10.3R1 for the initial version of Junos OS Release 10.3. Copyright © 2010, Juniper Networks, Inc.
  • Page 189 See “Emitting the Opening <junoscript> Tag” on page 40, “Parsing the Junos XML Protocol Server’s Opening <junoscript> Tag” on page 41, and “Requesting an Indicator for Identifiers” on page 73. Related Topics <rpc> on page 176 <rpc-reply> on page 177 junos:key on page 193 Copyright © 2010, Juniper Networks, Inc.
  • Page 190: Load-Configuration

    <configuration-text> format value . If providing configuration data as Junos XML tag elements, enclose it in a text <configuration> tag element and optionally set the format attribute to the value Copyright © 2010, Juniper Networks, Inc.
  • Page 191 The only valid value is rescue rollback —Specifies the numerical index of the previous configuration to load. Valid values (zero, for the most recently committed configuration) through one less than the number of stored previous configurations (maximum is Copyright © 2010, Juniper Networks, Inc.
  • Page 192 Usage Guidelines See “Changing Configuration Information” on page 103. Related Topics <load-configuration-results> on page 171 <rpc> on page 176 replace on page 199 entries for in the Junos XML API Configuration <configuration> <configuration-text> Reference Copyright © 2010, Juniper Networks, Inc.
  • Page 193: Load-Configuration-Results

    <unlock-configuration/> made to the candidate are discarded. Usage Guidelines See “Locking the Candidate Configuration” on page 53. Related Topics <rpc> on page 176 <unlock-configuration/> on page 177 Copyright © 2010, Juniper Networks, Inc.
  • Page 194: Open-Configuration

    <commit-configuration/> Usage Guidelines See “Creating a Private Copy of the Configuration” on page 54. Related Topics <close-configuration/> on page 154 <commit-configuration> on page 155 <lock-configuration/> on page 171 <rpc> on page 176 Copyright © 2010, Juniper Networks, Inc.
  • Page 195: Reason

    Request that the Junos XML protocol server end the current session. Usage Guidelines See “Ending a Junos XML Protocol Session and Closing the Connection” on page 55. Related Topics <end-session/> on page 161 <rpc> on page 176 Copyright © 2010, Juniper Networks, Inc.
  • Page 196: Request-Login

    The account must already be configured on the device where the Junos XML protocol server is running. Usage Guidelines See “Submitting an Authentication Request” on page 44. Related Topics <challenge> on page 152 <rpc> on page 176 Copyright © 2010, Juniper Networks, Inc.
  • Page 197: Routing-Engine

    —Name of the Routing Engine on which the commit operation was performed. <name> Possible values are Usage Guidelines See “Committing a Configuration” on page 133. Related Topics <commit-results> on page 159 <rpc-reply> on page 177 Copyright © 2010, Juniper Networks, Inc.
  • Page 198: Rpc

    <rpc> Usage Guidelines See “Sending a Request to the Junos XML Protocol Server” on page 46. Related Topics <junoscript> on page 166 <rpc-reply> on page 177 Copyright © 2010, Juniper Networks, Inc.
  • Page 199: Rpc-Reply

    Until the application emits this tag, other users or applications can read the configuration but cannot change it. Usage Guidelines See “Unlocking the Candidate Configuration” on page 54. Related Topics <lock-configuration/> on page 171 <rpc> on page 176 Copyright © 2010, Juniper Networks, Inc.
  • Page 200: Xml

    —Specifies the version of XML used by the emitter. Usage Guidelines See “Emitting the <?xml?> PI” on page 39 and “Parsing the Junos XML Protocol Server’s <?xml?> PI” on page 41. Related Topics <junoscript> on page 166 Copyright © 2010, Juniper Networks, Inc.
  • Page 201: Xnm:error

    CLI configuration mode banner. —(Occurs only during loading of a configuration file) Names the configuration <filename> file that was being loaded. Copyright © 2010, Juniper Networks, Inc.
  • Page 202 The other tag elements are explained separately. Usage Guidelines See “Handling an Error or Warning” on page 51. Related Topics <database-status-information> on page 161 <junoscript> on page 166 <reason> on page 173 <xnm:warning> on page 181 Copyright © 2010, Juniper Networks, Inc.
  • Page 203: Xnm:warning

    <filename> —Describes the warning in a natural-language text string. <message> <source-daemon> —Names the Junos OS module that was processing the request in which the warning occurred. Copyright © 2010, Juniper Networks, Inc.
  • Page 204 —Names which element in the request caused the warning. <token> The other tag element is explained separately. Usage Guidelines See “Handling an Error or Warning” on page 51. Related Topics <junoscript> on page 166 <reason> on page 173 <xnm:error> on page 179 Copyright © 2010, Juniper Networks, Inc.
  • Page 205: Chapter 8 Summary Of Attributes In Junos Xml Tags

    Configuration Element’s Activation State Simultaneously with Other Changes” on page 127. Related Topics inactive on page 186 insert on page 187 <load-configuration> on page 168 rename on page 198 replace on page 199 <rpc> on page 176 Copyright © 2010, Juniper Networks, Inc.
  • Page 206: Count

    Usage Guidelines See “Requesting a Specified Number of Configuration Objects” on page 84. Related Topics <get-configuration> on page 163 matching on page 196 recurse on page 197 <rpc> on page 176 start on page 200 Copyright © 2010, Juniper Networks, Inc.
  • Page 207: Delete

    Specify that the Junos XML protocol server remove the configuration element from the candidate configuration. The only acceptable value for the attribute is delete Usage Guidelines See “Deleting Configuration Elements” on page 116. Related Topics <load-configuration> on page 168 <rpc> on page 176 Copyright © 2010, Juniper Networks, Inc.
  • Page 208: Inactive

    Usage Guidelines See “Changing a Configuration Element’s Activation State” on page 125. Related Topics active on page 183 insert on page 187 <load-configuration> on page 168 rename on page 198 <rpc> on page 176 Copyright © 2010, Juniper Networks, Inc.
  • Page 209: Insert

    Other Changes” on page 127. Usage Guidelines See “Reordering Elements in Configuration Objects” on page 121. Related Topics active on page 183 inactive on page 186 <load-configuration> on page 168 <rpc> on page 176 Copyright © 2010, Juniper Networks, Inc.
  • Page 210: Junos:changed

    “Requesting Information from the Committed or Candidate Configuration” on page 65. Usage Guidelines See “Requesting a Change Indicator for Configuration Elements” on page 70. Related Topics <get-configuration> on page 163 <rpc-reply> on page 177 Copyright © 2010, Juniper Networks, Inc.
  • Page 211: Junos:changed-Localtime

    1 January 1970. Usage Guidelines See “Requesting Information from the Committed or Candidate Configuration” on page 65. Related Topics in the Junos XML API Configuration Reference <configuration> <rpc-reply> on page 177 junos:changed-localtime on page 189 Copyright © 2010, Juniper Networks, Inc.
  • Page 212: Junos:commit-Localtime

    See “Requesting Information from the Committed or Candidate Configuration” on page 65. Related Topics in the Junos XML API Configuration Reference <configuration> <rpc-reply> on page 177 junos:commit-user on page 191 junos:commit-localtime on page 190 Copyright © 2010, Juniper Networks, Inc.
  • Page 213: Junos:commit-User

    See “Requesting Information from the Committed or Candidate Configuration” on page 65. Related Topics <configuration> in the Junos XML API Configuration Reference <rpc-reply> on page 177 junos:commit-localtime on page 190 junos:commit-seconds on page 190 Copyright © 2010, Juniper Networks, Inc.
  • Page 214: Junos:group

    Instead, the Junos XML protocol server provides the information <get-configuration> in a comment directly above each inherited element. Usage Guidelines See “Displaying the Source Group for Inherited Configuration Elements” on page 76. Related Topics <get-configuration> on page 163 <rpc-reply> on page 177 Copyright © 2010, Juniper Networks, Inc.
  • Page 215: Junos:key

    <get-configuration/> tag or opening tag. <get-configuration> Usage Guidelines See “Requesting an Indicator for Identifiers” on page 73. Related Topics <get-configuration> on page 163 <junoscript> on page 166 <rpc> on page 176 Copyright © 2010, Juniper Networks, Inc.
  • Page 216: Junos:position

    Usage Guidelines See “Requesting a Specified Number of Configuration Objects” on page 84. Related Topics count on page 184 <get-configuration> on page 163 junos:total on page 195 <rpc> on page 176 start on page 200 Copyright © 2010, Juniper Networks, Inc.
  • Page 217: Junos:total

    Usage Guidelines See “Requesting a Specified Number of Configuration Objects” on page 84. Related Topics count on page 184 <get-configuration> on page 163 junos:position on page 194 <rpc> on page 176 start on page 200 Copyright © 2010, Juniper Networks, Inc.
  • Page 218: Matching

    Subset of Objects by Using Regular Expressions” on page 90. Usage Guidelines See “Requesting a Subset of Objects by Using Regular Expressions” on page 90. Related Topics count on page 184 <get-configuration> on page 163 <rpc> on page 176 start on page 200 Copyright © 2010, Juniper Networks, Inc.
  • Page 219: Recurse

    The attribute can be combined with one or more of the , and count matching attributes. start Usage Guidelines See “Requesting Identifiers Only” on page 86. Related Topics count on page 184 <get-configuration> on page 163 <rpc> on page 176 start on page 200 Copyright © 2010, Juniper Networks, Inc.
  • Page 220: Rename

    Usage Guidelines See “Renaming a Configuration Object” on page 123. Related Topics active on page 183 inactive on page 186 <load-configuration> on page 168 <rpc> on page 176 Copyright © 2010, Juniper Networks, Inc.
  • Page 221: Replace

    “Changing a Configuration Element’s Activation State Simultaneously with Other Changes” on page 127. Usage Guidelines See “Replacing Configuration Elements” on page 113. Related Topics active on page 183 inactive on page 186 <load-configuration> on page 168 <rpc> on page 176 Copyright © 2010, Juniper Networks, Inc.
  • Page 222: Start

    <get-configuration> Usage Guidelines See “Requesting a Specified Number of Configuration Objects” on page 84. Related Topics count on page 184 <get-configuration> on page 163 recurse on page 197 <rpc> on page 176 Copyright © 2010, Juniper Networks, Inc.
  • Page 223: Xmlns

    ) in their names. The namespace indicates which Junos XML document type junos: definition (DTD) defines the set of tag elements in the response. Usage Guidelines See “Requesting Operational Information” on page 62. Related Topics <rpc-reply> on page 177 Copyright © 2010, Juniper Networks, Inc.
  • Page 224 Junos 10.3 Junos XML Management Protocol Guide Copyright © 2010, Juniper Networks, Inc.
  • Page 225 PART 3 Writing Junos XML Protocol Client Applications Writing Junos XML Protocol Perl Client Applications on page 205 Writing Junos XML Protocol C Client Applications on page 233 Copyright © 2010, Juniper Networks, Inc.
  • Page 226 Junos 10.3 Junos XML Management Protocol Guide Copyright © 2010, Juniper Networks, Inc.
  • Page 227: Writing Junos Xml Protocol Perl Client Applications

    CHAPTER 9 Writing Junos XML Protocol Perl Client Applications Juniper Networks provides a Perl module to help you more quickly and JUNOS::Device easily develop custom Perl scripts for configuring and monitoring switches, routers, and security devices running Junos OS. The module implements a...
  • Page 228: Downloading The Junos Xml Protocol Perl Client And Prerequisites Package

    To download the compressed tar archive files that contain the Junos XML protocol Perl client distribution and the prerequisites package, perform the following steps: Access the Junos XML protocol download page on the Juniper Networks website at https://www.juniper.net/support/xml/junoscript/ Click the link for the appropriate software release.
  • Page 229: Unpacking The Junos Xml Protocol Perl Client And Sample Scripts

    The Junos XML protocol Perl client requires Perl version 5.0004 or later. To confirm whether Perl is installed on your system and to determine which version of Perl is currently running, issue the following commands: Copyright © 2010, Juniper Networks, Inc.
  • Page 230: Unpacking And Installing The Junos Xml Protocol Perl Client Prerequisites

    You can opt to install the modules in a private directory. To install the required modules in the standard directory: Go to the directory where you unpacked the parent-directory/junoscript-perl-release prerequisites package. Issue the following command: Copyright © 2010, Juniper Networks, Inc.
  • Page 231: Installing The Junos Xml Protocol Perl Client

    To install the Perl client in the standard directory (generally /usr/local/lib % perl Makefile.pl Checking if your kit is complete... Looks good Writing Makefile for junoscript-perl To install the Perl client in a private directory: Copyright © 2010, Juniper Networks, Inc.
  • Page 232: Tutorial: Writing Perl Client Applications

    Perl modules, which include functions that handle input from the command line: —Includes functions for processing filenames. File::Basename —Includes functions for reading in keyed options from the command line. Getopt::Std Copyright © 2010, Juniper Networks, Inc.
  • Page 233: Connect To The Junos Xml Protocol Server

    If your application sends the same requests to multiple devices, you can structure the script to iterate through either the set of devices or the set Copyright © 2010, Juniper Networks, Inc.
  • Page 234: Object

    In the following example from the script, the first parameter to get_chassis_inventory.pl function defines the acceptable options, which vary depending on the getopts application. A colon after the option letter indicates that it takes an argument. Copyright © 2010, Juniper Networks, Inc.
  • Page 235 # Check for login name. If not provided, prompt for it my $login = ""; if ($opt{l}) { $login = $opt{l}; } else { print STDERR "login: "; $login = ReadLine 0; chomp $login; Copyright © 2010, Juniper Networks, Inc.
  • Page 236 (echo) mode after it reads the password: my $password = ""; if ($opt{p}) { $password = $opt{p}; } else { print STDERR "password: "; ReadMode 'noecho'; $password = ReadLine 0; chomp $password; Copyright © 2010, Juniper Networks, Inc.
  • Page 237: Obtaining Application-Specific Parameters

    # The default action for load_configuration is 'merge' my $load_action = "merge"; $load_action = $opt{a} if $opt{a}; Copyright © 2010, Juniper Networks, Inc.
  • Page 238: Converting Disallowed Characters

    $line =~ s/<\/configuration-text>//g; $line =~ s/($char_class)/$escape_symbols{$1}/ge; $input_string .= $line; return "<configuration-text>$input_string</configuration-text>"; The first subsection of the preceding code sample reads in a file containing formatted ASCII configuration statements: sub get_escaped_text my $input_file = shift; Copyright © 2010, Juniper Networks, Inc.
  • Page 239: Establishing The Connection

    “Mapping CLI Commands to Perl Methods” on page 232 and the files stored in the directory of lib/JUNOS/release the Junos XML protocol Perl distribution ( is the Junos OS version code, such as release Copyright © 2010, Juniper Networks, Inc.
  • Page 240: Providing Method Options Or Attributes

    An option with a variable value is defined as type . In the following example, $STRING get_cos_drop_profile_information method takes the profile_name argument: ## Method : <get-cos-drop-profile-information> ## Returns: <cos-drop-profile-information> ## Command: "show class-of-service drop-profile" Copyright © 2010, Juniper Networks, Inc.
  • Page 241 For example, the get_forwarding_table_information method has four fixed-form options and five options with variable values: ## Method : <get-forwarding-table-information> ## Returns: <forwarding-table-information> ## Command: "show route forwarding-table" get_forwarding_table_information => { detail => $TOGGLE, Copyright © 2010, Juniper Networks, Inc.
  • Page 242: Submitting A Request

    For each argument, the application uses the notation described in “Providing Method Options or Attributes” on page 218. my %arguments = ( ); %arguments = ( argument1 => value1 , argument2 => value2 , ...); Copyright © 2010, Juniper Networks, Inc.
  • Page 243: Example: Getting An Inventory Of Hardware Components

    "ERROR: $deviceinfo{hostname}: failed to execute command $query.\n"; # Check and see if there were any errors in executing the command. my $err = $res->getFirstError( ); if ($err) { print STDERR "ERROR: $deviceinfo{'hostname'} - ", $err->{message}, "\n"; } else { Copyright © 2010, Juniper Networks, Inc.
  • Page 244: Example: Loading Configuration Statements

    ($jnx, $req, $state, $success) = @_; if ($state >= STATE_CONFIG_LOADED) { print "Rolling back configuration ...\n"; eval { $jnx->load_configuration(rollback => 0); if ($state >= STATE_LOCKED) { print "Unlocking configuration database ...\n"; eval { $jnx->unlock_configuration(); Copyright © 2010, Juniper Networks, Inc.
  • Page 245 "ERROR: Cannot load configuration in $xmlfile\n"; graceful_shutdown($jnx, $xmlfile, STATE_LOCKED, REPORT_FAILURE); my $parser = new XML::DOM::Parser; my $doc; if ($opt{t}) { my $xmlstring = get_escaped_text($xmlfile); $doc = $parser->parsestring($xmlstring) if $xmlstring; } else { $doc = $parser->parsefile($xmlfile); Copyright © 2010, Juniper Networks, Inc.
  • Page 246 $xmlfile, STATE_LOCKED, REPORT_FAILURE); Loading the Configuration Data The script now invokes the method to load the configuration onto load_configuration thedevice. It places the statement inside an block to ensure that the eval Copyright © 2010, Juniper Networks, Inc.
  • Page 247 If there are no errors, the script invokes the method (defined in the commit_configuration file lib/JUNOS/Methods.pm in the Junos XML protocol Perl distribution): print "Committing configuration from $xmlfile ...\n"; $res = $jnx->commit_configuration(); $err = $res->getFirstError(); Copyright © 2010, Juniper Networks, Inc.
  • Page 248: Parsing And Formatting The Response From The Junos Xml Protocol

    ($nm) { print "Transforming $xmlfile with $xslfile...\n" if $outputfile; my $command = "xsltproc $nm $deviceinfo{hostname}.xml"; $command .= "> $outputfile" if $outputfile; system($command); print "Done\n" if $outputfile; print "See $outputfile\n" if $outputfile; else { Copyright © 2010, Juniper Networks, Inc.
  • Page 249 XSLT file identified by the $xslfile variable to match the value in the Junos XML protocol server’s response. It assigns the resulting XSLT file to the variable. Copyright © 2010, Juniper Networks, Inc.
  • Page 250: Parsing And Outputting Configuration Data

    A detailed discussion of each line follows the complete code sample. my(%opt,$login,$password); getopts('l:p:dm:hit', \%opt) || output_usage(); output_usage() if $opt{h}; my $basepath = shift || output_usage; my $hostname = shift || output_usage; my $config = getconfig( $hostname, $jnx, $opt{t} ); Copyright © 2010, Juniper Networks, Inc.
  • Page 251 "# storing configuration for $hostname as $filename\n"; my $config_node; my $top_tag = "configuration"; $top_tag .= "-text" if $text_mode; if ($config->getTagName() eq $top_tag) { $config_node = $config; } else { print "# unknown response component ", $config->getTagName(), "\n"; Copyright © 2010, Juniper Networks, Inc.
  • Page 252 $top_tag variable. If the comparison succeeds, the XML DOM tree is assigned to the variable. Otherwise, the subroutine prints an error message because the $config_node XML DOM tree is not valid configuration data. Copyright © 2010, Juniper Networks, Inc.
  • Page 253 (For information about defining the hash to %escapes contain the set of disallowed characters, see “Converting Disallowed Characters” on page 216.) } else { my $buf = $config_node->getFirstChild( )->toString( ); $buf =~ s/($char_class)/$escapes{$1}/ge; print OUTPUTFILE "$buf\n"; Copyright © 2010, Juniper Networks, Inc.
  • Page 254: Closing The Connection To The Junos Xml Protocol Server

    Perl method, see the entry for the corresponding Junos XML request tag element in the chapter titled “ Summary of Operational Request Tags” in the Junos XML API Operational Reference. Copyright © 2010, Juniper Networks, Inc.
  • Page 255: Writing Junos Xml Protocol C Client Applications

    (pipe(ipipes) <0 || pipe(opipes) <0) err(1, "pipe failed"); pid = fork( ); if (pid <0) err(1, "fork failed"); if (pid == 0) { dup2(opipes[ 0 ], STDIN_FILENO); dup2(ipipes[ 1 ], STDOUT_FILENO); dup2(ipipes[ 1 ], STDERR_FILENO); Copyright © 2010, Juniper Networks, Inc.
  • Page 256: Accessing And Editing Device Configurations

    //--Temporary buffer used when --// //--sending js configuration commands--// char rcvbuffer[255]; //--Stores data from socket--// char *pim_output_ptr = NULL; //--Pointer for pim_output from socket--// //--buffer--// char *igmp_output_ptr = NULL; //--Pointer for igmp_output from socket buffer--// Copyright © 2010, Juniper Networks, Inc.
  • Page 257 //--Function prototypes--// void error(char *msg); //--Support error messaging--// xmlDocPtr getdoc(char *buffer); //--Parses XML content and loads it into memory--// xmlXPathObjectPtr getnodeset (xmlDocPtr doc, xmlChar *xpath); //--Parses xml content for result node(s) from XPath search--// //--Functions--// Copyright © 2010, Juniper Networks, Inc.
  • Page 258 #ifdef PRINT printf("No result\n"); #endif return NULL; return result; //--Main--// int main(int argc, char **argv) { if(argc != 4) { printf("\nUsage: %s <device Address> <Interface Name> <Multicast Source>\n\n", argv[0]); exit(0); } else { strcpy(jserver, argv[1]); Copyright © 2010, Juniper Networks, Inc.
  • Page 259 //--Continue to read from the buffer until match--// sock_bytes = read(sockfd, rcvbuffer, 255); rcvbuffer[sock_bytes] = 0; strcat(small_buff, rcvbuffer); //--Copy buffer contents into pim_buffer--// printf("Login completed to the Junos XML protocol server\n"); #ifdef PRINT printf("%s\n", small_buff); //--Print the small buff contents--// #endif Copyright © 2010, Juniper Networks, Inc.
  • Page 260 //--what we are removing--// memcpy(xmlns_start_ptr - 1, xmlns_start_ptr + repl_str_len, remain_len); //--copy the remaining string to the beginning --// //--of the replacement string--// #ifdef PRINT printf("\n%s\n", pim_output_ptr); #endif //--End of GET PIM join information--// Copyright © 2010, Juniper Networks, Inc.
  • Page 261 //--Store xPath results for igmp buffer search--// doc = getdoc(igmp_output_ptr); igmp_result = getnodeset (doc, igmp_xpath_ptr); if (igmp_result) { nodeset = igmp_result->nodesetval; for (count_a=0; count_a < nodeset->nodeNr; count_a++) { keyword_ptr = xmlNodeListGetString (doc, nodeset->nodeTab[count_a]->xmlChildrenNode, 1); strcpy(igmp_result_buff[count_a], (char *)keyword_ptr); #ifdef PRINT Copyright © 2010, Juniper Networks, Inc.
  • Page 262 "</rpc-reply>") == NULL) { sock_bytes = read(sockfd, rcvbuffer, 255); rcvbuffer[sock_bytes] = 0; strcat(small_buff, rcvbuffer); #ifdef PRINT printf("%s\n", small_buff); #endif bzero(small_buff, strlen(small_buff)); //--Erase (copy all 0's) small buffer contents--// bzero(temp_buff, strlen(temp_buff)); //--Erase temp_buff contents--// Copyright © 2010, Juniper Networks, Inc.
  • Page 263 = 1; count_y++; count_x=0; count_z=0; if(conf_chg == 1) { sock_bytes = write(sockfd, js_commit, strlen(js_commit)); while(strstr(small_buff, "</rpc-reply>") == NULL) { sock_bytes = read(sockfd, rcvbuffer, 255); rcvbuffer[sock_bytes] = 0; strcat(small_buff, rcvbuffer); Copyright © 2010, Juniper Networks, Inc.
  • Page 264 //--Erase contents of rcvbuffer--// char *xmlns_start_ptr = NULL; //--Nullify the contents--// char *xmlns_end_ptr = NULL; //--Nullify the contents--// for(count_x = 0; count_x < 129; count_x++) { //--Erase contents of both pim_result_buff and igmp_result_buff--// bzero(pim_result_buff[count_x], strlen(pim_result_buff[count_x])); bzero(igmp_result_buff[count_x], strlen(igmp_result_buff[count_x])); Copyright © 2010, Juniper Networks, Inc.
  • Page 265: Index

    PART 4 Index Index on page 245 Index of Statements and Commands on page 257 Copyright © 2010, Juniper Networks, Inc.
  • Page 266 Junos 10.3 Junos XML Management Protocol Guide Copyright © 2010, Juniper Networks, Inc.
  • Page 267: Index

    [ ], in configuration statements.........xx ASCII, formatted, in Junos XML protocol loading configuration as..........107 regular expression operator requesting configuration as........68 Junos XML protocol requests......91 at-time tag (Junos XML protocol)........155 { }, in configuration statements.........xx usage guidelines............136 Copyright © 2010, Juniper Networks, Inc.
  • Page 268 Perl See Perl client applications commit-success tag (Junos XML protocol)....175 client applications, sample Junos XML protocol usage guidelines C-language..............233 commit of private copy........135 close-configuration tag (Junos XML protocol)..154 confirmed commit..........137 usage guidelines.............54 immediate commit..........134 Copyright © 2010, Juniper Networks, Inc.
  • Page 269 Junos XML protocol..........109 protocol.................121 displaying replacing candidate or committed (Junos XML entire (Junos XML protocol)......108 protocol)..............65 only changed elements (Junos XML changed elements (Junos XML protocol)..............115 protocol)..............70 single element (Junos XML protocol)...113 entire (Junos XML protocol)......81 Copyright © 2010, Juniper Networks, Inc.
  • Page 270 (Junos XML protocol) Junos XML protocol usage guidelines usage guidelines...........137 client................39 confirmed tag (Junos XML protocol)......155 server................41 Junos XML protocol encoding attribute (Junos XML protocol)) usage guidelines...........137 <?xml?> tag..............178 end-session tag (Junos XML protocol)......161 usage guidelines.............55 Copyright © 2010, Juniper Networks, Inc.
  • Page 271 Junos XML tags...........111 attributes, usage guidelines overriding current configuration......108 changed..............70 renaming configuration elements......124 database..............65 reordering configuration elements......122 format ..............68 replacing configuration elements only those that have changed......116 using formatted ASCII.........114 using Junos XML tags..........113 Copyright © 2010, Juniper Networks, Inc.
  • Page 272 Junos XML protocol session when renaming element........129 authentication and security when reordering element.........129 overview..............37 when replacing element........128 procedures...............43 inherit attribute (Junos XML protocol) ending.................55 get-configuration tag..........163 establishing..............38 usage guidelines.............75 example................56 Copyright © 2010, Juniper Networks, Inc.
  • Page 273 (Junos XML with Junos XML displaying configuration........97 protocol) rollback-information usage guidelines............84 displaying configuration........97 junos:total attribute (Junos XML with Junos XML rollback-information tag protocol)................195 comparing configurations.........99 usage guidelines............84 Copyright © 2010, Juniper Networks, Inc.
  • Page 274 (Junos XML protocol) output from Junos XML protocol server, parsing..................50 usage guidelines.............45 output tag (Junos XML)............63 login-name tag (Junos XML protocol)......151 override (value of Junos XML protocol 'action' attribute) usage guidelines............108 Copyright © 2010, Juniper Networks, Inc.
  • Page 275 (Junos XML protocol)........177 rename attribute (Junos XML with Junos XML usage guidelines............48 protocol)................198 usage guidelines general..............123 SAX....................50 when changing activation state.....129 schema See XML schema schemaLocation attribute (Junos XML protocol) junoscript tag..............166 usage guidelines..............41 Copyright © 2010, Juniper Networks, Inc.
  • Page 276 Junos XML..............62 Junos XML protocol..........64 warning response from Junos XML protocol server........51 children of..............11 white space in XML tag sequences........11 defined...............10 Junos XML..............62 Copyright © 2010, Juniper Networks, Inc.
  • Page 277 (Junos XML protocol) usage guidelines..............51 xnm-clear-text statement usage guidelines.............29 xnm-ssl statement usage guidelines.............35 xnm:error tag (Junos XML protocol)......179 xnm:warning tag (Junos XML protocol)......181 usage guidelines..............51 xsd:import tag (Junos XML)..........95 xsd:schema tag (Junos XML)..........94 Copyright © 2010, Juniper Networks, Inc.
  • Page 278 Junos 10.3 Junos XML Management Protocol Guide Copyright © 2010, Juniper Networks, Inc.
  • Page 279: Index Of Statements And Commands

    (Junos XML with Junos XML protocol)................186 protocol)................184 inherit attribute (Junos XML protocol) get-configuration tag..........163 insert attribute (Junos XML with Junos XML daemon tag (Junos XML protocol).........173 protocol)................187 database attribute (Junos XML protocol) get-configuration tag..........163 Copyright © 2010, Juniper Networks, Inc.
  • Page 280 (Junos XML protocol)......179, 181 os attribute (Junos XML protocol) junoscript tag..............166 unlock-configuration tag (Junos XML protocol)................177 parse tag (Junos XML protocol)........179 url attribute (Junos XML protocol) pid tag (Junos XML protocol)..........160 load-configuration tag..........168 Copyright © 2010, Juniper Networks, Inc.
  • Page 281 (Junos XML protocol) <?xml?> tag..............178 junoscript tag..............166 xmlns attribute (Junos XML protocol)......201 junoscript tag..............166 xmlns:junos attribute (Junos XML protocol) junoscript tag..............166 rpc-reply tag..............177 xnm:error tag (Junos XML protocol)......179 xnm:warning tag (Junos XML protocol)......181 Copyright © 2010, Juniper Networks, Inc.
  • Page 282 Junos 10.3 Junos XML Management Protocol Guide Copyright © 2010, Juniper Networks, Inc.

This manual is also suitable for:

Junos os

Table of Contents