cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
225
Views
0
Helpful
5
Replies
Highlighted

One issue for ydk.models.cisco_ios_xe native OSPF

Hello,

Could you please have a look below issue ?

 

No matter I use Router.Ospf or router.Opsf or Router.ospf or router.ospf. It always has issue.

May I know how I could get router.ospf object ?
Thanks a lot!

 

from ydk.models.cisco_ios_xe import Cisco_IOS_XE_native as xe_native

 

def config_native(native):

    ospf = native.Router.Ospf()
    ospf.id = 172
    ospf.router_id = "172.16.255.1"

    ospf.passive_interface.interface = "Loopback0"

 

native = xe_native.Native()

config_native(native)

 

AttributeError: type object 'Router' has no attribute 'Ospf'
jzhang@YDK64:~/Documents/YDK-PY-Samples/ydk-py-samples$

 

 

 

 

def config_native(native):
"""Add config data to native object."""
# OSPF process
ospf = native.router.ospf()
ospf.id = 172
ospf.router_id = "172.16.255.1"

 

AttributeError: type object 'Router' has no attribute 'ospf'

Jacky Zhang
Global Telecom
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Participant

Hi Jacky

Unfortunately your script erroneously uses model API - container 'router' includes list 'ospf'. You should have something like this:

def config_native(native):
    ospf = xe_native.Native.Router.Ospf()
    ospf.id = 172
    ospf.router_id = "172.16.255.1"
    ospf.passive_interface.interface = "Loopback0"
native.router.ospf.append(ospf) # missed this line to add 'ospf' to the list

 

Yan Gorelik
YDK Solutions

View solution in original post

5 REPLIES 5
Highlighted
Participant

Hi Jacky

Unfortunately your script erroneously uses model API - container 'router' includes list 'ospf'. You should have something like this:

def config_native(native):
    ospf = xe_native.Native.Router.Ospf()
    ospf.id = 172
    ospf.router_id = "172.16.255.1"
    ospf.passive_interface.interface = "Loopback0"
native.router.ospf.append(ospf) # missed this line to add 'ospf' to the list

 

Yan Gorelik
YDK Solutions

View solution in original post

Highlighted

Hello Yan,

I hope you are doing well.

I am sorry to test and reply to you a bit later. Because I am busy with my personal things.

 

It still indicates error message "AttributeError: type object 'Router' has no attribute 'Ospf'"

Could you please have a look below coding and error message ?

Thanks a lot

 

 

from ydk.models.cisco_ios_xe import Cisco_IOS_XE_native as xe_native

 


def config_native(native):
ospf = native.Router.Ospf()
ospf.id = 172
ospf.router.id = "172.16.255.1"
ospf.passive_interface.interface = "Loopback0"
native.router.ospf.append(ospf)

if __name__ == "__main__":

# create codec provider
provider = CodecServiceProvider(type="xml")

codec = CodecService()

native = xe_native.Native()

config_native(native)
print(codec.encode(provider, native))

 


-native-router-ospf-20-ydk.py
Traceback (most recent call last):
File "/home/jzhang/Documents/YDK-PY-Samples/ydk-py-samples/projects/my_coding/IOS-XE/cd-encode-xe-native-router-ospf-20-ydk.py", line 45, in <module>
config_native(native)
File "/home/jzhang/Documents/YDK-PY-Samples/ydk-py-samples/projects/my_coding/IOS-XE/cd-encode-xe-native-router-ospf-20-ydk.py", line 24, in config_native
ospf = native.Router.Ospf()
AttributeError: type object 'Router' has no attribute 'Ospf'
jzhang@YDK64:~/Documents/YDK-PY-Samples/ydk-py-samples$

Jacky Zhang
Global Telecom
Highlighted

Sorry, my bad! It should be:

def config_native(native):
    ospf = xe_native.Native.Router.Ospf()
    ospf.id = 172
    ospf.router_id = "172.16.255.1"
    ospf.passive_interface.interface = "Loopback0"
native.router.ospf.append(ospf) # missed this line to add 'ospf' to the list
Yan Gorelik
YDK Solutions
Highlighted

Hi Yan,

 

Thank you for your help.

 

I did testing but it still show AttributeError: type object .   I will paste coding and result later.

 

Do you think there is a bug for YDK OSPF ?  

Jacky Zhang
Global Telecom
Highlighted

Hello Yan.

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