| Anderson Bravalheri | 0446cd5 | 2018-08-17 15:26:19 +0100 | [diff] [blame] | 1 | # -*- 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, |
| 36 | we need a replacement for it, that will throw an error every time we try to |
| 37 | execute any action |
| 38 | """ |
| 39 | import json |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 40 | from osm_ro_plugin.sdnconn import SdnConnectorError |
| Anderson Bravalheri | 0446cd5 | 2018-08-17 15:26:19 +0100 | [diff] [blame] | 41 | |
| 42 | |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 43 | class SdnFailingConnector(object): |
| Anderson Bravalheri | 0446cd5 | 2018-08-17 15:26:19 +0100 | [diff] [blame] | 44 | """Placeholder for a connector whose incitation failed, |
| 45 | This place holder will just raise an error every time an action is needed |
| 46 | from the connector. |
| 47 | |
| 48 | This way we can make sure that all the other parts of the program will work |
| 49 | but the user will have all the information available to fix the problem. |
| 50 | """ |
| 51 | def __init__(self, error_msg): |
| 52 | self.error_msg = error_msg |
| 53 | |
| tierno | ed3e4d4 | 2019-10-21 15:31:27 +0000 | [diff] [blame] | 54 | def __call__(self, wim, wim_account, config=None, logger=None): |
| 55 | return self |
| 56 | |
| 57 | def vimconnector(self, *args, **kwargs): |
| 58 | raise Exception(self.error_msg) |
| 59 | |
| Anderson Bravalheri | 0446cd5 | 2018-08-17 15:26:19 +0100 | [diff] [blame] | 60 | def check_credentials(self): |
| tierno | ed3e4d4 | 2019-10-21 15:31:27 +0000 | [diff] [blame] | 61 | raise SdnConnectorError('Impossible to use WIM:\n' + self.error_msg) |
| Anderson Bravalheri | 0446cd5 | 2018-08-17 15:26:19 +0100 | [diff] [blame] | 62 | |
| 63 | def get_connectivity_service_status(self, service_uuid, _conn_info=None): |
| tierno | ed3e4d4 | 2019-10-21 15:31:27 +0000 | [diff] [blame] | 64 | raise SdnConnectorError('Impossible to retrieve status for {}\n\n{}' |
| Anderson Bravalheri | 0446cd5 | 2018-08-17 15:26:19 +0100 | [diff] [blame] | 65 | .format(service_uuid, self.error_msg)) |
| 66 | |
| 67 | def create_connectivity_service(self, service_uuid, *args, **kwargs): |
| tierno | ed3e4d4 | 2019-10-21 15:31:27 +0000 | [diff] [blame] | 68 | raise SdnConnectorError('Impossible to connect {}.\n{}\n{}\n{}' |
| Anderson Bravalheri | 0446cd5 | 2018-08-17 15:26:19 +0100 | [diff] [blame] | 69 | .format(service_uuid, self.error_msg, |
| 70 | json.dumps(args, indent=4), |
| 71 | json.dumps(kwargs, indent=4))) |
| 72 | |
| 73 | def delete_connectivity_service(self, service_uuid, _conn_info=None): |
| tierno | ed3e4d4 | 2019-10-21 15:31:27 +0000 | [diff] [blame] | 74 | raise SdnConnectorError('Impossible to disconnect {}\n\n{}' |
| Anderson Bravalheri | 0446cd5 | 2018-08-17 15:26:19 +0100 | [diff] [blame] | 75 | .format(service_uuid, self.error_msg)) |
| 76 | |
| 77 | def edit_connectivity_service(self, service_uuid, *args, **kwargs): |
| tierno | ed3e4d4 | 2019-10-21 15:31:27 +0000 | [diff] [blame] | 78 | raise SdnConnectorError('Impossible to change connection {}.\n{}\n' |
| Anderson Bravalheri | 0446cd5 | 2018-08-17 15:26:19 +0100 | [diff] [blame] | 79 | '{}\n{}' |
| 80 | .format(service_uuid, self.error_msg, |
| 81 | json.dumps(args, indent=4), |
| 82 | json.dumps(kwargs, indent=4))) |
| 83 | |
| 84 | def clear_all_connectivity_services(self): |
| tierno | ed3e4d4 | 2019-10-21 15:31:27 +0000 | [diff] [blame] | 85 | raise SdnConnectorError('Impossible to use WIM:\n' + self.error_msg) |
| Anderson Bravalheri | 0446cd5 | 2018-08-17 15:26:19 +0100 | [diff] [blame] | 86 | |
| 87 | def get_all_active_connectivity_services(self): |
| tierno | ed3e4d4 | 2019-10-21 15:31:27 +0000 | [diff] [blame] | 88 | raise SdnConnectorError('Impossible to use WIM:\n' + self.error_msg) |