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=========================================================
20 from onapsdk.aai.business import Customer
22 from config import Config
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 logger.info("******** Get Customer *******")
34 customer = Customer.get_by_global_customer_id(Config.GLOBAL_CUSTOMER_ID)
36 logger.error("Customer not found")
39 logger.info("******** Check Service Subscription *******")
40 service_subscription = None
41 for service_sub in customer.service_subscriptions:
42 if service_sub.service_type == Config.SERVICENAME:
43 logger.info("Service %s subscribed", Config.SERVICENAME)
44 service_subscription = service_sub
46 if not service_subscription:
47 logger.error("Service Subscription not found")
50 logger.info("******** Get Service Instance details *******")
51 service_instance = None
52 for service in service_subscription.service_instances:
53 if service.instance_name == Config.SERVICE_INSTANCE_NAME:
54 service_instance = service
56 if not service_instance:
57 logger.error("Service Instance not found")
60 logger.info("******** Delete Service %s *******", service_instance.instance_name)
61 service_deletion = service_instance.delete()