예제 #1
0
def bundle(rootfs, size=10, filesystem='ext4'):
    log.debug('getting unique snapshot name')
    app = utils.get_turnkey_version(rootfs)
    snapshot_name = utils.get_uniquename(utils.get_region(), app + '.ebs')
    log.info('target snapshot - %s ', snapshot_name)

    log.info('creating volume, attaching, formatting and mounting')
    volume = Volume()
    volume.create(size)

    device = Device()
    volume.attach(utils.get_instanceid(), device)

    device.mkfs(filesystem)
    mount_path = rootfs + '.mount'
    device.mount(mount_path)

    log.info('syncing rootfs to volume')
    utils.rsync(rootfs, mount_path)

    device.umount()
    volume.detach()
    os.removedirs(mount_path)

    log.info('creating snapshot from volume')
    snapshot = Snapshot()
    snapshot.create(volume.vol.id, snapshot_name)
    volume.delete()

    log.info("complete - %s %s", snapshot.snap.id, snapshot.snap.description)
    return snapshot.snap.id, snapshot.snap.description
예제 #2
0
def bundle(rootfs, region, bucket=None, size=10, filesystem='ext4'):
    _get_amitools_path()
    pems = _get_pem_paths()

    log.info('creating loopback, formatting and mounting')
    image_path = rootfs + '.img'
    image_mount = rootfs + '.img.mount'
    utils.mkdir(image_mount)
    executil.system('dd if=/dev/null of=%s bs=1 seek=%dG' % (image_path, size))
    executil.system('mkfs.' + filesystem, '-F', '-j', image_path)
    executil.system('mount -o loop', image_path, image_mount)

    log.info('syncing rootfs to loopback')
    utils.rsync(rootfs, image_mount)

    log.debug('umounting loopback')
    executil.system('umount', '-d', image_mount)
    os.removedirs(image_mount)

    log.debug('getting unique ami name')
    app = utils.get_turnkey_version(rootfs)
    ami_name = utils.get_uniquename(region, app + '.s3')
    log.info('target ami_name - %s ', ami_name)

    log.info('bundling loopback into ami')
    arch = utils.parse_imagename(ami_name)['architecture']
    _bundle_image(region, image_path, ami_name, arch, pems)
    os.remove(image_path)

    log.info('uploading bundled ami')
    bucket = bucket if bucket else "turnkeylinux-" + region
    _bundle_upload(region, ami_name, bucket)

    log.info("complete - %s %s", bucket, ami_name)
    return bucket, ami_name
예제 #3
0
def bundle(rootfs, region, bucket=None, size=10, filesystem='ext4'):
    _get_amitools_path()
    pems = _get_pem_paths()

    log.info('creating loopback, formatting and mounting')
    image_path = rootfs + '.img'
    image_mount = rootfs + '.img.mount'
    utils.mkdir(image_mount)
    executil.system('dd if=/dev/null of=%s bs=1 seek=%dG' % (image_path, size))
    executil.system('mkfs.' + filesystem, '-F', '-j', image_path)
    executil.system('mount -o loop', image_path, image_mount)

    log.info('syncing rootfs to loopback')
    utils.rsync(rootfs, image_mount)

    log.debug('umounting loopback')
    executil.system('umount', '-d', image_mount)
    os.removedirs(image_mount)

    log.debug('getting unique ami name')
    app = utils.get_turnkey_version(rootfs)
    ami_name = utils.get_uniquename(region, app + '.s3')
    log.info('target ami_name - %s ', ami_name)

    log.info('bundling loopback into ami')
    arch = utils.parse_imagename(ami_name)['architecture']
    _bundle_image(region, image_path, ami_name, arch, pems)
    os.remove(image_path)

    log.info('uploading bundled ami')
    bucket = bucket if bucket else "turnkeylinux-" + region
    _bundle_upload(region, ami_name, bucket)

    log.info("complete - %s %s", bucket, ami_name)
    return bucket, ami_name
예제 #4
0
파일: ebs.py 프로젝트: jstruebel/buildtasks
        if opt == "--publish":
            publish = True

        if opt == "--marketplace":
            marketplace = True

    if len(args) != 1:
        usage("incorrect number of arguments")

    rootfs = args[0]
    if not os.path.exists(rootfs):
        fatal("rootfs path does not exist: %s" % rootfs)

    if not name:
        turnkey_version = utils.get_turnkey_version(rootfs)
        name = '_'.join([turnkey_version, str(int(time.time()))])

    if not virts:
        virts.add('hvm')
        virts.add('pvm')

    for virt in virts:
        if not virt in ('hvm', 'pvm'):
            fatal("virtualization type not supported: %s" % virt)

    arch = utils.get_arch()
    region = utils.get_region()
    snapshot_id, snapshot_name = bundle(rootfs, name)

    if marketplace:
예제 #5
0
        if opt == "--marketplace":
            marketplace = True

        if opt == "--pvmregister":
            pvmregister = True

    if len(args) != 1:
        usage("incorrect number of arguments")

    rootfs = args[0]
    if not os.path.exists(rootfs):
        fatal("rootfs path does not exist: %s" % rootfs)

    if not name:
        turnkey_version = utils.get_turnkey_version(rootfs)
        name = '_'.join([turnkey_version, str(int(time.time()))])

    arch = utils.get_arch()
    region = utils.get_region()
    snapshot_id, snapshot_name = bundle(rootfs, name)
    log.important(' '.join([snapshot_id, arch, region]))

    if marketplace:
        share_marketplace(snapshot_id, region)

    ami_id, ami_name = register(snapshot_id, region, arch)

    log.info(ami_name)
    log.important(' '.join([ami_id, arch, region]))