robot tcs, test charts, robot container added
[ta/cloudtaf.git] / testcases / basic_func_tests / tc_004_ssh_file_check.py
diff --git a/testcases/basic_func_tests/tc_004_ssh_file_check.py b/testcases/basic_func_tests/tc_004_ssh_file_check.py
new file mode 100644 (file)
index 0000000..57d1871
--- /dev/null
@@ -0,0 +1,36 @@
+import sys
+import os
+from robot.libraries.BuiltIn import BuiltIn
+from robot.api import logger
+import common_utils
+from test_constants import *
+
+sys.path.append(os.path.join(os.path.dirname(__file__), '..', '../libraries/common'))
+
+ex = BuiltIn().get_library_instance('execute_command')
+stack_infos = BuiltIn().get_library_instance('stack_infos')
+
+
+def tc_004_ssh_file_check():
+    steps = ['step1_openstack_file_check_on_crf_nodes']
+    common_utils.keyword_runner(steps)
+
+
+def step1_openstack_file_check_on_crf_nodes():
+    check_file(stack_infos.get_crf_nodes(), '/etc/userconfig/', crf_node_openstack_file_types)
+
+
+def check_file(nodes, folder, files):
+    if not nodes:
+        logger.info("Nodes dictionary is empty, nothing to check.")
+        return
+    for key in nodes:
+        logger.console("\n" + key + " " + nodes[key])
+        for f in files:
+            full_file_path = folder + f
+            command = 'ls ' + full_file_path + ' | wc -l'
+            stdout = ex.execute_unix_command_on_remote_as_user(command, nodes[key])
+            if stdout == "1":
+                logger.console(full_file_path + " exists.")
+            else:
+                raise Exception(full_file_path + " not exists !")