afcdb30792f775af7d31143ca3df05456a232008
[bottlenecks.git] / utils / k8s_setup / k8s_utils.py
1 #!/usr/bin/env python
2 ##############################################################################
3 # Copyright (c) 2018 Huawei Technologies Co.,Ltd and others.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 import os
12 import utils.logger as log
13
14 LOG = log.Logger(__name__).getLogger()
15 INSTALLER_TYPE = os.getenv("INSTALLER_TYPE")
16
17
18 def get_config_path(INSTALLER_TYPE=None, CONFIG_PATH="/tmp/k8s_config"):
19     if INSTALLER_TYPE:
20         CMD = "bash k8s_config_pre.sh -i " + INSTALLER_TYPE + \
21               " -c " + CONFIG_PATH
22         LOG.info("Executing command: " + CMD)
23         CONFIG_PATH = os.popen(CMD)
24     else:
25         if not os.path.exists(CONFIG_PATH):
26             raise Exception("Must at least specify the path \
27 of k8s config!")
28     return CONFIG_PATH