Fix/add use cases under SMO package
[it/dep.git] / smo-install / test / pythonsdk / src / orantests / oran_tests / smo / nonrtric.py
1 #!/usr/bin/env python3
2 ###
3 # ============LICENSE_START=======================================================
4 # ORAN SMO PACKAGE - PYTHONSDK TESTS
5 # ================================================================================
6 # Copyright (C) 2021-2022 AT&T Intellectual Property. All rights
7 #                             reserved.
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
12 #
13 # http://www.apache.org/licenses/LICENSE-2.0
14 #
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 # ===================================================================
22 #
23 ###
24
25 """NonrtRic module."""
26 import logging
27 import logging.config
28 from subprocess import check_output
29 from onapsdk.configuration import settings
30
31 logging.config.dictConfig(settings.LOG_CONFIG)
32 logger = logging.getLogger("NonRTRIc k8s")
33
34 class NonRTRic():
35     """Control the Nonrtric k8s deployment."""
36
37     @classmethod
38     def is_nonrtric_up(cls):
39         """Check if the nonrtric is up."""
40         cmd = "kubectl get pods --field-selector status.phase!=Running -n nonrtric | wc -l"
41         result = check_output(cmd, shell=True).decode('utf-8')
42         logger.info("Number of NonRTRIC pods not in Running state (expected == 0):%s", result)
43         if int(result) == 0:
44             logger.info("NONRTRIC is Up")
45             return True
46
47         logger.info("NONRTRIC is Down")
48         return False