No relevant resource is found in the selected language.

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Read our privacy policy>Search

Reminder

To have a better experience, please upgrade your IE browser.

upgrade

NETCONF YANG API Reference

AR100, AR120, AR160, AR1200, AR2200, AR3200, and AR3600 V300R003

NETCONF YANG API Reference
Rate and give feedback:
Huawei uses machine translation combined with human proofreading to translate this document to different languages in order to help you better understand the content of this document. Note: Even the most advanced machine translation cannot match the quality of professional translators. Huawei shall not bear any responsibility for translation accuracy and it is recommended that you refer to the English document (a link for which has been provided).
NETCONF Request

NETCONF Request

The NETCONF client encapsulates requests in the <rpc> element and sends them to the server. RFC 6241 defines various operations, such as get and get-config. NETCONF API supports operation subsets defined by the protocol. For details, see RFC 6241.

Table 2-2 NETCONF operations

Operation

Description

XML Format

get

Obtains data including running status data and configuration data.

<filter: <filter> element filters information. If this element is not specified, the entire configuration is returned.

NOTE:

The current version supports only subtree filtering, does not support xpath filtering. The target database of all operations must be running datastore, that is, the value of <source></source> must be <running/>.

Check requests of all interfaces on the server.

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

<rpc message-id="1003" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">

<get>

<source>

<running/>

</source>

<filter type="subtree">

<interfaces-state xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">

<interface/>

</interfaces-state>

</filter>

</get>

</rpc>

]]>]]>

get-config

Obtain all or part of the specified configuration database. The configuration database contains only the configuration data but not the status data.

<filter: <filter> element filters information. If this element is not specified, the entire configuration is returned.

NOTE:

The current version supports only subtree filtering, does not support xpath filtering.

Check requests of configuring security policies on the server:

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

<rpc message-id="1003" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">

<get-config>

<source>

<running/>

</source>

<filter type="subtree">

<sec-policy xmlns="urn:huawei:params:xml:ns:yang:huawei-security-policy">

</sec-policy>

</filter>

</get-config>

</rpc>

]]>]]>

edit-config: merge

Loads the specified configuration based on running configuration.

For the merge operation, the operation object must be specified.

  • If the specified object exists, you can directly configure the object.
  • If the specified object does not exist but can be created, you need to create and configure the object in sequence.
  • If the specified object does not exist and cannot be created, the operation fails.

Request of configuring a VLANIF interface on the server:

<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="DEVICECONFIG_6239492e9d4f442bbca31e4d447e3364">

<edit-config>

<target>

<running/>

</target>

<error-option>rollback-on-error</error-option>

<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">

<vlans xmlns="urn:huawei:params:xml:ns:yang:huawei-vlan">

<vlan>

<id>12</id>

<enabled>true</enabled>

</vlan>

</vlans>

<interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">

<interface>

<name>Vlanif12</name>

<type xmlns:iana="urn:ietf:params:xml:ns:yang:iana-if-type">iana:ethernetCsmacd</type>

<ipv4 xmlns="urn:ietf:params:xml:ns:yang:ietf-ip">

<address>

<ip>11.11.26.11</ip>

<prefix-length>24</prefix-length>

</address>

</ipv4>

</interface>

</interfaces>

</config>

</edit-config>

</rpc>

edit-config: create

Creates a specified object. For the create operation, the configuration object must be specified. The XML data format of the create operation is similar to that of the merge operation, but the attribute of the operation must be create.

  • If the current configuration table supports object creation and the curnet object does not exist, create the configuration object and specified configuration in sequence.
  • If the corresponding configuration items of the configuration object already exist, a message indicating that the data already exists is returned.

The packet format is similar to that of the merge operation, and nc:operation="merge" is changed to nc:operation="create".

edit-config: replace

Replaces the specified configuration.

  • When the specified replacement object does not exist, create the object.
  • When the specified replacement object has only the table index, all configurations of the specified object are replaced.

