robot tcs, test charts, robot container added
[ta/cloudtaf.git] / testcases / basic_func_tests / tc_004_ssh_file_check.py
1 import sys
2 import os
3 from robot.libraries.BuiltIn import BuiltIn
4 from robot.api import logger
5 import common_utils
6 from test_constants import *
7
8 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '../libraries/common'))
9
10 ex = BuiltIn().get_library_instance('execute_command')
11 stack_infos = BuiltIn().get_library_instance('stack_infos')
12
13
14 def tc_004_ssh_file_check():
15     steps = ['step1_openstack_file_check_on_crf_nodes']
16     common_utils.keyword_runner(steps)
17
18
19 def step1_openstack_file_check_on_crf_nodes():
20     check_file(stack_infos.get_crf_nodes(), '/etc/userconfig/', crf_node_openstack_file_types)
21
22
23 def check_file(nodes, folder, files):
24     if not nodes:
25         logger.info("Nodes dictionary is empty, nothing to check.")
26         return
27     for key in nodes:
28         logger.console("\n" + key + " " + nodes[key])
29         for f in files:
30             full_file_path = folder + f
31             command = 'ls ' + full_file_path + ' | wc -l'
32             stdout = ex.execute_unix_command_on_remote_as_user(command, nodes[key])
33             if stdout == "1":
34                 logger.console(full_file_path + " exists.")
35             else:
36                 raise Exception(full_file_path + " not exists !")