X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=RO-plugin%2Fosm_ro_plugin%2Fsdn_failing.py;fp=RO-plugin%2Fosm_ro_plugin%2Fsdn_failing.py;h=b8ea42f1d8d4c98b79a5e9631a3f7d3b4b94836d;hb=7277486065c905f91477bb064da86855a8fa269a;hp=0000000000000000000000000000000000000000;hpb=667d158c0d3ee7b4c176ad0b27ac428c81b0ddbc;p=osm%2FRO.git diff --git a/RO-plugin/osm_ro_plugin/sdn_failing.py b/RO-plugin/osm_ro_plugin/sdn_failing.py new file mode 100644 index 00000000..b8ea42f1 --- /dev/null +++ b/RO-plugin/osm_ro_plugin/sdn_failing.py @@ -0,0 +1,88 @@ +# -*- coding: utf-8 -*- +## +# Copyright 2018 University of Bristol - High Performance Networks Research +# Group +# All Rights Reserved. +# +# Contributors: Anderson Bravalheri, Dimitrios Gkounis, Abubakar Siddique +# Muqaddas, Navdeep Uniyal, Reza Nejabati and Dimitra Simeonidou +# +# 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. +# +# For those usages not covered by the Apache License, Version 2.0 please +# contact with: +# +# Neither the name of the University of Bristol nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# This work has been performed in the context of DCMS UK 5G Testbeds +# & Trials Programme and in the framework of the Metro-Haul project - +# funded by the European Commission under Grant number 761727 through the +# Horizon 2020 and 5G-PPP programmes. +## + +"""In the case any error happens when trying to initiate the WIM Connector, +we need a replacement for it, that will throw an error every time we try to +execute any action +""" +import json +from osm_ro_plugin.sdnconn import SdnConnectorError + + +class SdnFailingConnector(object): + """Placeholder for a connector whose incitation failed, + This place holder will just raise an error every time an action is needed + from the connector. + + This way we can make sure that all the other parts of the program will work + but the user will have all the information available to fix the problem. + """ + def __init__(self, error_msg): + self.error_msg = error_msg + + def __call__(self, wim, wim_account, config=None, logger=None): + return self + + def vimconnector(self, *args, **kwargs): + raise Exception(self.error_msg) + + def check_credentials(self): + raise SdnConnectorError('Impossible to use WIM:\n' + self.error_msg) + + def get_connectivity_service_status(self, service_uuid, _conn_info=None): + raise SdnConnectorError('Impossible to retrieve status for {}\n\n{}' + .format(service_uuid, self.error_msg)) + + def create_connectivity_service(self, service_uuid, *args, **kwargs): + raise SdnConnectorError('Impossible to connect {}.\n{}\n{}\n{}' + .format(service_uuid, self.error_msg, + json.dumps(args, indent=4), + json.dumps(kwargs, indent=4))) + + def delete_connectivity_service(self, service_uuid, _conn_info=None): + raise SdnConnectorError('Impossible to disconnect {}\n\n{}' + .format(service_uuid, self.error_msg)) + + def edit_connectivity_service(self, service_uuid, *args, **kwargs): + raise SdnConnectorError('Impossible to change connection {}.\n{}\n' + '{}\n{}' + .format(service_uuid, self.error_msg, + json.dumps(args, indent=4), + json.dumps(kwargs, indent=4))) + + def clear_all_connectivity_services(self): + raise SdnConnectorError('Impossible to use WIM:\n' + self.error_msg) + + def get_all_active_connectivity_services(self): + raise SdnConnectorError('Impossible to use WIM:\n' + self.error_msg)