cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
661
Views
0
Helpful
4
Replies

crud service works, but not netconfservice

fredrikjj
Level 1
Level 1

I'm working with csr1000v 16.4.1. I have this code:

from ydk.models.cisco_ios_xe.ned import Native

from ydk.services import CRUDService, NetconfService, Datastore

from ydk.providers import NetconfServiceProvider

bgp = Native().router.Bgp()

bgp.id = 100

new_neighbor = bgp.Neighbor()

new_neighbor.id = '2.2.2.2'

new_neighbor.remote_as = 65100

bgp.neighbor.append(new_neighbor)

provider = NetconfServiceProvider(address='192.168.1.127',

                                    port=830,

                                    username='admin',

                                    password='admin',

                                    protocol='ssh')

#nc = NetconfService()

#nc.edit_config(provider, Datastore.running, bgp)

crud = CRUDService()

crud.create(provider, bgp)

I have generated the APIs for the native model on IOS-XE using the guide here: Configuring Cisco IOS XE With YDK and OpenDaylight - Network-oriented programming

If I use crud, I can apply this config to the device, but if I use the netconfservice I get this error:

yangpy2) fred@ubuntu:~$ python netconftest.py

Traceback (most recent call last):

  File "netconftest.py", line 21, in <module>

    nc.edit_config(provider, Datastore.running, bgp)

  File "/home/fred/yangpy2/local/lib/python2.7/site-packages/ydk/services/netconf_service.py", line 291, in edit_config

    return self.executor.execute_rpc(provider, rpc)

  File "/home/fred/yangpy2/local/lib/python2.7/site-packages/ydk/services/executor_service.py", line 54, in execute_rpc

    rpc = MetaService.normalize_meta(provider._get_capabilities(), rpc)

  File "/home/fred/yangpy2/local/lib/python2.7/site-packages/ydk/services/meta_service.py", line 67, in normalize_meta

    deviation_tables = MetaService.get_active_deviation_tables(capabilities, entity)

  File "/home/fred/yangpy2/local/lib/python2.7/site-packages/ydk/services/meta_service.py", line 84, in get_active_deviation_tables

    active_pmodule_names = _get_active_deviation_module_names(capabilities, entity)

  File "/home/fred/yangpy2/local/lib/python2.7/site-packages/ydk/services/meta_service.py", line 132, in _get_active_deviation_module_names

    mname = _get_module_name_from_entity(entity)

  File "/home/fred/yangpy2/local/lib/python2.7/site-packages/ydk/services/meta_service.py", line 292, in _get_module_name_from_entity

    module_name = entity._meta_info().module_name

  File "/home/fred/yangpy2/local/lib/python2.7/site-packages/ydk/services/ietf_netconf.py", line 863, in _meta_info

    from _meta import _ietf_netconf as meta

  File "/home/fred/yangpy2/local/lib/python2.7/site-packages/ydk/services/_meta/_ietf_netconf.py", line 39, in <module>

    }, 'ietf-netconf', _yang_ns._namespaces['ietf-netconf']),

KeyError: 'ietf-netconf'

Please helps.

4 Replies 4

abhirame
Cisco Employee
Cisco Employee

Hi,

Which version of ydk are you using? Can you try the latest ydk (0.5.4). With 0.5.4, I'm not seeing this issue with NetconfService.

I was using 0.5.3. I've now upgraded to 0.5.4. The same script still works if I use crud, but I get a new error if I try netconf:

(ydk0.5.4py2) fred@ubuntu:~$ python netconftest.py

Traceback (most recent call last):

  File "netconftest.py", line 21, in <module>

    nc.edit_config(provider, Datastore.running, bgp)

  File "/home/fred/ydk0.5.4py2/local/lib/python2.7/site-packages/ydk/services/netconf_service.py", line 291, in edit_config

    return self.executor.execute_rpc(provider, rpc)

  File "/home/fred/ydk0.5.4py2/local/lib/python2.7/site-packages/ydk/services/executor_service.py", line 58, in execute_rpc

    ''

  File "/home/fred/ydk0.5.4py2/local/lib/python2.7/site-packages/ydk/providers/netconf_provider.py", line 94, in execute

    return self.sp_instance.execute_operation(payload, operation)

  File "/home/fred/ydk0.5.4py2/local/lib/python2.7/site-packages/ydk/providers/_provider_plugin.py", line 224, in execute_operation

    return self._handle_rpc_reply(operation, payload, reply.xml)

  File "/home/fred/ydk0.5.4py2/local/lib/python2.7/site-packages/ydk/providers/_provider_plugin.py", line 246, in _handle_rpc_reply

    self._handle_rpc_error(payload, reply_str, pathlist)

  File "/home/fred/ydk0.5.4py2/local/lib/python2.7/site-packages/ydk/providers/_provider_plugin.py", line 259, in _handle_rpc_error

    raise YPYServiceProviderError(error_code=YPYErrorCode.SERVER_REJ, error_msg=reply_str)

ydk.errors.YPYServiceProviderError: Server rejected request.

        error-type: application

        error-tag: unknown-element

        error-severity: error

        error-path: /rpc/edit-config/config/ios:bgp

        bad-element: bgp

(ydk0.5.4py2) fred@ubuntu:~$ cat netconftest.py

from ydk.models.cisco_ios_xe.ned import Native

from ydk.services import CRUDService, NetconfService, Datastore

from ydk.providers import NetconfServiceProvider

bgp = Native().router.Bgp()

bgp.id = 100

new_neighbor = bgp.Neighbor()

new_neighbor.id = '2.2.2.2'

new_neighbor.remote_as = 65100

bgp.neighbor.append(new_neighbor)

provider = NetconfServiceProvider(address='192.168.1.127',

                                    port=830,

                                    username='admin',

                                    password='admin',

                                    protocol='ssh')

nc = NetconfService()

nc.edit_config(provider, Datastore.running, bgp)

#crud = CRUDService()

#crud.create(provider, bgp)

Possibly some issue with how I have generated of the api via ydk-gen? Either way, considering that the XR bundle is what comes with the package, and that it doesn't really matter what OS I use (this is for educational purposes only), I will use XR instead from now on.

Glad you can get it to work with XR.

For the error, you could enable logging and try the erroneous script again. If you could then post the logs, I could debug it further.

The error message comes from the XE device.  Were you able to enable logging?  It'd help to contrast the logs when the CRUD service and the NETCONF service is used.