projects
/
osm
/
RO.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix bug 1537 to send dummy message to all kafka topics during startup
[osm/RO.git]
/
RO
/
osm_ro
/
wim
/
persistence.py
diff --git
a/RO/osm_ro/wim/persistence.py
b/RO/osm_ro/wim/persistence.py
index
32a46b3
..
6fbaf8f
100644
(file)
--- a/
RO/osm_ro/wim/persistence.py
+++ b/
RO/osm_ro/wim/persistence.py
@@
-40,6
+40,7
@@
No domain logic/architectural concern should be present in this file.
"""
import json
import logging
"""
import json
import logging
+import string
from contextlib import contextmanager
from hashlib import sha1
from itertools import groupby
from contextlib import contextmanager
from hashlib import sha1
from itertools import groupby
@@
-128,16
+129,16
@@
_PORT_MAPPING_SELECT = ('wim_port_mapping.*', )
_CONFIDENTIAL_FIELDS = ('password', 'passwd')
_SERIALIZED_FIELDS = ('config', 'vim_info', 'wim_info', 'conn_info', 'extra',
_CONFIDENTIAL_FIELDS = ('password', 'passwd')
_SERIALIZED_FIELDS = ('config', 'vim_info', 'wim_info', 'conn_info', 'extra',
- '
wan_
service_mapping_info')
+ 'service_mapping_info')
UNIQUE_PORT_MAPPING_INFO_FIELDS = {
UNIQUE_PORT_MAPPING_INFO_FIELDS = {
- 'dpid-port': ('
wan_switch_dpid', 'wan_
switch_port')
+ 'dpid-port': ('
switch_dpid', '
switch_port')
}
"""Fields that should be unique for each port mapping that relies on
}
"""Fields that should be unique for each port mapping that relies on
-
wan_
service_mapping_info.
+service_mapping_info.
For example, for port mappings of type 'dpid-port', each combination of
For example, for port mappings of type 'dpid-port', each combination of
-
wan_switch_dpid and wan_
switch_port should be unique (the same switch cannot
+
switch_dpid and
switch_port should be unique (the same switch cannot
be connected to two different places using the same port)
"""
be connected to two different places using the same port)
"""
@@
-307,6
+308,11
@@
class WimPersistence(object):
if "config" in wim_descriptor:
wim_descriptor["config"] = _serialize(wim_descriptor["config"])
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)
return self.db.new_row(
"wims", wim_descriptor, add_uuid=True, confidential_data=True)
@@
-508,14
+514,14
@@
class WimPersistence(object):
return self.get_datacenters_by(datacenter, tenant, **kwargs)[0]
def _create_single_port_mapping(self, properties):
return self.get_datacenters_by(datacenter, tenant, **kwargs)[0]
def _create_single_port_mapping(self, properties):
- info = properties.setdefault('
wan_
service_mapping_info', {})
- endpoint_id = properties.get('
wan_
service_endpoint_id')
+ info = properties.setdefault('service_mapping_info', {})
+ endpoint_id = properties.get('service_endpoint_id')
if info.get('mapping_type') and not endpoint_id:
if info.get('mapping_type') and not endpoint_id:
- properties['
wan_
service_endpoint_id'] = (
+ properties['service_endpoint_id'] = (
self._generate_port_mapping_id(info))
self._generate_port_mapping_id(info))
- properties['
wan_
service_mapping_info'] = _serialize(info)
+ properties['service_mapping_info'] = _serialize(info)
try:
self.db.new_row('wim_port_mappings', properties,
try:
self.db.new_row('wim_port_mappings', properties,
@@
-525,9
+531,9
@@
class WimPersistence(object):
ex = InvalidParameters(
"The mapping must contain the "
"'device_id', 'device_interface_id', and "
ex = InvalidParameters(
"The mapping must contain the "
"'device_id', 'device_interface_id', and "
- "
wan_
service_mapping_info: "
- "('
wan_switch_dpid' and 'wan_
switch_port') or "
- "'
wan_
service_endpoint_id}'")
+ "service_mapping_info: "
+ "('
switch_dpid' and '
switch_port') or "
+ "'service_endpoint_id}'")
raise ex from old_exception
return properties
raise ex from old_exception
return properties
@@
-628,12
+634,12
@@
class WimPersistence(object):
original = self.query_one('wim_port_mappings', WHERE={'id': id})
mapping_info = remove_none_items(merge_dicts(
original = self.query_one('wim_port_mappings', WHERE={'id': id})
mapping_info = remove_none_items(merge_dicts(
- original.get('
wan_
service_mapping_info') or {},
- properties.get('
wan_
service_mapping_info') or {}))
+ original.get('service_mapping_info') or {},
+ properties.get('service_mapping_info') or {}))
updates = preprocess_record(
merge_dicts(original, remove_none_items(properties),
updates = preprocess_record(
merge_dicts(original, remove_none_items(properties),
-
wan_
service_mapping_info=mapping_info))
+ service_mapping_info=mapping_info))
num_changes = self.db.update_rows('wim_port_mappings',
UPDATE=updates, WHERE={'id': id})
num_changes = self.db.update_rows('wim_port_mappings',
UPDATE=updates, WHERE={'id': id})
@@
-864,10
+870,7
@@
def _preprocess_wim_account(wim_account):
"""
wim_account = preprocess_record(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
return wim_account
@@
-913,8
+916,8
@@
def _postprocess_wim_account(wim_account, hide=_CONFIDENTIAL_FIELDS):
def _postprocess_wim_port_mapping(mapping, hide=_CONFIDENTIAL_FIELDS):
mapping = _postprocess_record(mapping, hide=hide)
def _postprocess_wim_port_mapping(mapping, hide=_CONFIDENTIAL_FIELDS):
mapping = _postprocess_record(mapping, hide=hide)
- mapping_info = mapping.get('
wan_
service_mapping_info', None) or {}
- mapping['
wan_
service_mapping_info'] = mapping_info
+ mapping_info = mapping.get('service_mapping_info', None) or {}
+ mapping['service_mapping_info'] = mapping_info
return mapping
return mapping