CSIT-212 SetupFramework scp result - logging fix 87/2087/5
authorMiroslav Miklus <mmiklus@cisco.com>
Tue, 26 Jul 2016 14:38:58 +0000 (16:38 +0200)
committerJan Gelety <jgelety@cisco.com>
Thu, 28 Jul 2016 14:14:02 +0000 (14:14 +0000)
Change-Id: I23a8090a117acd9cd0bef8bd69689751742d63e9
Signed-off-by: Miroslav Miklus <mmiklus@cisco.com>
resources/libraries/python/SetupFramework.py

index b81a306..570a2ba 100644 (file)
@@ -111,7 +111,7 @@ def create_env_directory_at_node(node):
     else:
         logger.console('Virtualenv created on {0}'.format(node['host']))
 
-
+#pylint: disable=broad-except
 def setup_node(args):
     """Run all set-up methods for a node.
 
@@ -121,14 +121,21 @@ def setup_node(args):
     :param args: All parameters needed to setup one node.
     :type args: tuple
     :return: nothing
+    :return: True - success, False - error
+    :rtype: bool
     """
     tarball, remote_tarball, node = args
-    copy_tarball_to_node(tarball, node)
-    extract_tarball_at_node(remote_tarball, node)
-    if node['type'] == NodeType.TG:
-        create_env_directory_at_node(node)
-    logger.console('Setup of node {0} done'.format(node['host']))
-
+    try:
+        copy_tarball_to_node(tarball, node)
+        extract_tarball_at_node(remote_tarball, node)
+        if node['type'] == NodeType.TG:
+            create_env_directory_at_node(node)
+    except Exception as exc:
+        logger.error("Node setup failed, error:'{0}'".format(exc.message))
+        return False
+    else:
+        logger.console('Setup of node {0} done'.format(node['host']))
+        return True
 
 def delete_local_tarball(tarball):
     """Delete local tarball to prevent disk pollution.
@@ -166,14 +173,15 @@ class SetupFramework(object): # pylint: disable=too-few-public-methods
         pool.close()
         pool.join()
 
+        # Turn on logging
+        BuiltIn().set_log_level(log_level)
+
         logger.info(
             'Executed node setups in parallel, waiting for processes to end')
         result.wait()
 
         logger.info('Results: {0}'.format(result.get()))
 
-        # Turn on logging
-        BuiltIn().set_log_level(log_level)
         logger.trace('Test framework copied to all topology nodes')
         delete_local_tarball(tarball)
         logger.console('All nodes are ready')

©2016 FD.io a Linux Foundation Collaborative Project. All Rights Reserved.
Linux Foundation is a registered trademark of The Linux Foundation. Linux is a registered trademark of Linus Torvalds.
Please see our privacy policy and terms of use.