cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1850
Views
0
Helpful
4
Replies

Perform sync-from before python based service instantiation

Ben Kelly
Cisco Employee
Cisco Employee

I'm trying to perform a sync from on a device before the instantiation of a python based service. I'm using the cb_pre_modification to do it with this code:

@service.pre_modification

    def cb_pre_modification(self, tctx, op, kp, root, proplist):

        self.log.info('Service premod(service=', kp, ')')

        self.log.info('Checking device {} is in sync'.format('svlngen4-fab6-dmzdc-02-fw1'))

        with ncs.maapi.single_write_trans('admin', 'python') as trans:

            root = ncs.maagic.get_root(trans)

            device = root.devices.device['svlngen4-fab6-dmzdc-02-fw1']

            # check_sync_output = device.check_sync.request()

            sync_output = device.sync_from.request()

            self.log.info('Device has now been sync\'d: {}'.format(sync_output.result))

However, the config never gets pushed to the device. I believe that we're getting some sort of timeout, as there's 2 minutes from the time the sync-from is started until it ends:

2017-09-28 07:28:19 - fw_acl_03 - INFO - Checking device svlngen4-fab6-dmzdc-02-fw1 is in sync

2017-09-28 07:30:21 - fw_acl_03 - INFO - Device has now been sync'd: True

In the meantime the transaction times out and not configuration is pushed. The next time I try to commit something on that service, I get:

no registration found for callpoint fw_acl_03-servicepoint/service_create of type=external


I have to reload the packages to clear this error.


Is this the right approach to performing a sync-from before committing config changes to a device?

1 Accepted Solution

Accepted Solutions

alam.bilal
Cisco Employee
Cisco Employee

Hi There,

The above is due to a classic deadlock situation.

When a transaction is started, various locks are taken. At some stage the preMod callback runs. It tries to do a sync-from which in turn tries to grab the same locks.

In short, we cannot do updates to CDB (sync-from) while a transaction is in progress.

I have been in a similar situation before and had to find an alternative way to think about the problem..

Why is the sync-from needed while we are withing the service update?

A messy way (which I would not recommend) is to write action wrappers. The wrapper will first do a sync-from and then invoke the service CRUD.

Thanks.

View solution in original post