Example #1
0
def upload(context, node, directory, filepath):
    """ Upload a file to a host """
    log.info("Waiting for ssh access on node %s..." % node.getName())
    ssh = context.getUtils().sshForNode().apply(node)
    filename = os.path.basename(filepath)
    file = File(filepath)
    try:
        log.info("Uploading %s to %s..." % (filename, node.getName()))
        ssh.connect()
        ssh.put(directory + "/" + filename, Payloads.newFilePayload(file))
    finally:
        if ssh:
            ssh.disconnect()
Example #2
0
    def _upload_file_node(self, context, node, destination, filename,
            abs_path=False):
        ssh = context.getUtils().sshForNode().apply(node)
        path = filename if abs_path else self.__scriptdir + "/" + filename
        tmpfile = os.path.exists(path + ".tmp")
        file = File(path + ".tmp" if tmpfile else path)

        if abs_path:
            filename = os.path.basename(path)

        try:
            ssh.connect()
            log.info("Uploading file %s..." % filename)
            ssh.put(destination + "/" + filename,
                    Payloads.newFilePayload(file))
        finally:
            if ssh:
                ssh.disconnect()
            if tmpfile:
                os.remove(file.getPath())