I would like to know if there is any possibility to send multiple entities (objects) in a single netconf create requests. It may be not possible directly with CRUD but any we could do this with the netconf service method.
The idea is to not create multiple sessions with the router for sending different objects (e.g. BGP, ISIS etc.)
Solved! Go to Solution.
Are you trying to avoid multiple transactions or do you really mean sessions? The NetconfServiceProvider session you create is already reused across multiple requests.
I suggest you try something like:
from ydk.services import NetconfService
from ydk.services import Datastore
from ydk.providers import NetconfServiceProvider
from ydk.models.cisco_ios_xr import Cisco_IOS_XR_ifmgr_cfg as ifmgr_cfg
# still need the service provider
session = NetconfServiceProvider(
address='220.127.116.11', # TODO insert your IP
# Initialize a NetconfService, rather than a CRUDService
nc = NetconfService()
# try creating a number of loopbacks in multiple edit-config operations
for index in xrange(100, 105):
cr_lo = ifmgr_cfg.InterfaceConfigurations.InterfaceConfiguration()
cr_lo.interface_virtual = Empty()
cr_lo.interface_name = 'Loopback%d' % index
cr_lo.description = 'Created Lo%d' % index
cr_lo.active = 'act'
cr_intf_configs = ifmgr_cfg.InterfaceConfigurations()
# now commit all the changes
Thank you Einar and Abhirame, I will try this week.
I am just probably thinking out loud so I may not be phrasing it correctly, how does NetconfService handle transactions across multiple devices so that if a commit for a single device fails, it does not commit for the rest of the devices.
I am guessing this is something to do on top of ydk-py (possibly via return code) and not inside ydk-py.
Correct, the YDK-Py doesn't coordinate transactions across devices. That is outside its current scope. If all the devices you are coordinating across support confirmed-commit, it is fairly simple to do a 2-phase-like sequence.
Note that the example above has multiple operations (RPCs) in a single transaction using NetconfService. With the CRUDService, each create operation is a transaction. If you're interested in sending data for multiple models in a single operation, take a look at these issue and give them a +1: