X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FRO.git;a=blobdiff_plain;f=RO%2Fosm_ro%2Fwim%2Fpersistence.py;h=27a87c45b7bf07c57273ba93ebbb3297028c1f2b;hp=f0f1ac338397583ef6e9a2023f962848779a2809;hb=bf1d0f10e219ae475213b947ce8c76c77c40c452;hpb=7d782eff123e5b44d41437377ccca66ad1e8b21b diff --git a/RO/osm_ro/wim/persistence.py b/RO/osm_ro/wim/persistence.py index f0f1ac33..27a87c45 100644 --- a/RO/osm_ro/wim/persistence.py +++ b/RO/osm_ro/wim/persistence.py @@ -40,11 +40,12 @@ No domain logic/architectural concern should be present in this file. """ import json import logging +import string from contextlib import contextmanager from hashlib import sha1 from itertools import groupby from operator import itemgetter -from sys import exc_info +# from sys import exc_info # from time import time from uuid import uuid1 as generate_uuid @@ -307,6 +308,11 @@ class WimPersistence(object): if "config" in wim_descriptor: wim_descriptor["config"] = _serialize(wim_descriptor["config"]) + url = wim_descriptor["wim_url"] + wim_descriptor["wim_url"] = url.strip(string.whitespace + "/") + # ^ This avoid the common problem caused by trailing spaces/slashes in + # the URL (due to CTRL+C/CTRL+V) + return self.db.new_row( "wims", wim_descriptor, add_uuid=True, confidential_data=True) @@ -362,6 +368,7 @@ class WimPersistence(object): def get_wim_accounts(self, **kwargs): """Retrieve all the accounts from the database""" kwargs.setdefault('postprocess', _postprocess_wim_account) + kwargs.setdefault('WHERE', {"sdn": "false"}) return self.query(FROM=_WIM_ACCOUNT_JOIN, **kwargs) def get_wim_account(self, uuid_or_name, **kwargs): @@ -523,7 +530,7 @@ class WimPersistence(object): self.logger.exception(old_exception) ex = InvalidParameters( "The mapping must contain the " - "'pop_switch_dpid', 'pop_switch_port', and " + "'device_id', 'device_interface_id', and " "wan_service_mapping_info: " "('wan_switch_dpid' and 'wan_switch_port') or " "'wan_service_endpoint_id}'") @@ -727,7 +734,7 @@ class WimPersistence(object): kwargs.setdefault('error_if_none', False) criteria_fields = ('uuid', 'instance_scenario_id', 'sce_net_id', - 'wim_id', 'wim_account_id') + 'wim_id', 'wim_account_id', 'sdn') criteria = remove_none_items(filter_dict_keys(kwargs, criteria_fields)) kwargs = filter_out_dict_keys(kwargs, criteria_fields) @@ -863,10 +870,7 @@ def _preprocess_wim_account(wim_account): """ wim_account = preprocess_record(wim_account) - created = wim_account.get('created') - wim_account['created'] = ( - 'true' if created is True or created == 'true' else 'false') - + wim_account['sdn'] = False return wim_account