3 # ============LICENSE_START===================================================
4 # ORAN SMO PACKAGE - PYTHONSDK TESTS
5 # ================================================================================
6 # Copyright (C) 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.
21 # SPDX-License-Identifier: Apache-2.0
22 # ============LICENSE_END=====================================================
25 """Update UUI configuration for Network Slicing option2 test."""
29 from subprocess import check_output
30 from onapsdk.configuration import settings
32 logging.config.dictConfig(settings.LOG_CONFIG)
33 logger = logging.getLogger("####################### Start UUI Preparation")
35 class UuiPreparation():
36 """Can be used to prepare UUI for Network Slicing usecase option2."""
39 def prepare_uui(cls, cst_uuid, cst_invariant_id):
40 """Register services to uui."""
41 logger.info("####################### Start to update uui settings")
42 uui_pod = subprocess.run("kubectl get pod -n onap | grep uui-server | awk '{print $1}' ", shell=True, check=True, stdout=subprocess.PIPE).stdout.decode('utf-8').strip()
44 cmd = f"kubectl exec -ti -n onap {uui_pod} -- sed -i 's/8ee5926d-720b-4bb2-86f9-d20e921c143b/{cst_uuid}/g' /home/uui/config/slicing.properties"
45 check_output(cmd, shell=True).decode('utf-8')
47 cmd = f"kubectl exec -ti -n onap {uui_pod} -- sed -i 's/e75698d9-925a-4cdd-a6c0-edacbe6a0b51/{cst_invariant_id}/g' /home/uui/config/slicing.properties"
48 check_output(cmd, shell=True).decode('utf-8')
51 def cleanup_uui(cls, cst_uuid, cst_invariant_id):
52 """Rollback uui settings."""
53 logger.info("####################### Start to rollback uui settings")
54 uui_pod = subprocess.run("kubectl get pod -n onap | grep uui-server | awk '{print $1}' ", shell=True, check=True, stdout=subprocess.PIPE).stdout.decode('utf-8').strip()
56 cmd = f"kubectl exec -ti -n onap {uui_pod} -- sed -i 's/{cst_uuid}/8ee5926d-720b-4bb2-86f9-d20e921c143b/g' /home/uui/config/slicing.properties"
57 check_output(cmd, shell=True).decode('utf-8')
59 cmd = f"kubectl exec -ti -n onap {uui_pod} -- sed -i 's/{cst_invariant_id}/e75698d9-925a-4cdd-a6c0-edacbe6a0b51/g' /home/uui/config/slicing.properties"
60 check_output(cmd, shell=True).decode('utf-8')
61 logger.info("####################### UUI settings rollback successfully")