The packet format is similar to that of the merge operation, and nc:operation="merge" is changed to nc:operation="replace".

edit-config: remove

Removes specified configuration.

  • When the specified deletion object has only the table index, all configurations of the specified object and the specified object are removed.
  • When the specified deletion object has the table index and corresponding configuration items, the specified configuration of the object is removed.
  • If the specified object does not exist, an error is returned.

The packet format is similar to that of the merge operation, and nc:operation="merge" is changed to nc:operation="remove".

edit-config: delete

Deletes specified configuration.

  • When the specified deletion object has only the table index, all configurations of the specified object and the specified object are deleted.
  • When the specified deletion object has the table index and corresponding configuration items, the specified configuration of the object is deleted.
  • If the specified object does not exist in the system, the system returns an error message indicating that the object does not exist.

The packet format is similar to that of the merge operation, and nc:operation="merge" is changed to nc:operation="delete".

edit-config: Operation

Modifies the current system configuration. When the mode for modifying the configuration is not specified in XML messages, the default operation is used. The default operation is merge, which can be configured through <default-operation> in XML messages. The values are as follows:

  • merge: is used when the configuration mode and operation are not specified.
  • none: is used when the configuration mode is not specified and the default operation is none. The none operation is mainly used for check, and the configuration with the none operation is only used for schema check. When syntax check is successful, a success message is returned. Otherwise, a failure message is returned.

The none operation is just for format verification, and is not delivered to the system. The XML request is as follows:

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

<rpc message-id="1001" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">

<edit-config>

<target>

<running/>

</target>

<error-option>rollback-on-error</error-option>

<config>

<sec-policy xmlns="urn:huawei:params:xml:ns:yang:huawei-security-policy" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">

<vsys>

<name>public</name>

<static-policy>

<rule nc:operation="merge">

<name>test1</name>

</rule>

</static-policy>

</vsys>

</sec-policy>

</config>

</edit-config>

</rpc>

]]>]]>

edit-config: error processing option

Loads the specified configuration to the system and complets the configured operation. During <edit-config> execution, if a configuration error of an instance occurs, an error is returned. To allow flexible applications, <edit-config> provides error options. Different values can be set for error options. When errors occur, different operations are performed.

<error-option> is used to configure a processing mode of subsequent instances when a configuration error of an instance occurs. The default value is all stop-on-error. The values are as follows:

  • stop-on-error: stops processing and returns an error. This is the default option.
  • continue-on-error: continues processing and reports an error.
  • rollback-on-error: stops processing and restores the configuration to the status before <edit-config>Operation.

Create a security policy, stop executing it when an error occurs, and restore the configuration to the status before <edit-config> execution. The XML request is as follows:

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

<rpc message-id="1001" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">

<edit-config>

<target>

<running/>

</target>

<error-option>rollback-on-error</error-option>

<config>

<sec-policy xmlns="urn:huawei:params:xml:ns:yang:huawei-security-policy" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">

<vsys>

<name>public</name>

<static-policy>

<rule nc:operation="merge">

<name>test1</name>

</rule>

</static-policy>

</vsys>

</sec-policy>

</config>

</edit-config>

</rpc>

]]>]]>

close-session

Requests to terminate the current NETCONF session.

Request of terminating the current NETCONF session with no ID specified:

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

<rpc message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">

<close-session/>

</rpc>

]]>]]>

kill-session

Terminates the NETCONF session with the specified ID. Even if the ID does not exist on the specified NETCONF server, the server returns <ok>.

Request of terminating NETCONF session 686

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

<rpc message-id="1010" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">

<kill-session>

<session-id>686</session-id>

</kill-session>

</rpc>

]]>]]>

Response message:

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

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1010">

<ok/>

</rpc-reply>

]]>]]>

Translation
Download
Updated: 2019-03-06

Document ID: EDOC1100022096

Views: 8367

Downloads: 69

Average rating:
This Document Applies to these Products
Related Documents
Related Version
Share
Previous Next