+ """Delete local tarball to prevent disk pollution.
+
+ :param tarball: Path to tarball to upload.
+ :type tarball: str
+ :returns: nothing
+ """
+ call(split('sh -c "rm {0} > /dev/null 2>&1"'.format(tarball)))
+
+
+def delete_framework_dir(node):
+ """Delete framework directory in /tmp/ on given node.
+
+ :param node: Node to delete framework directory on.
+ :type node: dict
+ """
+ logger.console('Deleting framework directory on {0}'
+ .format(node['host']))
+ ssh = SSH()
+ ssh.connect(node)
+ (ret_code, _, _) = ssh.exec_command(
+ 'sudo rm -rf {0}'
+ .format(con.REMOTE_FW_DIR), timeout=100)
+ if ret_code != 0:
+ raise RuntimeError('Deleting framework directory on {0} failed'
+ .format(node))
+
+
+def cleanup_node(node):
+ """Run all clean-up methods for a node.
+
+ This method is used as map_async parameter. It receives tuple with all
+ parameters as passed to map_async function.
+
+ :param node: Node to do cleanup on.
+ :type node: dict
+ :returns: True - success, False - error
+ :rtype: bool
+ """
+ try:
+ delete_framework_dir(node)
+ except RuntimeError:
+ logger.error("Cleanup of node {0} failed".format(node['host']))
+ return False
+ else:
+ logger.console('Cleanup of node {0} done'.format(node['host']))
+ return True