Skip to content
Snippets Groups Projects
Commit ff543f54 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Device component:

- Updated default OpenConfig unitary test template config
- Added minor code improvements in OpenConfig Driver
parent f5199c4c
No related branches found
No related tags found
1 merge request!54Release 2.0.0
...@@ -63,9 +63,9 @@ class NetconfSessionHandler: ...@@ -63,9 +63,9 @@ class NetconfSessionHandler:
self.__username = settings.get('username') self.__username = settings.get('username')
self.__password = settings.get('password') self.__password = settings.get('password')
self.__key_filename = settings.get('key_filename') self.__key_filename = settings.get('key_filename')
self.__hostkey_verify = settings.get('hostkey_verify') self.__hostkey_verify = settings.get('hostkey_verify', True)
self.__look_for_keys = settings.get('look_for_keys') self.__look_for_keys = settings.get('look_for_keys', True)
self.__allow_agent = settings.get('allow_agent') self.__allow_agent = settings.get('allow_agent', True)
self.__force_running = settings.get('force_running', False) self.__force_running = settings.get('force_running', False)
self.__device_params = settings.get('device_params') self.__device_params = settings.get('device_params')
self.__manager_params = settings.get('manager_params') self.__manager_params = settings.get('manager_params')
...@@ -183,8 +183,9 @@ def do_sampling(samples_cache : SamplesCache, resource_key : str, out_samples : ...@@ -183,8 +183,9 @@ def do_sampling(samples_cache : SamplesCache, resource_key : str, out_samples :
def edit_config( def edit_config(
netconf_handler : NetconfSessionHandler, resources : List[Tuple[str, Any]], delete=False, target='running', netconf_handler : NetconfSessionHandler, resources : List[Tuple[str, Any]], delete=False, target='running',
default_operation='merge', test_option=None, error_option=None, format='xml' # pylint: disable=redefined-builtin default_operation=None, test_option=None, error_option=None, format='xml' # pylint: disable=redefined-builtin
): ):
if default_operation is None: default_operation = 'delete' if delete else 'merge'
str_method = 'DeleteConfig' if delete else 'SetConfig' str_method = 'DeleteConfig' if delete else 'SetConfig'
LOGGER.info('[{:s}] resources = {:s}'.format(str_method, str(resources))) LOGGER.info('[{:s}] resources = {:s}'.format(str_method, str(resources)))
results = [None for _ in resources] results = [None for _ in resources]
...@@ -296,14 +297,14 @@ class OpenConfigDriver(_Driver): ...@@ -296,14 +297,14 @@ class OpenConfigDriver(_Driver):
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( results = edit_config(
self.__netconf_handler, resources, target='candidate', delete=True, default_operation='delete') self.__netconf_handler, resources, target='candidate', delete=True)
try: try:
self.__netconf_handler.commit() self.__netconf_handler.commit()
except Exception as e: # pylint: disable=broad-except except Exception as e: # pylint: disable=broad-except
LOGGER.exception('[DeleteConfig] Exception commiting resources: {:s}'.format(str(resources))) LOGGER.exception('[DeleteConfig] Exception commiting resources: {:s}'.format(str(resources)))
results = [e for _ in resources] # if commit fails, set exception in each resource results = [e for _ in resources] # if commit fails, set exception in each resource
else: else:
results = edit_config(self.__netconf_handler, resources, delete=True, default_operation='delete') results = edit_config(self.__netconf_handler, resources, delete=True)
return results return results
def SubscribeState(self, subscriptions : List[Tuple[str, float, float]]) -> List[Union[bool, Exception]]: def SubscribeState(self, subscriptions : List[Tuple[str, float, float]]) -> List[Union[bool, Exception]]:
......
...@@ -20,15 +20,20 @@ DEVICE_OC_ADDRESS = '127.0.0.1' # populate the Netconf Server IP address of th ...@@ -20,15 +20,20 @@ DEVICE_OC_ADDRESS = '127.0.0.1' # populate the Netconf Server IP address of th
DEVICE_OC_PORT = 830 # populate the Netconf Server port of the device to test DEVICE_OC_PORT = 830 # populate the Netconf Server port of the device to test
DEVICE_OC_USERNAME = 'username' # populate the Netconf Server username of the device to test DEVICE_OC_USERNAME = 'username' # populate the Netconf Server username of the device to test
DEVICE_OC_PASSWORD = 'password' # populate the Netconf Server password of the device to test DEVICE_OC_PASSWORD = 'password' # populate the Netconf Server password of the device to test
DEVICE_OC_TIMEOUT = 120 DEVICE_OC_TIMEOUT = 15
DEVICE_OC_ID = json_device_id(DEVICE_OC_UUID) DEVICE_OC_ID = json_device_id(DEVICE_OC_UUID)
DEVICE_OC = json_device_packetrouter_disabled(DEVICE_OC_UUID) DEVICE_OC = json_device_packetrouter_disabled(DEVICE_OC_UUID)
DEVICE_OC_CONNECT_RULES = json_device_connect_rules(DEVICE_OC_ADDRESS, DEVICE_OC_PORT, { DEVICE_OC_CONNECT_RULES = json_device_connect_rules(DEVICE_OC_ADDRESS, DEVICE_OC_PORT, {
'username': DEVICE_OC_USERNAME, 'username' : DEVICE_OC_USERNAME,
'password': DEVICE_OC_PASSWORD, 'password' : DEVICE_OC_PASSWORD,
'timeout' : DEVICE_OC_TIMEOUT, 'force_running' : True,
'hostkey_verify' : True,
'look_for_keys' : True,
'allow_agent' : True,
'device_params' : {'name': 'default'},
'manager_params' : {'timeout' : DEVICE_OC_TIMEOUT},
}) })
DEVICE_OC_CONFIG_RULES = [] # populate your configuration rules to test DEVICE_OC_CONFIG_RULES = [] # populate your configuration rules to test
......
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