3 # ============LICENSE_START=======================================================
4 # ORAN SMO PACKAGE - PYTHONSDK TESTS
5 # ================================================================================
6 # Copyright (C) 2021-2022 AT&T Intellectual Property. All rights
8 # ================================================================================
9 # Licensed under the Apache License, Version 2.0 (the "License");
10 # you may not use this file except in compliance with the License.
11 # You may obtain a copy of the License at
13 # http://www.apache.org/licenses/LICENSE-2.0
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 # See the License for the specific language governing permissions and
19 # limitations under the License.
20 # ============LICENSE_END============================================
21 # ===================================================================
25 """Cl usecase utils module."""
28 from waiting import wait
29 from onapsdk.configuration import settings
30 from oransdk.policy.clamp import ClampToscaTemplate
32 logging.config.dictConfig(settings.LOG_CONFIG)
33 logger = logging.getLogger("Cl usecae utils")
34 clamp = ClampToscaTemplate(settings.CLAMP_BASICAUTH)
37 class ClCommissioningUtils():
38 """Can be used to have cl usecase utils methods."""
41 def clean_instance(cls, usecase_name):
42 """Clean template instance."""
43 clamp.change_instance_status("UNINITIALISED", usecase_name, "1.2.3")
44 wait(lambda: clamp.verify_instance_status("UNINITIALISED"), sleep_seconds=5, timeout_seconds=60,
45 waiting_for="Clamp instance switches to UNINITIALISED")
47 logger.info("Delete Instance")
48 clamp.delete_template_instance(usecase_name, "1.2.3")
49 logger.info("Decommission tosca")
50 clamp.decommission_template("ToscaServiceTemplateSimple", "1.0.0")
53 def create_instance(cls, usecase_name, commissioning_payload, instance_payload) -> bool:
54 """Create template instance."""
55 response = clamp.upload_commission(commissioning_payload)
56 if response["errorDetails"] is not None:
59 logger.info("Create Instance")
60 response = clamp.create_instance(instance_payload)
61 if response["errorDetails"] is not None:
64 logger.info("Change Instance Status to PASSIVE")
65 clamp.change_instance_status("PASSIVE", usecase_name, "1.2.3")
66 wait(lambda: clamp.verify_instance_status("PASSIVE"), sleep_seconds=5, timeout_seconds=60,
67 waiting_for="Clamp instance switches to PASSIVE")