def get_or_create_image(node_driver='fuel_libvirt'): if node_driver == 'fuel_ipmitool': image_name = 'ironic_ubuntu_baremetal' disk_info = settings.IRONIC_GLANCE_DISK_INFO_BAREMETAL else: image_name = 'ironic_ubuntu_virtual' disk_info = settings.IRONIC_GLANCE_DISK_INFO_VIRTUAL try: image = next(x for x in os_conn.glance.images.list() if x['name'] == image_name) except StopIteration: logger.info('Creating %s image', image_name) 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(disk_info)) images.append(image) with file_cache.get_and_unpack(settings.IRONIC_IMAGE_URL) as img: os_conn.glance.images.upload(image.id, img) logger.info('Creating %s image ... done', image_name) return image
def test_no_cache_local_files(tar_gz, clean_cache): cache_before = get_cache_files() path = tar_gz.name with file_cache.get_and_unpack(path) as f: f.read() cache_after = get_cache_files() assert cache_before == cache_after
def test_get_from_url(clean_cache): url = 'http://httpbin.org/get' with file_cache.get_and_unpack(url) as f: content = f.read() assert url in content
def test_read_from_file(tar_gz, clean_cache, content): path = tar_gz.name with file_cache.get_and_unpack(path) as f: result = f.read() assert result == content