def _calc_required_size(context, image, locations): required_size = None if image.size: required_size = image.size * len(locations) else: for location in locations: size_from_backend = None try: if CONF.enabled_backends: size_from_backend = store.get_size_from_uri_and_backend( location['url'], location['metadata'].get('backend'), context=context) else: size_from_backend = store.get_size_from_backend( location['url'], context=context) except (store.UnknownScheme, store.NotFound): pass except store.BadStoreUri: raise exception.BadStoreUri if size_from_backend: required_size = size_from_backend * len(locations) break return required_size
def _calc_required_size(context, image, locations): required_size = None if image.size: required_size = image.size * len(locations) else: for location in locations: size_from_backend = None try: if CONF.enabled_backends: size_from_backend = store.get_size_from_uri_and_backend( location['url'], location['metadata'].get('store'), context=context) else: size_from_backend = store.get_size_from_backend( location['url'], context=context) except (store.UnknownScheme, store.NotFound): pass except store.BadStoreUri: raise exception.BadStoreUri if size_from_backend: required_size = size_from_backend * len(locations) break return required_size
def _set_image_size(context, image, locations): if not image.size: for location in locations: if CONF.enabled_backends: size_from_backend = store.get_size_from_uri_and_backend( location['url'], location['metadata'].get('store'), context=context) else: size_from_backend = store.get_size_from_backend( location['url'], context=context) if size_from_backend: # NOTE(flwang): This assumes all locations have the same size image.size = size_from_backend break
def _set_image_size(context, image, locations): if not image.size: for location in locations: if CONF.enabled_backends: size_from_backend = store.get_size_from_uri_and_backend( location['url'], location['metadata'].get('backend'), context=context) else: size_from_backend = store.get_size_from_backend( location['url'], context=context) if size_from_backend: # NOTE(flwang): This assumes all locations have the same size image.size = size_from_backend break