cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2506
Views
0
Helpful
2
Replies

Unable to push configuration using NETCONF, YANG with XML

rdhavade
Cisco Employee
Cisco Employee

I'm trying to push a simple configuration of shutting down an interface on IOS XR 6.2.2 using YANG model xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg.

 

Tried a lot with different options but unable to identify the reason why it isn't working. No luck in reading across many blogs/websites as well.

 

XML rpc-request data:

config_interface = """
<config>
<interface-configurations xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg">
<interface-configuration>
<active>act</active>
<interface-name>TenGigE10633/0/0/1</interface-name>
<shutdown/>
</interface-configuration>
</interface-configurations>
</config>
"""

after sending above to IOS-XR node, the rpc-reply comes back as-

OrderedDict([('rpc-reply', OrderedDict([('@message-id', 'urn:uuid:19d93944-b71d-471b-a3e1-a8fbe09fde2c'), ('@xmlns:nc', 'urn:ietf:params:xml:ns:netconf:base:1.0'), ('@xmlns', 'urn:ietf:params:xml:ns:netconf:base:1.0'), ('ok', None)]))])

 

In the IOS XR debugs I see below:

RP/0/RSP0/CPU0:Feb 18 12:10:29.281 : netconf[1126]: TRC: NC: Hello message validation success
RP/0/RSP0/CPU0:Feb 18 12:10:30.660 : netconf_sshd_proxy[65798]: TRC: NC: SSH PIPE INPUT cond: 0x1, fd 26, ctx 420ab80
RP/0/RSP0/CPU0:Feb 18 12:10:30.660 : netconf_sshd_proxy[65798]: TRC: NC: CLIENT read: 513
RP/0/RSP0/CPU0:Feb 18 12:10:30.660 : netconf_sshd_proxy[65798]: TRC: NC: CLIENT->SERVER 513
RP/0/RSP0/CPU0:Feb 18 12:10:30.660 : netconf[1126]: TRC: NC: EOM received, data len: 503
RP/0/RSP0/CPU0:Feb 18 12:10:30.660 : netconf[1126]: DBG: NC: Trying to process RPC message internally
RP/0/RSP0/CPU0:Feb 18 12:10:30.660 : netconf[1126]: DBG: NC: Operation <edit-config> will be handled in normal parsing
RP/0/RSP0/CPU0:Feb 18 12:10:30.661 : netconf[1126]: TRC: NC: adding http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg to namespace hashmap
RP/0/RSP0/CPU0:Feb 18 12:10:30.661 : netconf[1126]: TRC: NC: Tag <active> data len: 3
RP/0/RSP0/CPU0:Feb 18 12:10:30.661 : netconf[1126]: TRC: NC: Element <active> is not outer-most element under <filter>, state is unchanged.
RP/0/RSP0/CPU0:Feb 18 12:10:30.661 : netconf[1126]: TRC: NC: Tag <interface-name> data len: 18
RP/0/RSP0/CPU0:Feb 18 12:10:30.661 : netconf[1126]: TRC: NC: Element <interface-name> is not outer-most element under <filter>, state is unchanged.
RP/0/RSP0/CPU0:Feb 18 12:10:30.661 : netconf[1126]: TRC: NC: Element <shutdown> is not outer-most element under <filter>, state is unchanged.
RP/0/RSP0/CPU0:Feb 18 12:10:30.661 : netconf[1126]: TRC: NC: Element <interface-configuration> is not outer-most element under <filter>, state is unchanged.
RP/0/RSP0/CPU0:Feb 18 12:10:30.661 : netconf[1126]: TRC: NC: Element <interface-configurations> is not outer-most element under <filter>, state is unchanged.
RP/0/RSP0/CPU0:Feb 18 12:10:30.661 : netconf[1126]: TRC: NC: Parsed the incoming message

 

The python code to do this is -

import os
import sys
import xmltodict
from ncclient import manager
from pprint import pprint

m = manager.connect(host = '172.18.120.144', username = 'root', password = 'root', hostkey_verify = False, port = 830)

print('NETCONF session is connected : '+ str(m.connected))


config_interface = """
<config>
<interface-configurations xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg">
<interface-configuration>
<active>act</active>
<interface-name>TenGigE10633/0/0/1</interface-name>
<shutdown/>
</interface-configuration>
</interface-configurations>
</config>
"""
rpc_reply = m.edit_config(config_interface, target = 'candidate')
output_dictn = xmltodict.parse(rpc_reply.xml)
print(output_dictn)
m.close_session()
print('NETCONF session status : ' + str(m.connected))

rpc-reply is coming ok, but configuration is not getting applied on the router.
Can someone please guide as to what can be wrong here ?.

 

Just to give a glimpse of the YANG model-

module: Cisco-IOS-XR-ifmgr-cfg
  +--rw global-interface-configuration
  |  +--rw link-status?   Link-status-enum
  +--rw interface-configurations
     +--rw interface-configuration* [active interface-name]
        +--rw dampening
        |  +--rw args?                 enumeration
        |  +--rw half-life?            uint32
        |  +--rw reuse-threshold?      uint32
        |  +--rw suppress-threshold?   uint32
        |  +--rw suppress-time?        uint32
        |  +--rw restart-penalty?      uint32
        +--rw mtus
        |  +--rw mtu* [owner]
        |     +--rw owner    xr:Cisco-ios-xr-string
        |     +--rw mtu      uint32
        +--rw encapsulation
        |  +--rw encapsulation?         string
        |  +--rw capsulation-options?   int32
        +--rw shutdown?                      empty
        +--rw interface-virtual?             empty
        +--rw secondary-admin-state?         Secondary-admin-state-enum
        +--rw interface-mode-non-physical?   Interface-mode-enum
        +--rw bandwidth?                     uint32
        +--rw link-status?                   empty
        +--rw description?                   string
        +--rw active                         Interface-active
        +--rw interface-name                 xr:Interface-name

1 Accepted Solution

Accepted Solutions

rdhavade
Cisco Employee
Cisco Employee

Finally got the solution to the issue.

In the end of the code I shared, after using the "edit_config" method for instance of class "manager", we have to call "commit" function using the instance of class "manager".

i.e.:

m = manager.connect(host = '172.18.120.144', username = 'root', password = 'root', hostkey_verify = False, port = 830)

m.edit_config(config-loopback, target = candidate)

m.commit()

 

View solution in original post

2 Replies 2

rdhavade
Cisco Employee
Cisco Employee
rpc-reply is coming ok, but configuration is not getting applied on the router.
Can someone please guide as to what can be wrong here ?.

rdhavade
Cisco Employee
Cisco Employee

Finally got the solution to the issue.

In the end of the code I shared, after using the "edit_config" method for instance of class "manager", we have to call "commit" function using the instance of class "manager".

i.e.:

m = manager.connect(host = '172.18.120.144', username = 'root', password = 'root', hostkey_verify = False, port = 830)

m.edit_config(config-loopback, target = candidate)

m.commit()

 

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Recognize Your Peers