Пример #1
0
def uploadFiles(instance, conf, srcFiles, outDir, log=False):
    """
    This uploads srcFiles to the outDir, this is very low level and meant to allow the user to upload anywhere
    instance - the instance to upload to
    conf - contains various config data, the following options need to be present:
           ssh.options - options to pass to ssh
           ssh.user - user to ssh as
    srcFiles - a list of files to upload
    outDir - the directory to put them in
    """
    ##
    # This is cheap, but we'll have the mkdir print its error out to screen if logging is on, in reality if this fails
    # we should wrap it up somehow in an exception
    runSystemInstanceEx(instance, 'mkdir -p ' + outDir, None, (log and errorPrintS or None), user=conf('ssh.user'), options=conf('ssh.options'), log=log)
    for f in srcFiles:
        scpToEx(instance['public_dns'], f, outDir, user=conf('ssh.user'), options=conf('ssh.options'), log=log)
Пример #2
0
def uploadTag(instance, conf, tagDir, tagName, srcFiles, outDir, log=False):
    """
    This generates a tag (file list) from srcFiles and uploads the
    tag to the tag directory.
    instance - instance to upload to
    conf - contains various config data, the following options need to be present:
           ssh.options - options to pass to ssh
           ssh.user - user to ssh as
    tagDir - directory to put the tag in
    tagName - name of the tag
    srcFiles - list of files that the tag will be generated from
    outDir - the directory the srcFiles were put into
    """
    tempFName = os.path.join('/tmp', str(time.time()))
    fout = open(tempFName, 'w')
    for f in srcFiles:
        fout.write(os.path.join(outDir, os.path.basename(f)) + '\n')

    fout.close()
    runSystemInstanceEx(instance, 'mkdir -p ' + tagDir, None, (log and errorPrintS or None), user=conf('ssh.user'), options=conf('ssh.options'), log=log)
    scpToEx(instance['public_dns'], tempFName, os.path.join(tagDir, tagName), user=conf('ssh.user'), options=conf('ssh.options'), log=log)
    os.remove(tempFName)
Пример #3
0
    # and destinatio file name which we will then loop over and upload
    dstFileNames = [(f, os.path.join(dstCluster['config']['dirs.upload_dir'], tagName,
                                     makePathRelative(f.replace(tagBaseDir, ''))))
                    for f in tagData('files')]

    ##
    # Next, lets call 'mkdir -p' on all the dirs we need to make on the destination cluster
    try:
        makeDirsOnCluster(dstCluster, dirNames)
    except TryError, err:
        errorPrint('Caught TryError, ignoring for now: %s - %s ' % (err.msg, str(err.result)))

    ##
    # Now, copy up all of the files
    for l, d in dstFileNames:
        scpToEx(dstCluster['master']['public_dns'], l, d, user=srcCluster['config']['ssh.user'], options=srcCluster['config']['ssh.options'], log=True)
        ##
        # We are uploading as root, so chown everything to the user that everything in vappio will be done under
        try:
            runSystemInstanceEx(dstCluster['master'],
                                'chown %s %s' % (dstCluster['config']['vappio.user'], d),
                                None,
                                errorPrintS,
                                user=dstCluster['config']['ssh.user'],
                                options=dstCluster['config']['ssh.options'],
                                log=True)
        except ProgramRunError:
            errorPrint('Chown failed on ' + d)
        
    ##
    # return the list of uploaded filenames
Пример #4
0
                    for f in tagData('files')]

    ##
    # Next, lets call 'mkdir -p' on all the dirs we need to make on the destination cluster
    try:
        makeDirsOnCluster(dstCluster, dirNames)
    except TryError, err:
        errorPrint('Caught TryError, ignoring for now: %s - %s ' %
                   (err.msg, str(err.result)))

    ##
    # Now, copy up all of the files
    for l, d in dstFileNames:
        scpToEx(dstCluster['master']['public_dns'],
                l,
                d,
                user=srcCluster['config']['ssh.user'],
                options=srcCluster['config']['ssh.options'],
                log=True)
        ##
        # We are uploading as root, so chown everything to the user that everything in vappio will be done under
        try:
            runSystemInstanceEx(dstCluster['master'],
                                'chown %s %s' %
                                (dstCluster['config']['vappio.user'], d),
                                None,
                                errorPrintS,
                                user=dstCluster['config']['ssh.user'],
                                options=dstCluster['config']['ssh.options'],
                                log=True)
        except ProgramRunError:
            errorPrint('Chown failed on ' + d)