Showing results for 
Search instead for 
Did you mean: 
Cisco Employee

Diiferentiate create or update in Python ServiceCallbacks

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

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

Is there a similar thing in the ServiceCallbacks?


class ServiceCallbacks(Service):
    def cb_create(self, tctx, root, service, proplist):




Cisco Employee

Re: Diiferentiate create or update in Python ServiceCallbacks

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.


Cisco Employee

Re: Diiferentiate create or update in Python ServiceCallbacks

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.