06-29-2017 03:45 AM
Hello,
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.)
Thank
Solved! Go to Solution.
06-29-2017 12:43 PM
Yes. I just did a quick example of multiple interfaces added separately. You may call edit_config multiple times with objects from different places in the overall platform data model.
Cheers,
Einar
06-29-2017 04:38 AM
Muffadal,
Are you trying to avoid multiple transactions or do you really mean sessions? The NetconfServiceProvider session you create is already reused across multiple requests.
Cheers,
Einar
06-29-2017 04:42 AM
yeah its actually multiple transactions and not sessions.
06-29-2017 05:39 AM
Mufaddal,
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='1.2.3.4', # TODO insert your IP
port=830,
username='your_user',
password='your_password',
protocol='ssh')
# 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()
cr_intf_configs.interface_configuration.append(cr_lo)
nc.edit_config(
session,
Datastore.candidate,
cr_intf_configs)
# now commit all the changes
nc.commit(session)
Cheers,
Einar
06-29-2017 05:43 AM
Thanks Einar for the prompt response.
Can i add other objects (e.g. ISIS config) before doing the nc.commit(session)
06-29-2017 09:08 AM
Yes. The commit can be performed after editing data from multiple models
06-29-2017 12:43 PM
Yes. I just did a quick example of multiple interfaces added separately. You may call edit_config multiple times with objects from different places in the overall platform data model.
Cheers,
Einar
07-03-2017 03:43 PM
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.
07-03-2017 04:14 PM
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.
Cheers,
Einar
07-03-2017 04:17 PM
Thanks Einar for the help
07-03-2017 12:31 PM
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:
CRUD service should handle multiple objects · Issue #121 · CiscoDevNet/ydk-gen · GitHub
NETCONF service should handle multiple objects · Issue #123 · CiscoDevNet/ydk-gen · GitHub
07-03-2017 03:44 PM
Thanks Santiago, will check out them.
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