cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
374
Views
0
Helpful
8
Replies
Highlighted
Beginner

WLC98k Configure AP Tags through Netconf

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

8 REPLIES 8
Highlighted
Beginner

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?

Highlighted

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

 

Yan Gorelik
YDK Solutions
Highlighted

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:

https://community.cisco.com/t5/yang-development-kit-ydk/netconf-error-in-ios-xe-17-3-1a-but-works-fine-on-ios-xe-16-12-4/m-p/4146535#M1670

I'm going to try an earlier release and report back if it fixed it.

Oli

Highlighted

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?!

Highlighted

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}

CCNP - Wireless
CWNE #136
Highlighted

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:

 

anx_console.PNG

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

Highlighted

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

CCNP - Wireless
CWNE #136
Highlighted

Thanks everyone. Can confirm, had the same error on 17.3.1 but rolled back to 16.12.4a and its working as expected.

Content for Community-Ad
Cisco Community October 2020 Spotlight Award Winners
This widget could not be displayed.