08-31-2018 05:18 AM
Hi All,
I'm trying a simple python script based on the YDK module to send some BGP configuration to ODL.
I've based my script on the example found in core/samples/path_odl_bgp.py and bgp_xr_opendaylight.py.
But when I run my script I got the following error:
Traceback (most recent call last): File "obgp.py", line 21, in <module> odl_provider = OpenDaylightServiceProvider(repo, "127.0.0.1", "admin", "admin", 8181, EncodingFormat.XML) ValueError: type must be string, but is object
Here's the full script:
import os
import sys
from argparse import ArgumentParser
from ydk.types import Empty
from ydk.services import CRUDService
from ydk.providers import OpenDaylightServiceProvider
from ydk.errors import YError
from ydk.types import EncodingFormat
from ydk.models.openconfig.openconfig_bgp import Bgp
from ydk.models.cisco_ios_xe.Cisco_IOS_XE_native import Native
from ydk.path import Repository
repo = Repository("/opt/karaf-0.8.3/cache/schema") # In this case, we have a ODL boron instance with this schema cache location
odl_provider = OpenDaylightServiceProvider(repo, "127.0.0.1", "admin", "admin", 8181, EncodingFormat.XML)
bgp = openconfig_bgp.Bgp()
bgp.global_.config.as_ = 65023
crud_service = CRUDService()
crud_service.create(provider.get_node_provider('1681'), bgp)
odl_run(crud_service, provider)
I can't figure out what's wrong with the repository path.
Any help appreciated.
Thanks,
Benjamin
09-07-2018 04:28 PM
I cannot reproduce this issue. Your code is working fine for me. My env:
$ pip list|grep ydk ydk 0.7.2
09-10-2018 10:17 PM
Thanks for your check.
Here's my env:
root@odl-01-501:/opt/netapps# pip list | grep ydk
ydk (0.7.2)
ydk-models-cisco-ios-xe (16.8.1.post1)
ydk-models-ietf (0.1.5.post1)
ydk-models-openconfig (0.1.5)
Anything which would cause conflict ?
If not then I'll spawn a new VM and retry from a clean install.
Thanks,
Benjamin
09-20-2018 02:27 PM
Any luck with your new VM?
09-23-2018 10:49 PM
Unfortunately I got the same error with a new VM:
root@odl-02-501:/opt# python obgp.py
Traceback (most recent call last):
File "obgp.py", line 28, in <module>
odl_provider = OpenDaylightServiceProvider(repo , "127.0.0.1" , "admin" , "admin" , 8181 , EncodingFormat.XML)
ValueError: type must be string, but is object
I'm using Python 2.7.12 , I'll give it a try with python3.x anytime soon.
Benjamin
01-14-2020 06:39 AM
Hi Abhirame,
Would you be able to tell me if YDK 0.8.4 is working with ODL 0.11.1 ?
I got a little bit further in the troubleshooting and it seems that YDK doesn't like the answer it receives from ODL.
I can see that the connection is triggered (thanks to tshark) with:
odl_provider = OpenDaylightServiceProvider(repo, "127.0.0.1", "admin", "admin", 8181, EncodingFormat.XML)
but for some reason when the replies come back from the ODL python output:
Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: type must be string, but is object
So I'd be interested to know if YDK 0.8.4 has been tested with ODL version > 5.2(Boron)
Thanks,
01-14-2020 09:15 AM
Found out that when my device is in "connecting" state with my controller it's actually not complaining
opendaylight-user@root>netconf:list-devices NETCONF ID | NETCONF IP | NETCONF Port | Status -------------------------------------------------------------- EDG-01-216.BRU1-IXN | 10.1.128.120 | 1830 | connecting >>> >>> odl_provider = OpenDaylightServiceProvider(repo, "10.1.20.144", "admin", "admin", 8181, EncodingFormat.XML) >>>
but as soon as the device is connected, then it fails:
opendaylight-user@root>netconf:list-devices NETCONF ID | NETCONF IP | NETCONF Port | Status ------------------------------------------------------------- EDG-01-216.BRU1-IXN | 10.1.128.120 | 1830 | connected >>> >>> odl_provider = OpenDaylightServiceProvider(repo, "10.1.20.144", "admin", "admin", 8181, EncodingFormat.XML) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: type must be string, but is object
Below the output from a curl call just like YDK seems to be doing when it's working (for YDK):
~$ curl http://admin:admin@10.1.20.144:8181/restconf/operational/network-topology:network-topology/ | jq ''
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 246 0 246 0 0 1200 0 --:--:-- --:--:-- --:--:-- 1200
{
"network-topology": {
"topology": [
{
"topology-id": "topology-netconf",
"node": [
{
"node-id": "EDG-01-216.BRU1-IXN",
"netconf-node-topology:host": "10.1.128.120",
"netconf-node-topology:connection-status": "connecting",
"netconf-node-topology:port": 1830
}
]
}
]
}
}
Below the output from a curl call just like YDK seems to be doing when it's not working (for YDK):
~$ curl http://admin:admin@10.1.20.144:8181/restconf/operational/network-topology:network-topology/ | jq ''
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 64061 0 64061 0 0 45954 0 --:--:-- 0:00:01 --:--:-- 45921
{
"network-topology": {
"topology": [
{
"topology-id": "topology-netconf",
"node": [
{
"node-id": "EDG-01-216.BRU1-IXN",
"netconf-node-topology:unavailable-capabilities": {
"unavailable-capability": [
{
"capability": "(http://cisco.com/ns/cisco-xe-ietf-ospf-deviation?revision=2018-02-09)cisco-xe-ietf-ospf-deviation",
"failure-reason": "unable-to-resolve"
}
]
},
"netconf-node-topology:available-capabilities": {
"available-capability": [
{
"capability-origin": "device-advertised",
"capability": "urn:ietf:params:netconf:capability:notification:1.1"
},
{
"capability-origin": "device-advertised",
"capability": "urn:ietf:params:netconf:capability:with-defaults:1.0?basic-mode=explicit&also-supported=report-all-tagged"
},
{
"capability-origin": "device-advertised",
"capability": "urn:ietf:params:netconf:capability:notification:1.0"
},
{
"capability-origin": "device-advertised",
"capability": "urn:ietf:params:netconf:base:1.0"
},
{
"capability-origin": "device-advertised",
"capability": "urn:ietf:params:netconf:capability:yang-library:1.0?revision=2016-06-21&module-set-id=88c694c75e847aba17e8ab19254ad090"
},
{
"capability-origin": "device-advertised",
"capability": "http://tail-f.com/ns/netconf/actions/1.0"
},
{
"capability-origin": "device-advertised",
"capability": "urn:ietf:params:netconf:capability:validate:1.1"
},
{
"capability-origin": "device-advertised",
"capability": "urn:ietf:params:netconf:capability:validate:1.0"
},
{
"capability-origin": "device-advertised",
"capability": "urn:ietf:params:netconf:base:1.1"
},
{
"capability-origin": "device-advertised",
"capability": "urn:ietf:params:netconf:capability:interleave:1.0"
},
{
"capability-origin": "device-advertised",
"capability": "urn:ietf:params:netconf:capability:rollback-on-error:1.0"
},
{
"capability-origin": "device-advertised",
"capability": "urn:ietf:params:netconf:capability:xpath:1.0"
},
{
"capability-origin": "device-advertised",
"capability": "http://tail-f.com/ns/netconf/extensions"
},
........
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