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:
def use_candidate(self): return self.__candidate_supported and not self.__force_running
@property
def commit_per_delete_rule(self): return self.__commit_per_delete
def commit_per_rule(self): return self.__commit_per_delete
@RETRY_DECORATOR
def get(self, filter=None, with_defaults=None): # pylint: disable=redefined-builtin
......@@ -284,12 +284,15 @@ class OpenConfigDriver(_Driver):
with self.__lock:
if self.__netconf_handler.use_candidate:
with self.__netconf_handler.locked(target='candidate'):
results = edit_config(self.__netconf_handler, resources, target='candidate')
try:
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
if self.__netconf_handler.commit_per_rule:
results = edit_config(self.__netconf_handler, resources, target='candidate', commit_per_rule= True)
else:
results = edit_config(self.__netconf_handler, resources, target='candidate')
try:
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:
results = edit_config(self.__netconf_handler, resources)
return results
......@@ -300,7 +303,7 @@ class OpenConfigDriver(_Driver):
with self.__lock:
if self.__netconf_handler.use_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)
else:
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