blob: fac28aa9ad3c33780f97e4ec7712a13271fe8c2d [file] [log] [blame]
Anderson Bravalheri0446cd52018-08-17 15:26:19 +01001# -*- coding: utf-8 -*-
2##
3# Copyright 2018 University of Bristol - High Performance Networks Research
4# Group
5# All Rights Reserved.
6#
7# Contributors: Anderson Bravalheri, Dimitrios Gkounis, Abubakar Siddique
8# Muqaddas, Navdeep Uniyal, Reza Nejabati and Dimitra Simeonidou
9#
10# Licensed under the Apache License, Version 2.0 (the "License"); you may
11# not use this file except in compliance with the License. You may obtain
12# a copy of the License at
13#
14# http://www.apache.org/licenses/LICENSE-2.0
15#
16# Unless required by applicable law or agreed to in writing, software
17# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
19# License for the specific language governing permissions and limitations
20# under the License.
21#
22# For those usages not covered by the Apache License, Version 2.0 please
23# contact with: <highperformance-networks@bristol.ac.uk>
24#
25# Neither the name of the University of Bristol nor the names of its
26# contributors may be used to endorse or promote products derived from
27# this software without specific prior written permission.
28#
29# This work has been performed in the context of DCMS UK 5G Testbeds
30# & Trials Programme and in the framework of the Metro-Haul project -
31# funded by the European Commission under Grant number 761727 through the
32# Horizon 2020 and 5G-PPP programmes.
33##
34
35"""In the case any error happens when trying to initiate the WIM Connector,
36we need a replacement for it, that will throw an error every time we try to
37execute any action
38"""
tierno72774862020-05-04 11:44:15 +000039from osm_ro_plugin.sdnconn import SdnConnectorError
Anderson Bravalheri0446cd52018-08-17 15:26:19 +010040
41
tierno72774862020-05-04 11:44:15 +000042class SdnFailingConnector(object):
Anderson Bravalheri0446cd52018-08-17 15:26:19 +010043 """Placeholder for a connector whose incitation failed,
44 This place holder will just raise an error every time an action is needed
45 from the connector.
46
47 This way we can make sure that all the other parts of the program will work
48 but the user will have all the information available to fix the problem.
49 """
50 def __init__(self, error_msg):
51 self.error_msg = error_msg
52
tiernoed3e4d42019-10-21 15:31:27 +000053 def __call__(self, wim, wim_account, config=None, logger=None):
54 return self
55
56 def vimconnector(self, *args, **kwargs):
57 raise Exception(self.error_msg)
58
Anderson Bravalheri0446cd52018-08-17 15:26:19 +010059 def check_credentials(self):
tiernoed3e4d42019-10-21 15:31:27 +000060 raise SdnConnectorError('Impossible to use WIM:\n' + self.error_msg)
Anderson Bravalheri0446cd52018-08-17 15:26:19 +010061
62 def get_connectivity_service_status(self, service_uuid, _conn_info=None):
tierno529a2de2020-07-20 15:39:45 +000063 raise SdnConnectorError('Impossible to retrieve status for {}: {}'
Anderson Bravalheri0446cd52018-08-17 15:26:19 +010064 .format(service_uuid, self.error_msg))
65
66 def create_connectivity_service(self, service_uuid, *args, **kwargs):
tierno529a2de2020-07-20 15:39:45 +000067 raise SdnConnectorError('Impossible to create connectivity: {}'
68 .format(self.error_msg))
Anderson Bravalheri0446cd52018-08-17 15:26:19 +010069
70 def delete_connectivity_service(self, service_uuid, _conn_info=None):
tierno529a2de2020-07-20 15:39:45 +000071 raise SdnConnectorError('Impossible to delete {}: {}'
Anderson Bravalheri0446cd52018-08-17 15:26:19 +010072 .format(service_uuid, self.error_msg))
73
74 def edit_connectivity_service(self, service_uuid, *args, **kwargs):
tierno529a2de2020-07-20 15:39:45 +000075 raise SdnConnectorError('Impossible to change connection {}: {}'
76 .format(service_uuid, self.error_msg))
Anderson Bravalheri0446cd52018-08-17 15:26:19 +010077
78 def clear_all_connectivity_services(self):
tierno529a2de2020-07-20 15:39:45 +000079 raise SdnConnectorError('Impossible to use WIM: {}'.format(self.error_msg))
Anderson Bravalheri0446cd52018-08-17 15:26:19 +010080
81 def get_all_active_connectivity_services(self):
tierno529a2de2020-07-20 15:39:45 +000082 raise SdnConnectorError('Impossible to use WIM: {}'.format(self.error_msg))