Diiferentiate create or update in Python ServiceCallbacks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2019 03:13 PM
Hi experts,
Is there a quick way to differentiate if a ServiceCallbacks is updating the service or creating a service in python?
To be more specific, in pre_modification decorator, there is an op parameter that can differentiate create, update or delete
@Service.pre_modification def cb_pre_modification(self, tctx, op, kp, root, proplist):
Is there a similar thing in the ServiceCallbacks?
class ServiceCallbacks(Service): @Service.create def cb_create(self, tctx, root, service, proplist):
Thanks.
- Labels:
-
Other NSO Topics
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2019 01:29 PM
So, the purpose of the Create callback - and Fastmap - is to write only the create function for the service instance and allow Fastmap to infer the update and delete functionality from that. Placing create/update/delete specific code within the create_cb() is not advised as it may effect Fastmap operation.
The pre/post mod functions are 'outside' of the Fastmap operations, thus the potential need to differentiate create/update/delete functions.
Curious what you are attempting where you need to differentiate in create code.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2019 04:25 PM
My use case is about adding and placing an access-rule to a Check Point device. In the case of creation, the service creates a new access-rule and moves it to the bottom of the section. While in the case of an update, to maintain the order of the access-rules in the section, the service only updates the content of the access-rule and does not move around the access-rule. In other words, ideally, the service code moves the rule while creating the service and doesn't move the rule while updating the service.
