-def setup_node(args):
- 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)
+def setup_node(node, tarball, remote_tarball, results=None):
+ """Copy a tarball to a node and extract it.
+
+ :param node: A node where the tarball will be copied and extracted.
+ :param tarball: Local path of tarball to be copied.
+ :param remote_tarball: Remote path of the tarball.
+ :param results: A list where to store the result of node setup, optional.
+ :type node: dict
+ :type tarball: str
+ :type remote_tarball: str
+ :type results: list
+ :returns: True - success, False - error
+ :rtype: bool
+ """
+ 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 RuntimeError as exc:
+ logger.error("Node {0} setup failed, error:'{1}'"
+ .format(node['host'], exc.message))
+ result = False
+ else:
+ logger.console('Setup of node {0} done'.format(node['host']))
+ result = True
+
+ if isinstance(results, list):
+ results.append(result)
+ return result