Catch exception in volume get

Server return 500 when creating a container with non-existing volume
uuid in current version. We should add exception handler in volume get.

Change-Id: I5920a3a51b7c8d78f516b947045235ddd78e729c
Closes-Bug: #1742346
This commit is contained in:
miaohb 2018-01-22 00:22:36 -08:00
parent d53aa2d2dc
commit 6281d7aa6f
1 changed files with 4 additions and 1 deletions

View File

@ -42,7 +42,10 @@ class CinderAPI(object):
def search_volume(self, volume):
if uuidutils.is_uuid_like(volume):
volume = self.cinder.volumes.get(volume)
try:
volume = self.cinder.volumes.get(volume)
except cinder_exception.NotFound:
raise exception.VolumeNotFound(volume=volume)
else:
try:
volume = self.cinder.volumes.find(name=volume)