Merge "Image: Catch glance image not found exception"

This commit is contained in:
Jenkins
2017-05-17 15:56:50 +00:00
committed by Gerrit Code Review

View File

@@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from glanceclient.common import exceptions as glance_exceptions
from oslo_utils import uuidutils from oslo_utils import uuidutils
from zun.common import clients from zun.common import clients
@@ -45,9 +46,13 @@ def find_images(context, image_ident, exact_match):
glance = create_glanceclient(context) glance = create_glanceclient(context)
if uuidutils.is_uuid_like(image_ident): if uuidutils.is_uuid_like(image_ident):
images = [] images = []
image = glance.images.get(image_ident) try:
if image.container_format == 'docker': image = glance.images.get(image_ident)
images.append(image) if image.container_format == 'docker':
images.append(image)
except glance_exceptions.NotFound:
# ignore exception
pass
else: else:
filters = {'container_format': 'docker'} filters = {'container_format': 'docker'}
images = list(glance.images.list(filters=filters)) images = list(glance.images.list(filters=filters))