Table Of Contents
Configuring XML Requests
Prerequisites
Guidelines and Limitations
Starting a Session with the XML Server
Creating an XML Request
Manually Sending a Document to the Server
Example Configurations
Example: Creating a Message with Multiple Operations
Example 1
Example 2
Example: Creating a Port Profile
Example: Deleting a Port Profile
Example: Deleting a Configuration
Example: Closing Your Session
Example: Closing a Session Other Than Your Own
Example: Editing a Configuration
Default Settings
Additional References
Standards
RFCs
Configuring XML Requests
This chapter describes how to configure XML requests and includes the following sections:
•
Prerequisites
•
Guidelines and Limitations
•
Starting a Session with the XML Server
•
Creating an XML Request
•
Example Configurations
•
Default Settings
•
Additional References
Prerequisites
The XML API interface has the following prerequisites:
•
SSH Version 2 is installed and enabled on the client PC.
Guidelines and Limitations
Before you begin exchanging messages with the Cisco Nexus 1000VXML API, verify the following conditions:
•
You must use your own XML editor or XML management interface tool to create XML instances.
•
If using an XML management tool, it must support NETCONF over SSH.
Starting a Session with the XML Server
Use this procedure to start a NETCONF session between your XML client and the Cisco Nexus 1000V XML server.
Note
The Cisco Nexus 1000V xmlagent service is referred to as the XML server.
BEFORE YOU BEGIN
Before beginning this procedure, you must know or do the following:
•
You are logged in to your XML client PC where SSH Version 2 is enabled.
•
You know the IP address for the Cisco Nexus 1000V XML server.
•
There is an available XML server session.
For more information, see the "Configuring the Number of Allowed Sessions" procedure on page 2-1.
SUMMARY STEPS
1.
ssh username@ipaddress -s xmlagent
2.
password
DETAILED STEPS
| |
Command
|
Purpose
|
Step 1
|
ssh username@ip-address -s xmlagent
Example:
ssh admin@172.23.232.160 -s xmlagent
User Access Verification
Password:
|
Connects you to the Cisco Nexus 1000V XML agent over a secure SSH connection.
Note The SSH command syntax may differ for the SSH software on the client PC.
|
Step 2
|
password
Example:
Password: *******
|
Authenticates your credentials and begins a NETCONF session between your client PC and the Cisco Nexus 1000V XML server.
|
Step 3
|
<?xml version="1.0"?>
Example:
<?xml version="1.0"?>
<hello
xmlns="urn:ietf:params:xml:ns:netconf:base
:1.0"> <capabilities>
<capability>urn:ietf:params:xml:ns:netconf
:base:1.0</capability>
|
Enter a declaration statement indicating the version of XML you are using. The server responds with a hello message indicating its capabilities.
|
Step 4
|
<nc:hello xmlns:nc="urn:ietf:params :xml:ns:netconf:base:1.0" ><nc:capabilities><nc:cap ability>urn:ietf:params:x ml:ns:netconf:base:1.0</ nc:capability></ nc:capabilities></ nc:hello>
<nc:hello xmlns:nc="urn:ietf:params
:xml:ns:netconf:base:1.0"
><nc:capabilities><nc:cap
ability>urn:ietf:params:x
ml:ns:netconf:base:1.0</ nc:capability></
nc:capabilities></ nc:hello>
<session-id>17644</session-id>
|
Enter a hello message, indicating your client capabilities.
Your NETCONF session is started.
|
Creating an XML Request
Use this procedure to create an XML request in a message to the XML server.
BEFORE YOU BEGIN
Before beginning this procedure, you must know or do the following:
•
You have already started a NETCONF session with the XML server from your client PC.
See the "Starting a Session with the XML Server" procedure.
•
You will need to use your own XML editor or XML management interface tool to create XML messages.
DETAILED STEPS
Step 1
Enter a request start tag.
<nc:rpc message-id="1" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
xmlns="http://www.cisco.com/nxos:1.0:xml">
Step 2
Enter the NETCONF operations start tags for the operations you are requesting.
<nc:filter type="subtree">
Step 3
Enter the Cisco Nexus 1000V operation start tags for the operations you are requesting.
Step 4
Enter the Cisco Nexus 1000V operation end tags for the operations you are requesting.
Step 5
Enter the NETCONF operations end tags for the operations you are requesting.
Step 6
Enter a request end tag followed by the ]]>]]> end of message character sequence.
The following is what the entire XML request looks like:
<nc:rpc message-id="1" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
xmlns="http://www.cisco.com/nxos:1.0:xml">
<nc:filter type="subtree">
Manually Sending a Document to the Server
Use this procedure to manually send an XML document or message to the server.
BEFORE YOU BEGIN.
Before beginning this procedure, you must know or do the following:
•
Although you will generally use an automated method to send messages, you can verify the SSH connection to the XML server with this method.
•
You are logged in to the XML client PC where SSH Version 2 is enabled.
•
You have an XML editor application open on the client PC, and you have created an XML message that ends with the ]]>]]> character sequence.
•
You have opened an SSH session with the XML server and have already exchanged hello messages.
DETAILED STEPS
Step 1
Copy the XML message from the editor application.
Step 2
Paste the XML message into the active SSH session.
The XML message is sent to the XML server where it is parsed and carried out, and then a response indicating the result is returned to your client.
Example Configurations
This section provides the following examples of XML messages.
•
Example: Creating a Message with Multiple Operations
•
Example: Creating a Port Profile
•
Example: Deleting a Port Profile
•
Example: Deleting a Configuration
•
Example: Closing Your Session
•
Example: Closing a Session Other Than Your Own
•
Example: Editing a Configuration
Example: Creating a Message with Multiple Operations
You can include multiple NETCONF operations in a single XML message as long as all of the requests are for the same NETCONF operation.
The XML server ensures that all requests parse without errors before applying them. Any error causes the request to fail with a notification sent to you.
This section includes the following examples:
•
Example 1
•
Example 2
Example 1
This example shows two NETCONF get operations representing 2 CLI commands formatted in a single XML message.
CLI commands:
The following are the CLI commands that are required in the XML request message.
switch# show xml server status
Message
The following is the XML request message representing the required CLI commands.
<nc:rpc message-id="1" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
xmlns="http://www.cisco.com/nxos:1.0:security_tree">
<nc:filter type="subtree">
Reply
The following is the RPC reply sent from the XML server after parsing and carrying out the request from your client.
Note
The XML server may send replies in a different sequence than the requests were sent.
<?xml version="1.0" encoding="ISO-8859-1"?>
<nc:rpc-reply xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
xmlns="http://www.cisco.com/nxos:1.0:security_tree" message-id="1">
<__XML__OPT_Cmd_show_xml___readonly__>
<o_status>enabled</o_status>
<max_session>8</max_session>
<session_id>24559</session_id>
<user_name>admin</user_name>
<start_time>Tue Mar 25 16:14:17 2008</start_time>
<time_remaining_to_timeout>587</time_remaining_to_timeout>
<ip_addr>171.71.55.134</ip_addr>
</__XML__OPT_Cmd_show_xml___readonly__>
]]>]]><?xml version="1.0"?>
<nc:rpc-reply xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
xmlns="http://www.cisco.com/nxos:1.0:security_tree" message-id="1">
Example 2
This example shows two NETCONF get operations representing one valid CLI command and one erroneous CLI command formatted in a single XML message.
CLI commands:
The following are the CLI commands that are required in the XML request message.
switch# show version-error-does-not-exist
Message
The following is the XML request message representing the required CLI commands.
<nc:rpc message-id="1" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
xmlns="http://www.cisco.com/nxos:1.0:sysmgrcli">
<nc:filter type="subtree">
<version-error-doesnotexist>
</version-error-doesnotexist>
Reply
The following is the RPC reply sent from the XML server after parsing and carrying out the request from your client.
<?xml version="1.0" encoding="ISO-8859-1"?>
<nc:rpc-reply xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
xmlns="http://www.cisco.com/nxos:1.0:sysmgrcli" message-id="1">
<__XML__OPT_Cmd_sysmgr_show_version___readonly__>
<header_str>Cisco Nexus Operating System (NX-OS) Software
TAC support: http://www.cisco.com/tac
Copyright (c) 2002-2009, Cisco Systems, Inc. All rights reserved.
The copyrights to certain works contained in this software are
owned by other third parties and used and distributed under
license. Certain components of this software are licensed under
the GNU General Public License (GPL) version 2.0 or the GNU
Lesser General Public License (LGPL) Version 2.1. A copy of each
such license is available at
http://www.opensource.org/licenses/gpl-2.0.php and
http://www.opensource.org/licenses/lgpl-2.1.php
<loader_ver_str>1.2(2) [last: image booted through mgmt0]</loader_ver_str>
<kickstart_ver_str>4.0(4)SV1(2)</kickstart_ver_str>
<sys_ver_str>4.0(4)SV1(2) [gdb]</sys_ver_str>
<kick_file_name></kick_file_name>
<kick_cmpl_time> 9/22/2009 2:00:00</kick_cmpl_time>
<isan_file_name>bootflash:/isan.bin</isan_file_name>
<isan_cmpl_time> 9/22/2009 2:00:00</isan_cmpl_time>
<isan_tmstmp>09/26/2009 00:36:00</isan_tmstmp>
<chassis_id>Nexus 1000V Chassis</chassis_id>
<module_id>Virtual Supervisor Module</module_id>
<cpu_name>Intel(R) Xeon(R) CPU </cpu_name>
<proc_board_id>T5056BE7598</proc_board_id>
<host_name>roshan-vsm</host_name>
<bootflash_size>2332296</bootflash_size>
<kern_uptm_days>3</kern_uptm_days>
<kern_uptm_hrs>16</kern_uptm_hrs>
<kern_uptm_mins>58</kern_uptm_mins>
<kern_uptm_secs>3</kern_uptm_secs>
</__XML__OPT_Cmd_sysmgr_show_version___readonly__>
<nc:rpc-reply xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
xmlns="http://www.cisco.com/nxos:1.0:sysmgrcli" message-id="1">
<nc:error-type>application</nc:error-type>
<nc:error-tag>invalid-value</nc:error-tag>
<nc:error-severity>error</nc:error-severity>
<nc:error-message>Syntax error while parsing 'show version-error-doesnotexist '
<nc:bad-element>show</nc:bad-element>
Example: Creating a Port Profile
The following example shows the XML request message for creating a port profile.
Commands
The following are the CLI commands that are required in the XML request message.
switch(config)# port-profile testppf
switch(config-port-prof)# description portprofile-test-description
switch(config-port-prof)# vmware port-group portprofile-test
switch(config-port-prof)# state enabled
switch(config-port-prof)# no shut
Message
The following example shows the XML message for the required commands.
<nf:rpc xmlns="http://www.cisco.com/nxos:1.0:ppm"
xmlns:nf="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="110">
<nxos:configure xmlns:nxos="http://www.cisco.com/nxos:1.0:ppm">
<nxos:__XML__MODE__exec_configure>
<__XML__PARAM_value isKey="true">testppf</__XML__PARAM_value>
<desc_text>portprofile-test-description</desc_text>
<__XML__OPT_Cmd_ppm_port_group_pg_name>
<pg_name>portprofile-test</pg_name>
</__XML__OPT_Cmd_ppm_port_group_pg_name>
</nxos:__XML__MODE__exec_configure>
Reply
The following is the XML server reply to the NETCONF message.
<nf:rpc-reply xmlns="http://www.cisco.com/nxos:1.0:ppm"
xmlns:nf="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="110">
Example: Deleting a Port Profile
The following example shows the XML request message for deleting a port profile.
Commands
The following are the CLI commands that are required in the XML request message.
switch(config)# no port-profile testppf
Message
The following example shows the XML message for the required commands.
<nf:rpc xmlns="http://www.cisco.com/nxos:1.0:ppm"
xmlns:nf="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="110">
<nxos:configure xmlns:nxos="http://www.cisco.com/nxos:1.0:ppm">
<nxos:__XML__MODE__exec_configure>
<__XML__PARAM_value isKey="true">testppf</__XML__PARAM_value>
</nxos:__XML__MODE__exec_configure>
Reply
The following is the XML server reply to the NETCONF message.
<nf:rpc-reply xmlns="http://www.cisco.com/nxos:1.0:ppm"
xmlns:nf="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="110">
Example: Deleting a Configuration
The following example shows the NETCONF delete-config operation, which performs the equivalent of the write erase command on the startup configuration.
Caution 
This procedure removes the existing configuration entirely.
CLI Command
switch# write erase
Message
The following example shows the XML message for the required command.
<rpc message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
Reply
The following is the XML server reply to the NETCONF message.
<nc:rpc-reply xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
xmlns="http://www.cisco.com/nxos:1.0" message-id="101">
Example: Closing Your Session
The following example shows the NETCONF close-session operation which closes your session with the XML server, also terminating the SSH session.
Message
The following is the XML message for the NETCONF close-session operation.
<rpc message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
Reply
The following is the XML server reply to the message.
<nc:rpc-reply xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
xmlns="http://www.cisco.com/nxos:1.0" message-id="101">
Example: Closing a Session Other Than Your Own
The following example shows the NETCONF kill-session operation which terminates a server session other than your own.
Message
The following is the XML message for the NETCONF kill-session operation.
<rpc message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<session-id>31990</session-id>
Reply
The following is the XML server reply to the message.
<nc:rpc-reply xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
xmlns="http://www.cisco.com/nxos:1.0" message-id="110">
Example: Editing a Configuration
This example shows a request for editing a configuration using the NETCONF edit-config operation.
CLI Commands
The following are the CLI commands required in the message.
switch(config)# interface ethernet 2/30
switch(config-if)# description Marketing Network
Message
The following is the XML message with the NETCONF edit-config operation and the required CLI commands.
<nc:rpc message-id="16" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
xmlns="http://www.cisco.com/nxos:1.0:if_manager">
<__XML__MODE__exec_configure>
<interface>2/30</interface>
<__XML__MODE_if-ethernet>
<__XML__MODE_if-ethernet>
<desc_line>Marketing Network</desc_line>
</__XML__MODE_if-ethernet>
</__XML__MODE_if-ethernet>
</__XML__MODE__exec_configure>
Reply
The following is the XML server reply to the message.
<nc:rpc-reply xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
xmlns="http://www.cisco.com/nxos:1.0:if_manager" message-id="16">
Default Settings
Table 3-1 lists the default SSH settings.
Table 3-1 SSH Defaults
Parameters
|
Default
|
SSH Version 6
|
Enabled
|
Additional References
For additional information related to implementing the XML management interface, see the following sections:
•
Standards
•
RFCs
Standards
Standards
|
Title
|
No new or modified standards are supported by this feature, and support for existing standards has not been modified by this feature.
|
—
|
RFCs
RFCs
|
Title
|
RFC 4741
|
NETCONF Configuration Protocol
|
RFC 4742
|
Using the NETCONF Configuration Protocol over Secure Shell (SSH)
|