cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2151
Views
20
Helpful
4
Replies

How to check if it is a dry-run in python for a service

For the service that I am writing, I have some python code that I would like to run on a commit, but not a dry-run. I know that in the pre/post modification it gives me the parameter 'op', which will tell me if it is a CREATE/UPDATE/DELETE happening to the service, but it does not inform me if it is a dry-run. Is this possible?

1 Accepted Solution

Accepted Solutions

frjansso
Cisco Employee
Cisco Employee
Unfortunately not, the service doesn't know.

View solution in original post

4 Replies 4

frjansso
Cisco Employee
Cisco Employee
Unfortunately not, the service doesn't know.

Nabsch
Spotlight
Spotlight

Hello,

 

In NSO 5.5 and later , you can check if it's a dry-run in your python service .

 

trans= ncs.maagic.get_trans(root)
params = trans.get_params()
params.is_dry_run()

The function get_params is returning a CommitParams object . Here  Link to the the class  . You can access to other commit parameter as well  (no-deploy , no-networking , Get dry-run outformat type ) .

 

def get_commit_queue_error_option(self)
Get commit queue item behaviour on error.

def get_commit_queue_sync_timeout(self)
Get commit queue synchronous mode of operation timeout.

def get_commit_queue_tag(self)
Get commit-queue tag.

def get_dry_run_outformat(self)
Get dry-run outformat

def get_trace_id(self)
Get trace id.

def get_wait_devices(self)
Get the devices that the transaction should wait for a device lock for before entering the transactions critical section.

def is_commit_queue_async(self)
Get commit queue asynchronous mode of operation.

def is_commit_queue_atomic(self)
Check if the commit queue item should be atomic.

def is_commit_queue_block_others(self)
Check if the the commit queue item should block other commit queue items for this device.

def is_commit_queue_bypass(self)
Check if the commit is transactional even if commit queue is configured by default.

def is_commit_queue_lock(self)
Check if the commit queue item should be locked.

def is_commit_queue_non_atomic(self)
Check if the commit queue item should be non-atomic.

def is_commit_queue_sync(self)
Get commit queue synchronous mode of operation.

def is_dry_run(self)
Is dry-run enabled

def is_dry_run_reverse(self)
Is dry-run reverse enabled.

def is_no_deploy(self)
Should service create method be invoked or not.

def is_no_lsa(self)
Get no-lsa commit parameter.

def is_no_networking(self)
Check if the the configuration should only be written to CDB and not actually pushed to the device.

def is_no_out_of_sync_check(self)
Do not check device sync state before pushing the configuration change.

def is_no_overwrite(self)
Should a check be done that the parts of the device configuration to be modified are are up-to-date in CDB before pushing the configuration change to the device.

def is_no_revision_drop(self)
Get no-revision-drop commit parameter.

def is_reconcile_discard_non_service_config(self)
Get reconcile commit parameter with discard-non-service-config behaviour.

def is_reconcile_keep_non_service_config(self)
Get reconcile commit parameter with keep-non-service-config behaviour.

def is_use_lsa(self)
Get use-lsa commit parameter.

Concerning the function get_params ,  here a link to get_params documentation 

Thanks Nabsch, it is very helpful!

 

Just tested it against 5.4.4.1 too.

 

Regards,

Dragan