Esempio n. 1
0
def ubuntu_image_id(os_conn, cleanup):
    image = os_conn.glance.images.create(
        name="image_ubuntu", url=UBUNTU_QCOW2_URL, disk_format='qcow2',
        container_format='bare')
    with file_cache.get_file(UBUNTU_QCOW2_URL) as f:
        os_conn.glance.images.upload(image.id, f)
    return image.id
def ubuntu_image(request, os_conn):
    actions = request.param
    image_name = 'ironic_trusty'

    if 'create' in actions:
        logger.info('Creating ubuntu image')
        image = os_conn.glance.images.create(
            name=image_name,
            disk_format='raw',
            container_format='bare',
            hypervisor_type='baremetal',
            visibility='public',
            cpu_arch='x86_64',
            fuel_disk_info=json.dumps(settings.IRONIC_GLANCE_DISK_INFO))

        with file_cache.get_file(settings.IRONIC_IMAGE_URL) as src:
            with tarfile.open(fileobj=src, mode='r|gz') as tar:
                img = tar.extractfile(tar.firstmember)
                os_conn.glance.images.upload(image.id, img)

        logger.info('Creating ubuntu image ... done')
    else:
        image = os_conn.nova.images.find(name=image_name)

    yield image

    if 'delete' in actions:
        os_conn.glance.images.delete(image.id)
Esempio n. 3
0
    def image(os_conn):

        name = url.split("/")[-1]

        exists = [x for x in os_conn.glance.images.list() if x.name == name]

        if len(exists) > 0:
            image = exists[0]
        else:
            logger.info("Creating {0} image".format(name))
            logger.info("Image source {0}".format(url))
            image = os_conn.glance.images.create(
                name=name, disk_format="qcow2", container_format="bare", visibility="public"
            )

            with file_cache.get_file(url) as f:
                os_conn.glance.images.upload(image.id, f)

            logger.info("Creating {0} image ... done".format(name))

        os_conn.glance.images.update(
            image.id, murano_image_info='{"type": "linux.kubernetes", ' '"title": "%s"}' % name
        )
        yield image

        if len(exists) == 0:
            os_conn.glance.images.delete(image.id)
 def ubuntu_image_id(self, os_conn):
     logger.info('Creating ubuntu image')
     image = os_conn.glance.images.create(name="image_ubuntu",
                                          disk_format='qcow2',
                                          container_format='bare')
     with file_cache.get_file(settings.UBUNTU_QCOW2_URL) as f:
         os_conn.glance.images.upload(image.id, f)
     logger.info('Ubuntu image created')
     yield image.id
     os_conn.glance.images.delete(image.id)
 def create_image(self):
     """Create image
     :return: image object for Glance
     """
     image = self.os_conn.glance.images.create(name="image_ubuntu",
                                               disk_format='qcow2',
                                               container_format='bare')
     with file_cache.get_file(settings.UBUNTU_QCOW2_URL) as f:
         self.os_conn.glance.images.upload(image['id'], f)
     return image
Esempio n. 6
0
def iperf_image_id(os_conn):
    logger.info('Creating ubuntu image')
    image = os_conn.glance.images.create(name="image_ubuntu",
                                         disk_format='qcow2',
                                         container_format='bare')
    with file_cache.get_file(settings.UBUNTU_QCOW2_URL) as f:
        os_conn.glance.images.upload(image.id, f)

    logger.info('Ubuntu image created')
    yield image.id
    os_conn.glance.images.delete(image.id)
def vanilla_image_id(os_conn):
    logger.info('Creating vanilla image')
    image = os_conn.glance.images.create(name="image_vanilla",
                                         url=VANILLA_UBUNTU_QCOW2_URL,
                                         disk_format='qcow2',
                                         container_format='bare')
    with file_cache.get_file(VANILLA_UBUNTU_QCOW2_URL) as f:
        os_conn.glance.images.upload(image.id, f)

    logger.info('Vanilla image created')
    yield image.id
    os_conn.glance.images.delete(image.id)
Esempio n. 8
0
def env2_ubuntu_image(env2, image_file):
    image_name = 'ironic_trusty'

    logger.info('Creating ubuntu image')
    image = env2.os_conn.glance.images.create(
        name=image_name,
        disk_format='raw',
        container_format='bare',
        hypervisor_type='baremetal',
        visibility='public',
        cpu_arch='x86_64',
        fuel_disk_info=json.dumps(settings.IRONIC_GLANCE_DISK_INFO))

    with file_cache.get_file(settings.IRONIC_IMAGE_URL) as src:
        with tarfile.open(fileobj=src, mode='r|gz') as tar:
            img = tar.extractfile(tar.firstmember)
            env2.os_conn.glance.images.upload(image.id, img)

    logger.info('Creating ubuntu image ... done')

    yield image

    env2.os_conn.glance.images.delete(image.id)
def env2_ubuntu_image(env2, image_file):
    image_name = 'ironic_trusty'

    logger.info('Creating ubuntu image')
    image = env2.os_conn.glance.images.create(
        name=image_name,
        disk_format='raw',
        container_format='bare',
        hypervisor_type='baremetal',
        visibility='public',
        cpu_arch='x86_64',
        fuel_disk_info=json.dumps(settings.IRONIC_GLANCE_DISK_INFO))

    with file_cache.get_file(settings.IRONIC_IMAGE_URL) as src:
        with tarfile.open(fileobj=src, mode='r|gz') as tar:
            img = tar.extractfile(tar.firstmember)
            env2.os_conn.glance.images.upload(image.id, img)

    logger.info('Creating ubuntu image ... done')

    yield image

    env2.os_conn.glance.images.delete(image.id)
def env2_ubuntu_image(env2):
    image_name = "ironic_trusty"

    logger.info("Creating ubuntu image")
    image = env2.os_conn.glance.images.create(
        name=image_name,
        disk_format="raw",
        container_format="bare",
        hypervisor_type="baremetal",
        visibility="public",
        cpu_arch="x86_64",
        fuel_disk_info=json.dumps(settings.IRONIC_GLANCE_DISK_INFO),
    )

    with file_cache.get_file(settings.IRONIC_IMAGE_URL) as src:
        with tarfile.open(fileobj=src, mode="r|gz") as tar:
            img = tar.extractfile(tar.firstmember)
            env2.os_conn.glance.images.upload(image.id, img)

    logger.info("Creating ubuntu image ... done")

    yield image

    env2.os_conn.glance.images.delete(image.id)