cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
901
Views
15
Helpful
3
Replies

Pyats OSPF feaure objects

aidariys5
Level 1
Level 1

Hello,

What is the proper way to add network to OSPF on router via Feature on Pyats?

from genie.libs.conf.ospf import Ospf

I cannot find method "add_network" but it is specified in Ospf feature model.

 

3 Replies 3

@aidariys5 Get the pyATS Library functionality that you need to create each feature, for example

 

from genie.conf.base import Interface
from genie.libs.conf.ospf import Ospf
from genie.libs.conf.isis import Isis
from genie.libs.conf.rip import Rip

 

https://pubhub.devnetcloud.com/media/pyats-getting-started/docs/quickstart/configuredevices.html

 

Hope this helps.

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

HI, thanks for reply. Let me bring more context. I'm trying to add network to ospf (like: network 1.1.1.0 0.0.0.255 area 0)

 

For example, I can specify instance and area_id:

 

from genie.libs.conf.ospf import Ospf
r1_ospf.instance = '1'
r1_ospf.area_id = '0'

 

But I cannot add network, such options is simply not available but probably I'm missing something.

If check https://pubhub.devnetcloud.com/media/genie-feature-browser/docs/_models/ospf.pdf, then you will find these two options:

area_network

area_network_wildcard

 

CristianP
Cisco Employee
Cisco Employee

Late answer: If your device type is NXOS the model does not support that 
It is supported for IOSXE as you can see here 
https://github.com/CiscoTestAutomation/genielibs/blob/master/pkgs/conf-pkg/src/genie/libs/conf/ospf/iosxe/tests/test_ospf.py#:~:text=an1%20%3D%20AreaNetwork,(an2)
Try these

    from genie.conf import Genie
    from genie.conf.base import Testbed, Device
    testbed = Testbed()
    Genie.testbed = testbed
    dev1 = Device(name='PE1', testbed=testbed, os='iosxe')
    vrf = Vrf('VRF1')
    dev1.add_feature(vrf)
    
 
    ospf1 = Ospf()
    dev1=device
    ospf1.device_attr[dev1].enabled = True
    ospf1.device_attr[dev1].vrf_attr[vrf0].instance = '30'
    ospf1.device_attr[dev1].vrf_attr[vrf0].enable = True
    ospf1.device_attr[dev1].vrf_attr[vrf0].router_id = '3.3.3.3'
    an2 = AreaNetwork(device=dev1)
    an2.area_network = '192.168.1.1'
    an2.area_network_wildcard = '0.0.0.255'
    ospf1.device_attr[device].vrf_attr[vrf].area_attr['0.0.0.1'].add_areanetwork_key(an2)
    device.add_feature(ospf1)
    print(device.build_config(apply=False))
The above will work
If you change 
dev1 = Device(name='PE1', testbed=testbed, os='iosxe')
to 
dev1 = Device(name='PE1', testbed=testbed, os='nxos')
The resulting config won't show the network statement which you could use to activate OSPF on multiple interfaces in one shot> This does not work on NXOS

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: