NETCONF Operations
NETCONF protocol defines a set of operations to modify or obtain information in datastores.
For AsterNOS, operations supported situation are as following:
| Operation | Status | Description |
|---|---|---|
| <get-config> | Supported | Obtains some or all configuration data from the |
| <get> | Supported | Obtains some or all running configuration data and status data from the |
| <edit-config> | Supported | Add/Modify/Delete configuration in |
| <copy-config> | Supported | Replaces the target database with the source database. If no target database has been created, this operation creates a database and then replaces the database. |
| <close-session> | Supported | Closes a NETCONF session. |
<get-config>
Section titled “<get-config>”Description
Section titled “Description”AsterNOS support to retrieve all or part of a specified configuration datastore via <get-config>.
Parameters
Section titled “Parameters”- source: Name of the configuration datastore being queried, such as <running/>.
- filter: This parameter identifies the portions of the device configuration datastore to retrieve. If this parameter is not present, the entire configuration is returned.
Positive Response
Section titled “Positive Response”If the device can satisfy the request, the server sends an <rpc-reply> element containing a <data> element with the results of the query.
Negative Response
Section titled “Negative Response”An <rpc-error> element is included in the <rpc-error> if the request cannot be completed for any reason.
Example
Section titled “Example”To retrieve the entire <vlans> subtree:
<filter type="subtree"> <top> <vlans xmlns="http://asterfusion.com/ns/yang/asternos-vlan"/> </top></filter>Reply:
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <top> <vlans xmlns="http://asterfusion.com/ns/yang/asternos-vlan"> <vlan> <vlanid>100</vlanid> <mac-limit>10000</mac-limit> <description>this is a test1</description> <unknown-unicast-action>flood</unknown-unicast-action> <unknown-multicast-action>drop</unknown-multicast-action> </vlan> <vlan> <vlanid>200</vlanid> <mac-limit>20000</mac-limit> <description>this is a test2</description> <unknown-unicast-action>flood</unknown-unicast-action> <unknown-multicast-action>drop</unknown-multicast-action> </vlan> <vlan> <vlanid>4000</vlanid> <mac-limit>20000</mac-limit> <description>test</description> <unknown-unicast-action>flood</unknown-unicast-action> <unknown-multicast-action>drop</unknown-multicast-action> </vlan> </vlans> </top></data><edit-config>
Section titled “<edit-config>”Description
Section titled “Description”AsterNOS support <edit-config> operation to <running>/<startup>/<candidate>.
The <edit-config> operation loads all or part of a specified configuration to the specified target configuration datastore.
This operation allows the new configuration to be expressed in xml format data. If the target configuration datastore does not exist, it will be created.
If a NETCONF peer supports the :url capability (Section 8.8), the <url> element can appear instead of the <config> parameter. The device analyzes the source and target configurations and performs the requested changes. The target configuration is not necessarily replaced, as with the <copy-config> message. Instead, the target configuration is changed in accordance with the source’s data and requested operations.
If the <edit-config> operation contains multiple sub-operations that apply to the same conceptual node in the underlying data model, then the result of the operation is undefined (i.e., outside the scope of the NETCONF protocol).
Operation
Section titled “Operation”Elements in the <config> subtree MAY contain an “operation” attribute. The attribute identifies the point in the configuration to perform the operation and MAY appear on multiple elements throughout the <config> subtree.
If the “operation” attribute is not specified, the configuration is merged into the configuration datastore.
The “operation” attribute has one of the following values:
merge
The configuration data identified by the element containing this attribute is merged with the configuration at the corresponding level in the configuration datastore identified by the <target> parameter. This is the default behavior.
replace
The configuration data identified by the element containing this attribute replaces any related configuration in the configuration datastore identified by the <target> parameter. If no such configuration data exists in the configuration datastore, it is created. Unlike a <copy-config> operation, which replaces the entire target configuration, only the configuration actually presents in the <config> parameter is affected.
create
The configuration data identified by the element containing this attribute is added to the configuration if and only if the configuration data does not already exist in the configuration datastore. If the configuration data exists, an <rpc-error> element is returned with an <error-tag> value of “data-exists”.
delete
The configuration data identified by the element containing this attribute is deleted from the configuration if and only if the configuration data currently exists in the configuration datastore. If the configuration data does not exist, an <rpc-error> element is returned with an <error-tag> value of “data-missing”.
remove
Not supported currently.
Parameters
Section titled “Parameters”- target: Name of the configuration datastore being edited, such as <running/> or <candidate/>.
- config: A hierarchy of configuration data as defined by one of the device’s data models.The contents MUST be placed in an appropriate namespace, to allow the device to detect the appropriate data model, and the contents MUST follow the constraints of that data model, as defined by its capability definition. Capabilities are discussed in Capabilities.
Positive Response
Section titled “Positive Response”If the device was able to satisfy the request, an <rpc-reply> is sent containing an <ok> element.
Negative Response
Section titled “Negative Response”An <rpc-error> response is sent if the request cannot be completed for any reason.
Example
Section titled “Example”The <edit-config> examples in this section utilize a simple data model, in which multiple vlans of the <vlan> element can be present, and an instance is distinguished by the <vlanid> element within each <vlan> element.
Set the description to “test netconf” on a vlan “100” in the running configuration:
<config> <top> <vlans xmlns="http://asterfusion.com/ns/yang/asternos-vlan"> <vlan operation="merge"> <vlanid>100</vlanid> <description>test netconf</description> </vlan> </vlans> </top></config>Create a new vlan with vlanid=200:
<config> <top> <vlans xmlns="http://asterfusion.com/ns/yang/asternos-vlan"> <vlan operation="create"> <vlanid>200</vlanid> </vlan> </vlans> </top></config>Delete vlan 100:
<config> <top> <vlans xmlns="http://asterfusion.com/ns/yang/asternos-vlan"> <vlan operation="delete"> <vlanid>100</vlanid> </vlan> </vlans> </top><config>replace vlan 100:
<config> <top> <vlans xmlns="http://asterfusion.com/ns/yang/asternos-vlan"> <vlan operation="replace"> <vlanid>100</vlanid> <description>this is a replaced vlan 100</description> </vlan> </vlans> </top><config><copy-config>
Section titled “<copy-config>”Description
Section titled “Description”AsterNOS support <copy-config>, source can be <running>/<startup>/<uri>, target can be <startup>/<uri>.
<copy-config> can create or replace an entire configuration datastore with the contents of another complete configuration datastore.
If the target datastore exists, it is overwritten. Otherwise, a new one is created, if allowed.
Parameters
Section titled “Parameters”-
target: Name of the configuration datastore to use as the destination of the <copy-config> operation.Support <startup>/<uri>.
-
source: Name of the configuration datastore to use as the source of the <copy-config> operation. Support <running>/<startup>/<uri>.
Positive Response
Section titled “Positive Response”If the device was able to satisfy the request, an <rpc-reply> is sent that includes an <ok> element.
Negative Response
Section titled “Negative Response”An
Example
Section titled “Example”Request:
<rpc message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <copy-config> <target> <startup/> </target> <source> <running/> </source> </copy-config></rpc>Reply:
<rpc-reply message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <ok/></rpc-reply>Description
Section titled “Description”AsterNOS support <get> to obtain config and state( defined with ‘config false’ in YANG). <get> is used to retrieve running configuration and device state information.
Parameters
Section titled “Parameters”filter: This parameter specifies the portion of the system configuration and state data to retrieve.If this parameter is not present, all the device configuration and state information is returned.
The <filter> element MUST contain a “type” attribute with value ‘subtree’. User may refer to Subtree Filtering for more detailed info about subtree filter on AsterNOS.
Positive Response
Section titled “Positive Response”If the device was able to satisfy the request, an <rpc-reply> is sent. The <data> section contains the appropriate subset.
Negative Response
Section titled “Negative Response”An <rpc-reply> element is included in the <rpc-reply> if the request cannot be completed for any reason.
Example
Section titled “Example”This example shows how to get PTP instance <current-ds> under a specified PTP instance.
<filter type="subtree"> <top xmlns="http://www.asterfusion.com/asternos-schema/1.0/config"> <ptp> <instances> <instance> <instance-number>0</instance-number> <current-ds/> </instance> </instances> </ptp> </top></filter>Reply:
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <top xmlns="http://www.asterfusion.com/asternos-schema/1.0/config"> <ptp> <instances> <instance> <instance-number>0</instance-number> <current-ds> <offset-from-master>0</offset-from-master> <mean-path-delay>0</mean-path-delay> <servo-state>unlocked</servo-state> </current-ds> </instance> </instances> </ptp> </top></data>For more subtree info, user may refer to Subtree Filtering.
<close-session>
Section titled “<close-session>”Description
Section titled “Description”AsterNOS support to use <close-session> to request graceful termination of a NETCONF session.
When NETCONF server receives a <close-session> request, it will gracefully close the session. The server will release any locks and resources associated with the session and gracefully close any associated connections. Any NETCONF requests received after a <close-session> request will be ignored.
Positive Response
Section titled “Positive Response”If the device was able to satisfy the request, an <rpc-reply> is sent that includes an <ok> element.
Negative Response
Section titled “Negative Response”An <rpc-reply> element is included in the <rpc-reply> if the request cannot be completed for any reason.
Example
Section titled “Example”Request:
<rpc message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <close-session/></rpc>Reply:
<rpc-reply message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <ok/></rpc-reply>