09-04-2020 04:47 AM - last edited on 05-08-2023 11:30 AM by Paul Zimmerman
Hi all
I'm trying to add Tags through netconf to an Access Point on a WLC98k (17.3.1).
Here is the code:
from ncclient import manager insert_ap_cfg_data = ''' <ap-cfg-data xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-wireless-ap-cfg"> <ap-tags> <ap-tag> <ap-mac>a4:53:0e:39:d3:f8</ap-mac> <policy-tag>policy-tag</policy-tag> <site-tag>site-tag</site-tag> <rf-tag>rf-tag_typical_density</rf-tag> </ap-tag> </ap-tags> </ap-cfg-data> ''' wlc = {"host": "10.90.255.180", "port": "xxx", "username": "xxx", "password": "xxx"} with manager.connect(host=wlc['host'], port=wlc['port'], username=wlc['username'], password=wlc['password'], hostkey_verify=False, device_params={'name':'iosxe'}) as wlc_con: connected = wlc_con.connected if connected: print('Connection to ' + wlc['host'] + ' established!\n') reply = wlc_con.edit_config(target='running', config=insert_ap_cfg_data) print(reply)
But all I'm getting is this error:
[root@ansible temp]# python3 wlc98k_config_ap.py Connection to 10.90.255.180 established! Traceback (most recent call last): File "wlc98k_config_ap.py", line 46, in <module> reply = wlc_con.edit_config(target='running', config=insert_ap_cfg_data) File "/usr/local/lib/python3.6/site-packages/ncclient/manager.py", line 231, in execute huge_tree=self._huge_tree).request(*args, **kwds) File "/usr/local/lib/python3.6/site-packages/ncclient/operations/edit.py", line 65, in request node.append(validated_element(config, ("config", qualify("config")))) File "/usr/local/lib/python3.6/site-packages/ncclient/xml_.py", line 150, in validated_element raise XMLError("Element [%s] does not meet requirement" % ele.tag) ncclient.xml_.XMLError: Element [{http://cisco.com/ns/yang/Cisco-IOS-XE-wireless-ap-cfg}ap-cfg-data] does not meet requirement
What am I missing here?
Best regards,
Oli
09-04-2020 08:42 AM
I changed the netconf payload to this:
<config> <ap-cfg-data xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-wireless-ap-cfg"> <ap-tags> <ap-tag> <ap-mac>a4:53:0e:39:d3:f8</ap-mac> <policy-tag>policy-tag</policy-tag> <site-tag>site-tag</site-tag> <rf-tag>rf-tag_typical_density</rf-tag> </ap-tag> </ap-tags> </ap-cfg-data> </config>
But now I am getting this message:
[root@ansible temp]# python3 wlc98k_config_ap.py Connection to 10.90.255.180 established! Traceback (most recent call last): File "wlc98k_config_ap.py", line 15, in <module> reply = wlc_con.edit_config(target='running', config=netconf_payload) File "/usr/local/lib/python3.6/site-packages/ncclient/manager.py", line 231, in execute huge_tree=self._huge_tree).request(*args, **kwds) File "/usr/local/lib/python3.6/site-packages/ncclient/operations/edit.py", line 69, in request return self._request(node) File "/usr/local/lib/python3.6/site-packages/ncclient/operations/rpc.py", line 360, in _request raise self._reply.error ncclient.operations.rpc.RPCError: {'type': 'protocol', 'tag': 'unknown-element', 'app_tag': None, 'severity': 'error', 'info': '<?xml version="1.0" encoding="UTF-8"?><error-info xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><bad-element>config</bad-element>\n</error-info>\n', 'path': '\n /rpc/edit-config\n ', 'message': None}
Any ideas?
09-05-2020 03:27 PM
It is possible that YANG model Cisco-IOS-XE-wireless-ap-cfg.yang is not included in your router's configuration. Please check your router's YANG capabilities:
ssh -p <netconf-port> <username>@10.90.255.180 -s netconf
09-07-2020 01:51 AM
Hi Yan
The module is included. I was able to read the Access Point configuration through "get-config" without any issues. I basically copied the "get-config" output to create the configuration snippet.
It might be an issue with the Software version, someone else is facing something similar:
I'm going to try an earlier release and report back if it fixed it.
Oli
09-07-2020 05:50 AM
I can now confirm that the script runs on a WLC with version 16.12.4a but not on one with version 17.3.1. Yang model is identical.
WTH Cisco?!
09-08-2020 07:53 PM
I am getting this on 17.3.1
ncclient.operations.rpc.RPCError: {'type': 'protocol', 'tag': 'unknown-element', 'app_tag': None, 'severity': 'error', 'info': '<?xml version="1.0" encoding="UTF-8"?><error-info xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><bad-element>config</bad-element>\n</error-info>\n', 'path': '\n /rpc/edit-config\n ', 'message': None}
09-09-2020 01:25 AM - edited 09-09-2020 02:26 AM
Same as me :-(
Here is an interesting observation I made: Yesterday I installed the advanced netconf explorer (https://github.com/cisco-ie/anx) and used its Netconf console to configure the WLC.
I tried this snippet on a WLC98k 17.3.1:
<edit-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <target> <running/> </target> <config> <ap-cfg-data xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-wireless-ap-cfg"> <ap-tags> <ap-tag> <ap-mac>10:10:10:10:10:10</ap-mac> <policy-tag>policy_test_tag</policy-tag> <site-tag>site_test_tag</site-tag> <rf-tag>rf_test_tag</rf-tag> </ap-tag> </ap-tags> </ap-cfg-data> </config> </edit-config>
It worked with the advanced netconf explorer:
Then I removed the "edit-config" and "target" part of the snippet so it looked like this:
<config> <ap-cfg-data xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-wireless-ap-cfg"> <ap-tags> <ap-tag> <ap-mac>10:10:10:10:10:10</ap-mac> <policy-tag>policy_test_tag</policy-tag> <site-tag>site_test_tag</site-tag> <rf-tag>rf_test_tag</rf-tag> </ap-tag> </ap-tags> </ap-cfg-data> </config>
And then I called it with the python ncclient:
reply_raw = wlc_con.edit_config(target='running', config=netconf_payload)
This did not work on 17.3.1 but worked on 16.12.4a. I think there might be a communication issue between the ncclient and the WLC.
Oli
09-09-2020 04:10 PM
mine fails through netconf explorer
<config> <wlan-cfg-data xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-wireless-wlan-cfg"> <wlan-cfg-entries> <wlan-cfg-entry xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-wireless-wlan-cfg"> <profile-name xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-wireless-wlan-cfg">WT-Python</profile-name> <wlan-id xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-wireless-wlan-cfg">204</wlan-id> <auth-key-mgmt-psk xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-wireless-wlan-cfg">true</auth-key-mgmt-psk> <auth-key-mgmt-dot1x xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-wireless-wlan-cfg">false</auth-key-mgmt-dot1x> <psk xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-wireless-wlan-cfg">12345678</psk> <radio-policy xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-wireless-wlan-cfg">apf-vap-radio-80211a-only</radio-policy> <apf-vap-id-data xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-wireless-wlan-cfg"> <broadcast-ssid xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-wireless-wlan-cfg">true</broadcast-ssid> <ssid xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-wireless-wlan-cfg">WT Python</ssid> <wlan-status xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-wireless-wlan-cfg">true</wlan-status> </apf-vap-id-data> </wlan-cfg-entry> </wlan-cfg-entries> </wlan-cfg-data> </config>
Gives me
<rpc-error xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <error-type>protocol</error-type> <error-tag>operation-not-supported</error-tag> <error-severity>error</error-severity> <error-info> <bad-element>config</bad-element> </error-info> </rpc-error>
This worked on 16.12.4a as well
09-18-2020 11:35 AM
Thanks everyone. Can confirm, had the same error on 17.3.1 but rolled back to 16.12.4a and its working as expected.
12-08-2021 12:48 PM
I can confirm i am having the same issue as mentioned above. I can run a python script to my WLC on 16.12.x code. However, I'm unable to perform the same function with my WLC on 17.x.x code. it still looks like an issue between ncclient and the WLC on 17.x.x.
12-17-2021 02:15 PM
I this just a perm broken ? did anyone fix this ?
04-07-2022 12:23 AM
Have you tried this solution?
https://github.com/ncclient/ncclient/issues/489
04-07-2022 06:53 AM
Thanks for very helpful link!
I changed the following RPC:
<ap-cfg-data xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-wireless-ap-cfg"> <ap-tags> <ap-tag> <ap-mac>10:10:10:10:10:10</ap-mac> <policy-tag>policy-tag</policy-tag> <site-tag>site-tag</site-tag> <rf-tag>rf-tag_typical_density</rf-tag> </ap-tag> </ap-tags> </ap-cfg-data>
To this:
<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <ap-cfg-data xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-wireless-ap-cfg"> <ap-tags> <ap-tag> <ap-mac>10:10:10:10:10:10</ap-mac> <policy-tag>policy_tag</policy-tag> <site-tag>site_tag</site-tag> <rf-tag>rf-tag_typical_density</rf-tag> </ap-tag> </ap-tags> </ap-cfg-data> </config>
This way it works now! I tested it on 17.3.4
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide