From: garciadeblas Date: Fri, 21 Feb 2020 11:02:11 +0000 (+0100) Subject: Renamed FakeWimconnector to DummyWimconnector X-Git-Tag: v7.1.0rc1~1^2~23 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=08cfe043bcce0c20728b09865f192f9c61d864e7;p=osm%2FRO.git Renamed FakeWimconnector to DummyWimconnector Change-Id: I0e32bfd988a89d85cae56e85136773f1afd5cc32 Signed-off-by: garciadeblas --- diff --git a/RO/osm_ro/nfvo.py b/RO/osm_ro/nfvo.py index 82096cd1..96e0a7a0 100644 --- a/RO/osm_ro/nfvo.py +++ b/RO/osm_ro/nfvo.py @@ -64,7 +64,7 @@ from pkg_resources import iter_entry_points # WIM from .wim import sdnconn -from .wim.wimconn_fake import FakeConnector +from .wim.wimconn_dummy import DummyConnector from .wim.failing_connector import FailingConnector from .http_tools import errors as httperrors from .wim.engine import WimEngine @@ -195,8 +195,8 @@ def start_service(mydb, persistence=None, wim=None): try: worker_id = get_process_id() - if "rosdn_fake" not in plugins: - plugins["rosdn_fake"] = FakeConnector + if "rosdn_dummy" not in plugins: + plugins["rosdn_dummy"] = DummyConnector # starts ovim library ovim = Sdn(db, plugins) diff --git a/RO/osm_ro/wim/schemas.py b/RO/osm_ro/wim/schemas.py index a887b65a..f20d418f 100644 --- a/RO/osm_ro/wim/schemas.py +++ b/RO/osm_ro/wim/schemas.py @@ -39,7 +39,7 @@ from ..openmano_schemas import ( ) # WIM ------------------------------------------------------------------------- -wim_types = ["tapi", "onos", "onos_vpls", "odl", "dynpac", "fake"] +wim_types = ["tapi", "onos", "onos_vpls", "odl", "dynpac", "dummy"] dpid_type = { "type": "string", @@ -96,7 +96,7 @@ wim_schema_properties = { "description": description_schema, "type": { "type": "string", - # "enum": ["tapi", "onos", "odl", "dynpac", "fake"] + # "enum": ["tapi", "onos", "odl", "dynpac", "dummy"] }, "wim_url": description_schema, "config": { diff --git a/RO/osm_ro/wim/wim_thread.py b/RO/osm_ro/wim/wim_thread.py index 34661935..bf35837e 100644 --- a/RO/osm_ro/wim/wim_thread.py +++ b/RO/osm_ro/wim/wim_thread.py @@ -61,7 +61,7 @@ from .errors import ( ) from .failing_connector import FailingConnector from .sdnconn import SdnConnectorError -from .wimconn_fake import FakeConnector +from .wimconn_dummy import DummyConnector ACTIONS = { 'instance_wim_nets': wan_link_actions.ACTIONS @@ -69,7 +69,7 @@ ACTIONS = { CONNECTORS = { # "odl": wimconn_odl.OdlConnector, - "fake": FakeConnector, + "dummy": DummyConnector, # Add extra connectors here not managed via plugins } @@ -110,8 +110,8 @@ class WimThread(threading.Thread): wim_account['name'], wim_account['uuid']) super(WimThread, self).__init__(name=name) self.plugins = plugins - if "rosdn_fake" not in self.plugins: - self.plugins["rosdn_fake"] = FakeConnector + if "rosdn_dummy" not in self.plugins: + self.plugins["rosdn_dummy"] = DummyConnector self.name = name self.connector = None diff --git a/RO/osm_ro/wim/wimconn_dummy.py b/RO/osm_ro/wim/wimconn_dummy.py new file mode 100644 index 00000000..3e15b645 --- /dev/null +++ b/RO/osm_ro/wim/wimconn_dummy.py @@ -0,0 +1,144 @@ +# -*- coding: utf-8 -*- +## +# Copyright 2018 Telefonica +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +This WIM does nothing and allows using it for testing and when no WIM is needed +""" + +import logging +from uuid import uuid4 +from .sdnconn import SdnConnectorBase, SdnConnectorError +from http import HTTPStatus +__author__ = "Alfonso Tierno " + + +class DummyConnector(SdnConnectorBase): + """Abstract base class for all the WIM connectors + + Arguments: + wim (dict): WIM record, as stored in the database + wim_account (dict): WIM account record, as stored in the database + config (dict): optional persistent information related to an specific + connector. Inside this dict, a special key, + ``service_endpoint_mapping`` provides the internal endpoint + mapping. + logger (logging.Logger): optional logger object. If none is passed + ``openmano.wim.wimconn`` is used. + + The arguments of the constructor are converted to object attributes. + An extra property, ``service_endpoint_mapping`` is created from ``config``. + """ + def __init__(self, wim, wim_account, config=None, logger=None): + self.logger = logger or logging.getLogger('openmano.sdnconn.dummy') + super(DummyConnector, self).__init__(wim, wim_account, config, self.logger) + self.logger.debug("__init: wim='{}' wim_account='{}'".format(wim, wim_account)) + self.connections = {} + self.counter = 0 + + def check_credentials(self): + """Check if the connector itself can access the WIM. + + Raises: + SdnConnectorError: Issues regarding authorization, access to + external URLs, etc are detected. + """ + self.logger.debug("check_credentials") + return None + + def get_connectivity_service_status(self, service_uuid, conn_info=None): + """Monitor the status of the connectivity service established + + Arguments: + service_uuid (str): UUID of the connectivity service + conn_info (dict or None): Information returned by the connector + during the service creation/edition and subsequently stored in + the database. + + Returns: + dict: JSON/YAML-serializable dict that contains a mandatory key + ``sdn_status`` associated with one of the following values:: + + Additionally ``error_msg``(**str**) and ``sdn_info``(**dict**) + keys can be used to provide additional status explanation or + new information available for the connectivity service. + """ + self.logger.debug("get_connectivity_service_status: service_uuid='{}' conn_info='{}'".format(service_uuid, + conn_info)) + return {'sdn_status': 'ACTIVE', 'sdn_info': self.connectivity.get(service_uuid)} + + def create_connectivity_service(self, service_type, connection_points, + **kwargs): + """ + Stablish WAN connectivity between the endpoints + + """ + self.logger.debug("create_connectivity_service: service_type='{}' connection_points='{}', kwargs='{}'". + format(service_type, connection_points, kwargs)) + _id = str(uuid4()) + self.connections[_id] = connection_points.copy() + self.counter += 1 + return _id, None + + def delete_connectivity_service(self, service_uuid, conn_info=None): + """Disconnect multi-site endpoints previously connected + + """ + self.logger.debug("delete_connectivity_service: service_uuid='{}' conn_info='{}'".format(service_uuid, + conn_info)) + if service_uuid not in self.connections: + raise SdnConnectorError("connectivity {} not found".format(service_uuid), + http_code=HTTPStatus.NOT_FOUND.value) + self.connections.pop(service_uuid, None) + return None + + def edit_connectivity_service(self, service_uuid, conn_info=None, + connection_points=None, **kwargs): + """Change an existing connectivity service. + + This method's arguments and return value follow the same convention as + :meth:`~.create_connectivity_service`. + """ + self.logger.debug("edit_connectivity_service: service_uuid='{}' conn_info='{}', connection_points='{}'" + "kwargs='{}'".format(service_uuid, conn_info, connection_points, kwargs)) + if service_uuid not in self.connections: + raise SdnConnectorError("connectivity {} not found".format(service_uuid), + http_code=HTTPStatus.NOT_FOUND.value) + self.connections[service_uuid] = connection_points.copy() + return None + + def clear_all_connectivity_services(self): + """Delete all WAN Links in a WIM. + + This method is intended for debugging only, and should delete all the + connections controlled by the WIM, not only the WIM connections that + a specific RO is aware of. + + """ + self.logger.debug("clear_all_connectivity_services") + self.connections.clear() + return None + + def get_all_active_connectivity_services(self): + """Provide information about all active connections provisioned by a + WIM. + + Raises: + SdnConnectorException: In case of error. + """ + self.logger.debug("get_all_active_connectivity_services") + return self.connections diff --git a/RO/osm_ro/wim/wimconn_fake.py b/RO/osm_ro/wim/wimconn_fake.py deleted file mode 100644 index 168996d7..00000000 --- a/RO/osm_ro/wim/wimconn_fake.py +++ /dev/null @@ -1,144 +0,0 @@ -# -*- coding: utf-8 -*- -## -# Copyright 2018 Telefonica -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" -This WIM does nothing and allows using it for testing and when no WIM is needed -""" - -import logging -from uuid import uuid4 -from .sdnconn import SdnConnectorBase, SdnConnectorError -from http import HTTPStatus -__author__ = "Alfonso Tierno " - - -class FakeConnector(SdnConnectorBase): - """Abstract base class for all the WIM connectors - - Arguments: - wim (dict): WIM record, as stored in the database - wim_account (dict): WIM account record, as stored in the database - config (dict): optional persistent information related to an specific - connector. Inside this dict, a special key, - ``service_endpoint_mapping`` provides the internal endpoint - mapping. - logger (logging.Logger): optional logger object. If none is passed - ``openmano.wim.wimconn`` is used. - - The arguments of the constructor are converted to object attributes. - An extra property, ``service_endpoint_mapping`` is created from ``config``. - """ - def __init__(self, wim, wim_account, config=None, logger=None): - self.logger = logger or logging.getLogger('openmano.sdnconn.fake') - super(FakeConnector, self).__init__(wim, wim_account, config, self.logger) - self.logger.debug("__init: wim='{}' wim_account='{}'".format(wim, wim_account)) - self.connections = {} - self.counter = 0 - - def check_credentials(self): - """Check if the connector itself can access the WIM. - - Raises: - SdnConnectorError: Issues regarding authorization, access to - external URLs, etc are detected. - """ - self.logger.debug("check_credentials") - return None - - def get_connectivity_service_status(self, service_uuid, conn_info=None): - """Monitor the status of the connectivity service established - - Arguments: - service_uuid (str): UUID of the connectivity service - conn_info (dict or None): Information returned by the connector - during the service creation/edition and subsequently stored in - the database. - - Returns: - dict: JSON/YAML-serializable dict that contains a mandatory key - ``sdn_status`` associated with one of the following values:: - - Additionally ``error_msg``(**str**) and ``sdn_info``(**dict**) - keys can be used to provide additional status explanation or - new information available for the connectivity service. - """ - self.logger.debug("get_connectivity_service_status: service_uuid='{}' conn_info='{}'".format(service_uuid, - conn_info)) - return {'sdn_status': 'ACTIVE', 'sdn_info': self.connectivity.get(service_uuid)} - - def create_connectivity_service(self, service_type, connection_points, - **kwargs): - """ - Stablish WAN connectivity between the endpoints - - """ - self.logger.debug("create_connectivity_service: service_type='{}' connection_points='{}', kwargs='{}'". - format(service_type, connection_points, kwargs)) - _id = str(uuid4()) - self.connections[_id] = connection_points.copy() - self.counter += 1 - return _id, None - - def delete_connectivity_service(self, service_uuid, conn_info=None): - """Disconnect multi-site endpoints previously connected - - """ - self.logger.debug("delete_connectivity_service: service_uuid='{}' conn_info='{}'".format(service_uuid, - conn_info)) - if service_uuid not in self.connections: - raise SdnConnectorError("connectivity {} not found".format(service_uuid), - http_code=HTTPStatus.NOT_FOUND.value) - self.connections.pop(service_uuid, None) - return None - - def edit_connectivity_service(self, service_uuid, conn_info=None, - connection_points=None, **kwargs): - """Change an existing connectivity service. - - This method's arguments and return value follow the same convention as - :meth:`~.create_connectivity_service`. - """ - self.logger.debug("edit_connectivity_service: service_uuid='{}' conn_info='{}', connection_points='{}'" - "kwargs='{}'".format(service_uuid, conn_info, connection_points, kwargs)) - if service_uuid not in self.connections: - raise SdnConnectorError("connectivity {} not found".format(service_uuid), - http_code=HTTPStatus.NOT_FOUND.value) - self.connections[service_uuid] = connection_points.copy() - return None - - def clear_all_connectivity_services(self): - """Delete all WAN Links in a WIM. - - This method is intended for debugging only, and should delete all the - connections controlled by the WIM, not only the WIM connections that - a specific RO is aware of. - - """ - self.logger.debug("clear_all_connectivity_services") - self.connections.clear() - return None - - def get_all_active_connectivity_services(self): - """Provide information about all active connections provisioned by a - WIM. - - Raises: - SdnConnectorException: In case of error. - """ - self.logger.debug("get_all_active_connectivity_services") - return self.connections