Sie sind auf Seite 1von 15

BRKDEV-1181

14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 1

XML-PI 1.0
Programmatic Access to
Cisco IOS Using XML

BRKDEV-1181

BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 2

© 2006, Cisco Systems, Inc. All rights reserved. 1


Presentation_ID.scr
Agenda

ƒ What is XML-PI?
ƒ Retrieving configurations in XML
ƒ Changing configurations using XML
ƒ Getting “show” command output in XML
ƒ Development tools and libraries
ƒ Q&A

BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 3

“For customers and partners needing to remotely


deploy, adapt and control the behavior of Cisco
devices, XML-PI 1.0 provides unambiguous and
robust information access without the complexity
and expense of screen-scraping technologies
or external XML-to-CLI gateways.”

BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 4

© 2006, Cisco Systems, Inc. All rights reserved. 2


Presentation_ID.scr
What Is XML-PI 1.0?
CLI Is for Humans, XML Is for Machines
ƒ Inventory—retrieve configurations
in XML
ƒ Status—determine how a device
is performing in XML
ƒ Performance—retrieve non-SNMP
information in XML
ƒ Management—adapt the behavior
of a Cisco device using XML
ƒ Configure—add new services and
features using XML

BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 5

XML-PI Big Picture

GET-CONFIG Retrieve the


Running config
Response
Management
System

EDIT-CONFIG Change the


Response
Running config
Management
System

GET Run a “show”


command
Response
Management
System

BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 6

© 2006, Cisco Systems, Inc. All rights reserved. 3


Presentation_ID.scr
What Can You Do In XML-PI 1.0?
Interrogate, Control and Adapt
ƒ Retrieve the current configuration of a Cisco device
in fully tagged XML
ƒ Change the configuration of a Cisco device by sending
an XML document (or fragment)
ƒ Retrieve the output from “show” commands
from a Cisco device in fully tagged XML
ƒ Retrieve the XML schema (XSD) from a Cisco device

BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 7

How Does XML-PI 1.0 Work?


The Architecture

Running config “show ip bgp…”

XML-PI

get-config edit-config get CLI

NETCONF (rfc 4741)


show <command> | format
SSH <specfile>

IOS

BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 8

© 2006, Cisco Systems, Inc. All rights reserved. 4


Presentation_ID.scr
Retrieving the Running
Configuration in XML

BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 9

Retrieve Config—GET-CONFIG

ƒ Retrieve the currently running config in fully


formed XML
ƒ Available through CLI as:
show run | format spec.odm

ƒ Available through NETCONF using GET-CONFIG


ƒ Request options:
all Configuration with defaults
brief Configuration without certificate data
full Full configuration
interface Show interface configuration

BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 10

© 2006, Cisco Systems, Inc. All rights reserved. 5


Presentation_ID.scr
Retrieve Config—GET-CONFIG
Request
<rpc message-id="xmlpi.1.10">
<get-config>
<source>
<running/>
</source>
<filter>
<config-format-xml options="interface GigabitEthernet0/1">
</config-format-xml>
</filter>
</get-config>
</rpc>

Response

<Device-Configuration>
<interface>
<GigabitEthernetInterface>
<InterfaceName>GigabitEthernet0/1</InterfaceName>
<Interface-Configuration>
<ip>
<address>
<IPAddress>10.0.1.1</IPAddress>
<IPSubnetMask>255.0.0.0</IPSubnetMask>
</address>
</ip>
<duplex><auto/></duplex>
<speed><auto/></speed>
<media-type><rj45/></media-type>
<negotiation><auto operation='delete'/></negotiation>
</Interface-Configuration>
</GigabitEthernetInterface>
</interface>
</Device-Configuration>

BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 11

Changing the Current


Config with XML

BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 12

© 2006, Cisco Systems, Inc. All rights reserved. 6


Presentation_ID.scr
Change a Config—EDIT-CONFIG

ƒ Change the running configuration on a device


ƒ Can send in a partial configuration in XML
ƒ Partial changes can be made as long as they are
unambiguous as to where they should be applied
ƒ Can change, delete or add configuration commands
ƒ Only available through NETCONF, not CLI

BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 13

Change a Config—EDIT-CONFIG
Request
<?xml version="1.0" encoding="UTF-8"?>
<rpc message-id="3"
xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<edit-config>
<target><running/></target>
<config>
<xml-config-data>
<Device-Configuration>
<ip>
<host>
<NameHost>
shangrila
</NameHost>
<HostIPAddress>
10.2.3.4
</HostIPAddress>
</host>
</ip>
<ip>
<host>
<NameHost>
vallhala
</NameHost>
<HostIPAddress>
10.2.3.5
</HostIPAddress>
</host>
</ip>
</Device-Configuration>
</xml-config-data>
</config>
</edit-config>
</rpc>]]>]]>

BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 14

© 2006, Cisco Systems, Inc. All rights reserved. 7


Presentation_ID.scr
Change a Config—Successful Response
Response
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply message-id="3" xmlns="urn:ietf:params:netconf:base:1.0">
<ok/>
</rpc-reply>

BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 15

Deleting a Host Name—EDIT-CONFIG


Request
<?xml version="1.0" encoding="UTF-8"?>
<rpc message-id="3" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<edit-config>
<target><running/></target>
<config>
<xml-config-data>
<Device-Configuration>
<ip>
<host operation="delete">
<NameHost>shangrila</NameHost>
<HostIPAddress>1.2.3.4</HostIPAddress>
</host>
</ip>
<ip>
<host operation="delete">
<NameHost>vallhala</NameHost>
<HostIPAddress>1.2.3.5</HostIPAddress>
</host>
</ip>
</Device-Configuration>
</xml-config-data>
</config>
</edit-config>
</rpc>]]>]]>

Response
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply message-id="3" xmlns="urn:ietf:params:netconf:base:1.0">
<ok/>
</rpc-reply>

BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 16

© 2006, Cisco Systems, Inc. All rights reserved. 8


Presentation_ID.scr
Retrieving “show”
Command Output
in XML

BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 17

Operational Status—Show Commands

ƒ Retrieve a fully formed XML representation of CLI show


commands (e.g. “show ip bgp…”)
ƒ Allow any “show” command to be XMLized
ƒ Provides base support for top 120 commands
ƒ Allow customization of XML output through Spec files
and pattern matching technology
ƒ Spec files are stored on the local file system
on the device
ƒ Operational status commands use either the
NETCONF GET or CLI
ƒ Error messages are returned in RPC ERROR
messages
BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 18

© 2006, Cisco Systems, Inc. All rights reserved. 9


Presentation_ID.scr
Show Commands via CLI or NETCONF

ƒ XML for show commands can be retrieved through the


CLI using the “xml” pipe command
show ip arp | format spec.odm
ƒ XML for show commands can be retrieved through
NETCONF using the NETCONF standard (rfc 4741)
<?xml version="1.0" encoding="UTF-8"?>
<rpc message-id="xmlpi.2.13">
<get>
<filter>
<oper-data-format-xml>
<show>arp</show>
</oper-data-format-xml>
</filter>
</get>
</rpc>]]>]]>

BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 19

Operational Status—GET Request

<?xml version="1.0" encoding="UTF-8"?>


<rpc message-id="xmlpi.2.13">
<get>
<filter>
<oper-data-format-xml>
<show>line</show>
</oper-data-format-xml>
</filter>
</get>
</rpc>]]>]]>

BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 20

© 2006, Cisco Systems, Inc. All rights reserved. 10


Presentation_ID.scr
Operational Status—GET Response

<?xml version="1.0" encoding="UTF-8"?>


<ShowLine>
<LineInfoTable>
<Tty> 0</Tty>
<Typ> CTY </Typ>
<TxRX> </TxRX>
<A> -</A>
<Modem> - </Modem>
<Roty> -</Roty>
<AccO> -</AccO>
<AccI> -</AccI>
<Uses> 0</Uses>
<Noise> 0</Noise>
<Overruns> 0/0 </Overruns>
<Int> -</Int>
</LineInfoTable>
<LineInfoTable>
<Tty> 1</Tty>
<Typ> AUX </Typ>
<TxRX> 9600/9600</TxRX>
<A> -</A>
<Modem> - </Modem>
<Roty> -</Roty>
<AccO> -</AccO>
<AccI> -</AccI>
<Uses> 0</Uses>
<Noise> 0</Noise>
<Overruns> 0/0 </Overruns>
<Int> -</Int>
</LineInfoTable> Tty Typ Tx/Rx A Modem Roty AccO AccI Uses Noise Overruns Int
<LineInfoTable>
</ShowLine> * 0 CTY - - - - - 0 0 0/0 -
1 AUX 9600/9600 - - - - - 0 0 0/0 -

BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 21

Spec Files and Controlling XML Output

ƒ CLI output is automatically processed by a pattern


matching algorithm defined in a Spec File
ƒ The format of the XML output is controlled
by Spec Files
ƒ There is one Spec File for all show commands
ƒ Spec Files can be added for new commands
or modified to customize the XML output
ƒ If a show command does not have a Spec File,
no XML output is available
ƒ Cisco provides the top 120 show commands

BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 22

© 2006, Cisco Systems, Inc. All rights reserved. 11


Presentation_ID.scr
Example Spec File—“show vtp status”
<ODMSpec>
<Command>
<Name>show vtp status</Name>
</Command>
<OS>ios</OS>
<SupportedDeviceTypes>
<DeviceSpec>

</DeviceSpec>
<DeviceType>Cat295024G</DeviceType>
<Versions><Version>12.1(22)EA2</Version></Versions> Targets for the
<DeviceSpec>
<DeviceType>Cat355024</DeviceType>
CLI Command
<Versions><Version>12.1(22)EA6</Version></Versions>
</DeviceSpec>
</SupportedDeviceTypes>
<DataModel>
<Container name="ShowVtpStatus" >
<Property name="VTP Version" />
<Property name="Configuration Revision" />
<Property name="Maximum VLANs supported locally" type="Integer" />
<Property name="Number of existing VLANs" type="Integer" />
<Property name="VTP Operating Mode" />
<Property name="VTP Domain Name" />
<Property name="VTP Pruning Mode" />
<Property name="VTP V2 Mode" />
Output Format
<Property name="VTP Traps Generation" />
<Property name="MD5 digest" length="-1"/>
<Container name="Configuration" >
<Property name="last modified by" />
<Property name="last modified by" alias="At" distance="3" length="-1"/>
</Container>
</Container>
</DataModel>
</ODMSpec>
Type
Length
Distance

BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 23

Development Tools

BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 24

© 2006, Cisco Systems, Inc. All rights reserved. 12


Presentation_ID.scr
Tools, Libraries and Examples

ƒ Perl libraries to simplify code development


ƒ Example applications
ƒ Demo XML browser

BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 25

Demo XML Browser

BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 26

© 2006, Cisco Systems, Inc. All rights reserved. 13


Presentation_ID.scr
Q and A

BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 27

Recommended Reading

ƒ Industry NETCONF info:


http://en.wikipedia.org/wiki/Netconf
http://www.ietf.org/rfc/rfc4741.txt

ƒ Cisco NETCONF support:


http://www.cisco.com/en/US/docs/ios/12_2sr/12_2sra/feature/
guide/srnetcon.html

BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 28

© 2006, Cisco Systems, Inc. All rights reserved. 14


Presentation_ID.scr
Complete Your Online
Session Evaluation
ƒ Give us your feedback and you could win Don’t forget to activate
fabulous prizes. Winners announced daily. your Cisco Live virtual
account for access to
ƒ Receive 20 Passport points for each session all session material
evaluation you complete. on-demand and return
for our live virtual event
ƒ Complete your session evaluation online now in October 2008.
(open a browser through our wireless network Go to the Collaboration
to access our portal) or visit one of the Internet Zone in World of
stations throughout the Convention Center. Solutions or visit
www.cisco-live.com.

BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 29

BRKDEV-1181
14361_05_2008_X1 © 2008 Cisco Systems, Inc. All rights reserved. Cisco Public 30

© 2006, Cisco Systems, Inc. All rights reserved. 15


Presentation_ID.scr

Das könnte Ihnen auch gefallen