예제 #1
0
def upload_log(app, sys, filename):
    bucket = get_bucket()

    get_bucket(settings.AWS_LOGS_ACCESS_KEY_ID, settings.AWS_LOGS_SECRET_ACCESS_KEY,
               settings.AWS_LOGS_BUCKET_NAME)

    basename = os.path.basename(filename)
    hostname = get_hostname()

    k = Key(bucket)
    k.key = 'milkywhite/' + '_'.join(hostname, app, sys, basename)
    k.set_contents_from_filename(filename)

    print "Upload finished"
예제 #2
0
def install(app, version):
    print "INSTALL " + app, version

    stop_webserver()

    local_dir = os.path.join(settings.APPS_LOCALDIR, app)
    try:
        os.makedirs(local_dir)
    except:
        pass

    localfile = os.path.join(local_dir, app + '.tar.bz2')

    """ Download file form S3 """
    bucket = get_bucket()
    k = Key(bucket)
    k.key = 'applications/' + app + '_' + version + '.tar.bz2'
    k.get_contents_to_file(open(localfile, 'w'))

    """ extract file """
    os.system('cd ' + local_dir + ' && tar -jxvf %s' % app + '.tar.bz2')
    os.unlink(localfile)

    """ Run install scrpt """
    os.system('cd ' + local_dir + ' && /bin/bash mwpackage/install.sh')

    """ write new version to config """
    write_localinfo_new(app, version)
예제 #3
0
def write_versioninfo(content):
    bucket = get_bucket()

    """ write new version.info and a backup file """
    k = Key(bucket)
    k.key = 'version.info'
    k.set_contents_from_string(content)

    k = Key(bucket)
    k.key = 'old/version.info_' + str(int(time()))
    k.set_contents_from_string(content)
예제 #4
0
def upload(group, filename):
    bucket = get_bucket()

    basename = os.path.basename(filename)
    app, version = basename.replace('.tar.bz2', '').split('_')

    k = Key(bucket)
    k.key = 'applications/' + basename
    k.set_contents_from_filename(filename)

    versioninfo_update(group, app, version)
    print "Upload finished"
예제 #5
0
def version(group, app, version):
    bucket = get_bucket()

    list = bucket.list('applications/')

    found = False
    for appentry in list:
        appfile = os.path.basename(appentry.name).replace('.tar.bz2', '')

        s3app, s3version = appfile.split('_')
        if s3app == app and s3version == version:
            found = True

    if found:
        versioninfo_update(group, app, version)
        print "Version change done"
    else:
        print "\nApp '%s' in version '%s' not found!\n" % (app, version)