Skip to content
Snippets Groups Projects
Commit c9f05d80 authored by PabloArmingolRobles's avatar PabloArmingolRobles
Browse files

Commit per rulle in SetConfig

parent 09881403
No related branches found
No related tags found
2 merge requests!54Release 2.0.0,!4Compute component:
...@@ -92,7 +92,7 @@ class NetconfSessionHandler: ...@@ -92,7 +92,7 @@ class NetconfSessionHandler:
def use_candidate(self): return self.__candidate_supported and not self.__force_running def use_candidate(self): return self.__candidate_supported and not self.__force_running
@property @property
def commit_per_delete_rule(self): return self.__commit_per_delete def commit_per_rule(self): return self.__commit_per_delete
@RETRY_DECORATOR @RETRY_DECORATOR
def get(self, filter=None, with_defaults=None): # pylint: disable=redefined-builtin def get(self, filter=None, with_defaults=None): # pylint: disable=redefined-builtin
...@@ -284,12 +284,15 @@ class OpenConfigDriver(_Driver): ...@@ -284,12 +284,15 @@ class OpenConfigDriver(_Driver):
with self.__lock: with self.__lock:
if self.__netconf_handler.use_candidate: if self.__netconf_handler.use_candidate:
with self.__netconf_handler.locked(target='candidate'): with self.__netconf_handler.locked(target='candidate'):
results = edit_config(self.__netconf_handler, resources, target='candidate') if self.__netconf_handler.commit_per_rule:
try: results = edit_config(self.__netconf_handler, resources, target='candidate', commit_per_rule= True)
self.__netconf_handler.commit() else:
except Exception as e: # pylint: disable=broad-except results = edit_config(self.__netconf_handler, resources, target='candidate')
LOGGER.exception('[SetConfig] Exception commiting resources: {:s}'.format(str(resources))) try:
results = [e for _ in resources] # if commit fails, set exception in each resource self.__netconf_handler.commit()
except Exception as e: # pylint: disable=broad-except
LOGGER.exception('[SetConfig] Exception commiting resources: {:s}'.format(str(resources)))
results = [e for _ in resources] # if commit fails, set exception in each resource
else: else:
results = edit_config(self.__netconf_handler, resources) results = edit_config(self.__netconf_handler, resources)
return results return results
...@@ -300,7 +303,7 @@ class OpenConfigDriver(_Driver): ...@@ -300,7 +303,7 @@ class OpenConfigDriver(_Driver):
with self.__lock: with self.__lock:
if self.__netconf_handler.use_candidate: if self.__netconf_handler.use_candidate:
with self.__netconf_handler.locked(target='candidate'): with self.__netconf_handler.locked(target='candidate'):
if self.__netconf_handler.commit_per_delete_rule: if self.__netconf_handler.commit_per_rule:
results = edit_config(self.__netconf_handler, resources, target='candidate', delete=True, commit_per_rule= True) results = edit_config(self.__netconf_handler, resources, target='candidate', delete=True, commit_per_rule= True)
else: else:
results = edit_config(self.__netconf_handler, resources, target='candidate', delete=True) results = edit_config(self.__netconf_handler, resources, target='candidate', delete=True)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment