summaryrefslogtreecommitdiffstats
path: root/dovetail/utils/dovetail_utils.py
diff options
context:
space:
mode:
authorxudan <xudan16@huawei.com>2018-03-09 03:27:14 -0500
committerGeorg Kunz <georg.kunz@ericsson.com>2018-03-14 16:01:41 +0000
commit66d20467c423505559bba2efa5aae2619903d647 (patch)
tree10d796efb2e5c7e679150d7a63ecc5842fd5ccd5 /dovetail/utils/dovetail_utils.py
parent189f27b7a90b6ddc74f1c3ede806e87d7548c539 (diff)
Add process info to pod.yaml to specify the info of a special process
1. Many HA test cases try to kill special processes with their name. 2. Then they check corresponding openstack services and the status of processes' recovery. 3. For different SUTs, the names of the processes and the hosts' names may be different. 4. So there is a requirement for Dovetail tool to provide one way to allow users to specify all the infos about process name and its host name. 5. All process infos can be added into file DOVETAIL_HOME/user_config/pod.yaml 6. The infos include 'attack_process' and 'attack_host' for each HA test cases. 7. If not given in this file, will use Yardtsick default values. JIRA: DOVETAIL-627 Change-Id: I83cee991f72a8685080ed562597c70d73002623a Signed-off-by: xudan <xudan16@huawei.com>
Diffstat (limited to 'dovetail/utils/dovetail_utils.py')
-rw-r--r--dovetail/utils/dovetail_utils.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/dovetail/utils/dovetail_utils.py b/dovetail/utils/dovetail_utils.py
index 2c16ca71..be2974b6 100644
--- a/dovetail/utils/dovetail_utils.py
+++ b/dovetail/utils/dovetail_utils.py
@@ -379,3 +379,31 @@ def get_hosts_info(logger=None):
logger.error("There is no key {} in file {}"
.format(e, hosts_config_file))
return hosts_config
+
+
+def read_yaml_file(file_path, logger=None):
+ if not os.path.isfile(file_path):
+ logger.error("File {} doesn't exist.".format(file_path))
+ return None
+ try:
+ with open(file_path, 'r') as f:
+ content = yaml.safe_load(f)
+ return content
+ except Exception as e:
+ logger.exception("Failed to read file {}, exception: {}"
+ .format(file_path, e))
+ return None
+
+
+def read_plain_file(file_path, logger=None):
+ if not os.path.isfile(file_path):
+ logger.error("File {} doesn't exist.".format(file_path))
+ return None
+ try:
+ with open(file_path, 'r') as f:
+ content = f.read()
+ return content
+ except Exception as e:
+ logger.exception("Failed to read file {}, exception: {}"
+ .format(file_path, e))
+ return None