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?