<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Perform sync-from before python based service instantiation in NSO Developer Hub Discussions</title>
    <link>https://community.cisco.com/t5/nso-developer-hub-discussions/perform-sync-from-before-python-based-service-instantiation/m-p/3467829#M655</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&lt;a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/9199"&gt;@service&lt;/a&gt;.pre_modification&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #000000; font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; def cb_pre_modification(self, tctx, op, kp, root, proplist):&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #000000; font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.log.info('Service premod(service=', kp, ')')&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #000000; font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.log.info('Checking device {} is in sync'.format('svlngen4-fab6-dmzdc-02-fw1'))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #000000; font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; with ncs.maapi.single_write_trans('admin', 'python') as trans:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #000000; font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; root = ncs.maagic.get_root(trans)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #000000; font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; device = root.devices.device['svlngen4-fab6-dmzdc-02-fw1']&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #000000; font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # check_sync_output = device.check_sync.request()&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #000000; font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sync_output = device.sync_from.request()&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.log.info('Device has now been sync\'d: {}'.format(sync_output.result))&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #000000; font-family: 'courier new', courier;"&gt;2017-09-28 07:28:19 - fw_acl_03 - INFO - Checking device svlngen4-fab6-dmzdc-02-fw1 is in sync&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #000000; font-family: 'courier new', courier;"&gt;2017-09-28 07:30:21 - fw_acl_03 - INFO - Device has now been sync'd: True&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: Arial, Tahoma, Helvetica, clean, sans-serif; font-size: 13px; background-color: #f9f9f9;"&gt;no registration found for callpoint fw_acl_03-servicepoint/service_create of type=external&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: Arial, Tahoma, Helvetica, clean, sans-serif; font-size: 13px; background-color: #f9f9f9;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: Arial, Tahoma, Helvetica, clean, sans-serif; font-size: 13px; background-color: #f9f9f9;"&gt;I have to reload the packages to clear this error.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: Arial, Tahoma, Helvetica, clean, sans-serif; font-size: 13px; background-color: #f9f9f9;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: Arial, Tahoma, Helvetica, clean, sans-serif; font-size: 13px; background-color: #f9f9f9;"&gt;Is this the right approach to performing a sync-from before committing config changes to a device? &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 01 Mar 2019 12:00:24 GMT</pubDate>
    <dc:creator>Ben Kelly</dc:creator>
    <dc:date>2019-03-01T12:00:24Z</dc:date>
    <item>
      <title>Perform sync-from before python based service instantiation</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/perform-sync-from-before-python-based-service-instantiation/m-p/3467829#M655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&lt;a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/9199"&gt;@service&lt;/a&gt;.pre_modification&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #000000; font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; def cb_pre_modification(self, tctx, op, kp, root, proplist):&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #000000; font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.log.info('Service premod(service=', kp, ')')&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #000000; font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.log.info('Checking device {} is in sync'.format('svlngen4-fab6-dmzdc-02-fw1'))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #000000; font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; with ncs.maapi.single_write_trans('admin', 'python') as trans:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #000000; font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; root = ncs.maagic.get_root(trans)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #000000; font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; device = root.devices.device['svlngen4-fab6-dmzdc-02-fw1']&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #000000; font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # check_sync_output = device.check_sync.request()&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #000000; font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sync_output = device.sync_from.request()&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.log.info('Device has now been sync\'d: {}'.format(sync_output.result))&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #000000; font-family: 'courier new', courier;"&gt;2017-09-28 07:28:19 - fw_acl_03 - INFO - Checking device svlngen4-fab6-dmzdc-02-fw1 is in sync&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #000000; font-family: 'courier new', courier;"&gt;2017-09-28 07:30:21 - fw_acl_03 - INFO - Device has now been sync'd: True&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: Arial, Tahoma, Helvetica, clean, sans-serif; font-size: 13px; background-color: #f9f9f9;"&gt;no registration found for callpoint fw_acl_03-servicepoint/service_create of type=external&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: Arial, Tahoma, Helvetica, clean, sans-serif; font-size: 13px; background-color: #f9f9f9;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: Arial, Tahoma, Helvetica, clean, sans-serif; font-size: 13px; background-color: #f9f9f9;"&gt;I have to reload the packages to clear this error.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: Arial, Tahoma, Helvetica, clean, sans-serif; font-size: 13px; background-color: #f9f9f9;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: Arial, Tahoma, Helvetica, clean, sans-serif; font-size: 13px; background-color: #f9f9f9;"&gt;Is this the right approach to performing a sync-from before committing config changes to a device? &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Mar 2019 12:00:24 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/perform-sync-from-before-python-based-service-instantiation/m-p/3467829#M655</guid>
      <dc:creator>Ben Kelly</dc:creator>
      <dc:date>2019-03-01T12:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: Perform sync-from before python based service instantiation</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/perform-sync-from-before-python-based-service-instantiation/m-p/3467830#M656</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi There,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above is due to a classic deadlock situation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In short, we cannot do updates to CDB (sync-from) while a transaction is in progress.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have been in a similar situation before and had to find an alternative way to think about the problem..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why is the sync-from needed while we are withing the service update?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Sep 2017 10:01:36 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/perform-sync-from-before-python-based-service-instantiation/m-p/3467830#M656</guid>
      <dc:creator>alam.bilal</dc:creator>
      <dc:date>2017-09-28T10:01:36Z</dc:date>
    </item>
    <item>
      <title>Re: Perform sync-from before python based service instantiation</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/perform-sync-from-before-python-based-service-instantiation/m-p/3467831#M657</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The device that I'm pushing the configuration to is only partially managed by NSO. There are other automated systems as well as manual configuration adjustments going on. The service I'm working on makes adjustments to a shared ACL and at very specific line numbers. It's very likely that the ACL has been manually changed since the last time NSO committed a change and therefore the line numbers on the device won't match what's in the CDB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the idea is that before making any changes, NSO should first get an updated config from the device.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Sep 2017 11:23:25 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/perform-sync-from-before-python-based-service-instantiation/m-p/3467831#M657</guid>
      <dc:creator>Ben Kelly</dc:creator>
      <dc:date>2017-09-28T11:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: Perform sync-from before python based service instantiation</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/perform-sync-from-before-python-based-service-instantiation/m-p/3467832#M658</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have worked on a use-case with slightly similar requirements. However there was clear demarcation of the configuration space touched between NSO and other orchestrator/manual-operator. Plus from a process perspective, particular naming conventions were to be used to avoid cross scribbling.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some suggestions on the options to consider:&lt;/P&gt;&lt;P&gt;1. From the NB-System, first do a sync-from on the device[s] of interest. Then perform the service CRUD.&lt;/P&gt;&lt;P&gt;2. If don't want an extra API call from the NB System to do sync-from then within the service instance's CRUD, in the pre-mod callback a service "deep-check-sync" can be done to detect any scribbling. If scribbling detected then terminate the transaction and return delta-diffs.There will be performance implication associated with reading the device[s] configs.&lt;/P&gt;&lt;P&gt;3. To avoid performance penalty of (2), w&lt;SPAN style="font-size: 13.3333px;"&gt;ithin the service-CRUD, in the pre-mod ensure all devices of interest are in-sync then perform service check-sync against the CDB.&amp;nbsp; Reject request if a device is out-of-sync or service not in sync. The NB-System will have to re-attempt&lt;/SPAN&gt; the service-CRUD request. Also an optimisation is to have kicker watching the service instance node and performs sync-from post the service-CRUD. So the next attempt by NB-System can proceed.&lt;/P&gt;&lt;P&gt;4. Craft and action that first does the sync-from and them performs the service-CRUD. Downside, a lot of action wrapper code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Oct 2017 07:06:08 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/perform-sync-from-before-python-based-service-instantiation/m-p/3467832#M658</guid>
      <dc:creator>alam.bilal</dc:creator>
      <dc:date>2017-10-03T07:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: Perform sync-from before python based service instantiation</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/perform-sync-from-before-python-based-service-instantiation/m-p/4403593#M6323</link>
      <description>&lt;P&gt;easy and straightforward&lt;/P&gt;</description>
      <pubDate>Sat, 15 May 2021 20:33:53 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/perform-sync-from-before-python-based-service-instantiation/m-p/4403593#M6323</guid>
      <dc:creator>randreetta</dc:creator>
      <dc:date>2021-05-15T20:33:53Z</dc:date>
    </item>
  </channel>
</rss>

