1 # ============LICENSE_START=======================================================
2 # Copyright (C) 2020 Orange
3 # ================================================================================
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 # ============LICENSE_END=========================================================
21 from config import Config
22 from onapsdk.msb.k8s import ConnectivityInfo
24 logger = logging.getLogger("")
25 logger.setLevel(logging.DEBUG)
26 fh = logging.StreamHandler()
27 fh_formatter = logging.Formatter('%(asctime)s %(levelname)s %(lineno)d:%(filename)s(%(process)d) - %(message)s')
28 fh.setFormatter(fh_formatter)
31 MYPATH = os.path.dirname(os.path.realpath(__file__))
33 logger.info("******** Connectivity Info *******")
34 with open(os.path.join(MYPATH, Config.CLUSTER_KUBECONFIG_PATH), 'rb') as kubeconfig_file:
35 kubeconfig = kubeconfig_file.read()
37 connectivity_info = ConnectivityInfo.get_connectivity_info_by_region_id(cloud_region_id=Config.CLOUD_REGION)
38 logger.info("Connectivity Info exists ")
39 logger.info("Delete Connectivity Info exists ")
40 connectivity_info.delete()
41 connectivity_info = ConnectivityInfo.create(cloud_region_id=Config.CLOUD_REGION,
42 cloud_owner=Config.CLOUD_OWNER,
43 kubeconfig=kubeconfig)
45 logger.info("Connectivity Info does not exists ")
46 connectivity_info = ConnectivityInfo.create(cloud_region_id=Config.CLOUD_REGION,
47 cloud_owner=Config.CLOUD_OWNER,
48 kubeconfig=kubeconfig)
49 logger.info("Connectivity Info created ")