Trying to read configuration of the static routes (something that have been doing with ncclient). The code is simple:
log = logging.getLogger('ydk')
log.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
log.addHandler(ch)
provider = NetconfServiceProvider(address=HOST, port=PORT, username=USER, password=PASS, protocol=PROTO)
crud = CRUDService()
router_static = Cisco_IOS_XR_ip_static_cfg.RouterStatic()
crud.read(provider,router_static)
print ("Printing static routes:\n")
for vrf_prefix in router_static.default_vrf.address_family.vrfipv4.vrf_unicast.vrf_prefixes.vrf_prefix:
print(vrf_prefix.prefix + "/" + vrf_prefix.prefix_length)
print ("Done.\n")
However, nothing happens although log shows that config has been read from the router:
<Log section is removed>
Can the problem be the fact I'm not using lxml 3.4.4 but 3.7.2.
Try
~/ > pip list|grep lxml
lxml (3.7.3)
Try the below script.
from ydk.models.cisco_ios_xr import Cisco_IOS_XR_ip_static_cfg
import logging
log = logging.getLogger('ydk')
log.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
log.addHandler(ch)
from ydk.providers import NetconfServiceProvider
from ydk.services import CRUDService
crud = CRUDService()
ncc = NetconfServiceProvider(address='localhost' , username='vagrant', password='vagrant', port=830)
router_static = crud.read(ncc,Cisco_IOS_XR_ip_static_cfg.RouterStatic())
for pref in router_static.default_vrf.address_family.vrfipv4.vrf_unicast.vrf_prefixes.vrf_prefix:
print ( '{}/{}'.format(pref.prefix, pref.prefix_length))
you can easily it reproduce it in the dCloud lab:
dcloud is still running 0.5.3, can you run an instance, upgrade to 0.5.4 and try to reproduce. You can upgrade using:
$ sudo pip install ydk-models-cisco-ios-xr --upgrade
password is the same as username.
Comments
0 comments
Please sign in to leave a comment.