def upload_glance_remote_image(file_path, disk_format='raw', container_format='bare', image_name='jeos_remote', timeout=60):
    """ Upload remote glance image file """

    baseTest = BaseTest()
    token = baseTest.token
    endpoint = baseTest.get_service_endpoint('glance')
    endpoint = endpoint.rsplit('/', 1)[0]

    glance = Client('1', endpoint, token)

    meta = {
        'name': image_name,
        'is_public': True,
        'disk_format': disk_format,
        'container_format': container_format,
        'copy_from': file_path,
    }

    start = int(time.time())
    results = glance.images.create(**meta)

    image_id = results.id
   
    ret = baseTest._wait_for_image_status(image_id, 'ACTIVE', timeout)

    image_file = "/var/lib/glance/images/" + image_id
    # Ensure the image has been realy stroed in the glance location
    if ret == 0 and os.path.isfile(image_file):
        # clean the created image
        baseTest.clean_images(image_name)
        return 0
    return 1
def upload_glance_image(file, disk_format='raw', container_format='bare', image_name='jeos1', timeout=60):
    """ Upload glance image file """

    baseTest = BaseTest()
    token = baseTest.token
    endpoint = baseTest.get_service_endpoint('glance')
    endpoint = endpoint.rsplit('/', 1)[0]

    glance = Client('1', endpoint, token)

    start = int(time.time())
    image = glance.images.create(name=image_name, disk_format=disk_format, container_format=container_format, is_public=True)

    image.update(data=open(file, 'rb'))
   
    return baseTest._wait_for_image_status(image.id, 'ACTIVE', 60) 
Пример #3
0
def upload_glance_remote_image(file_path,
                               disk_format='raw',
                               container_format='bare',
                               image_name='jeos_remote',
                               timeout=60):
    """ Upload remote glance image file """

    baseTest = BaseTest()
    token = baseTest.token
    endpoint = baseTest.get_service_endpoint('glance')
    endpoint = endpoint.rsplit('/', 1)[0]

    glance = Client('1', endpoint, token)

    meta = {
        'name': image_name,
        'is_public': True,
        'disk_format': disk_format,
        'container_format': container_format,
        'copy_from': file_path,
    }

    start = int(time.time())
    results = glance.images.create(**meta)

    image_id = results.id

    ret = baseTest._wait_for_image_status(image_id, 'ACTIVE', timeout)

    image_file = "/var/lib/glance/images/" + image_id
    # Ensure the image has been realy stroed in the glance location
    if ret == 0 and os.path.isfile(image_file):
        # clean the created image
        baseTest.clean_images(image_name)
        return 0
    return 1