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

Multiple bug fixes:

- `common` > `tests` > `InMemoryObjectDatabase.py`: enhance log error reporting
- `common` > `tools` > `descriptor` > `Tools.py`: correct formatting of non-string resource_values in custom config rules in method `format_custom_config_rules()`
- `common` > `tools` > `service` > `GenericRestServer.py`: correct format of reported listen URL
parent 1cdafbad
No related branches found
No related tags found
2 merge requests!235Release TeraFlowSDN 3.0,!181Resolve "(CTTC) Multiple Bug Fixes affecting `common` code"
...@@ -37,7 +37,9 @@ class InMemoryObjectDatabase: ...@@ -37,7 +37,9 @@ class InMemoryObjectDatabase:
LOGGER.debug('[get_entry] BEFORE database={:s}'.format(str(self._database))) LOGGER.debug('[get_entry] BEFORE database={:s}'.format(str(self._database)))
container = self._get_container(container_name) container = self._get_container(container_name)
if entry_uuid not in container: if entry_uuid not in container:
context.abort(grpc.StatusCode.NOT_FOUND, str('{:s}({:s}) not found'.format(container_name, entry_uuid))) MSG = '{:s}({:s}) not found; available({:s})'
msg = str(MSG.format(container_name, entry_uuid, str(container.keys())))
context.abort(grpc.StatusCode.NOT_FOUND, msg)
return container[entry_uuid] return container[entry_uuid]
def set_entry(self, container_name : str, entry_uuid : str, entry : Any) -> Any: def set_entry(self, container_name : str, entry_uuid : str, entry : Any) -> Any:
......
...@@ -57,6 +57,8 @@ def format_custom_config_rules(config_rules : List[Dict]) -> List[Dict]: ...@@ -57,6 +57,8 @@ def format_custom_config_rules(config_rules : List[Dict]) -> List[Dict]:
if isinstance(custom_resource_value, (dict, list)): if isinstance(custom_resource_value, (dict, list)):
custom_resource_value = json.dumps(custom_resource_value, sort_keys=True, indent=0) custom_resource_value = json.dumps(custom_resource_value, sort_keys=True, indent=0)
config_rule['custom']['resource_value'] = custom_resource_value config_rule['custom']['resource_value'] = custom_resource_value
elif not isinstance(custom_resource_value, str):
config_rule['custom']['resource_value'] = str(custom_resource_value)
return config_rules return config_rules
def format_device_custom_config_rules(device : Dict) -> Dict: def format_device_custom_config_rules(device : Dict) -> Dict:
......
...@@ -37,7 +37,8 @@ class GenericRestServer(threading.Thread): ...@@ -37,7 +37,8 @@ class GenericRestServer(threading.Thread):
self.bind_port = bind_port self.bind_port = bind_port
self.base_url = base_url self.base_url = base_url
self.bind_address = get_http_bind_address() if bind_address is None else bind_address self.bind_address = get_http_bind_address() if bind_address is None else bind_address
self.endpoint = 'http://{:s}:{:s}{:s}'.format(str(self.bind_address), str(self.bind_port), str(self.base_url)) self.endpoint = 'http://{:s}:{:s}'.format(str(self.bind_address), str(self.bind_port))
if self.base_url is not None: self.endpoint += str(self.base_url)
self.srv = None self.srv = None
self.ctx = None self.ctx = None
self.app = Flask(__name__) self.app = Flask(__name__)
......
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