Raise a shade exception on broken volumes

Some clouds don't have volumes and bomb out here, which is a bad place
to bomb out. A later patch will add an active check for service
existence, but we still should catch and throw here so that we're not
leaking python-*client exceptions.

Change-Id: I1f768dcd6ad6f54fb1b5638e9486653ee07965ef
This commit is contained in:
Monty Taylor 2015-04-22 20:00:05 -04:00 committed by Davide Guerri
parent 3b64ee66e4
commit 2c4d909111
2 changed files with 19 additions and 7 deletions

View File

@ -839,9 +839,16 @@ class OpenStackCloud(object):
if not cache:
warnings.warn('cache argument to list_volumes is deprecated. Use '
'invalidate instead.')
return meta.obj_list_to_dict(
self.manager.submitTask(_tasks.VolumeList())
)
try:
return meta.obj_list_to_dict(
self.manager.submitTask(_tasks.VolumeList())
)
except Exception as e:
self.log.debug(
"cinder could not list volumes: {message}".format(
message=str(e)),
exc_info=True)
raise OpenStackCloudException("Error fetching volume list")
@_cache_on_arguments()
def list_flavors(self):

View File

@ -15,6 +15,8 @@
import six
from shade import exc
NON_CALLABLES = (six.string_types, bool, dict, int, list, type(None))
@ -126,10 +128,13 @@ def get_hostvars_from_server(cloud, server, mounts=None):
server_vars['image'].pop('links', None)
volumes = []
for volume in cloud.get_volumes(server):
# Make things easier to consume elsewhere
volume['device'] = volume['attachments'][0]['device']
volumes.append(volume)
try:
for volume in cloud.get_volumes(server):
# Make things easier to consume elsewhere
volume['device'] = volume['attachments'][0]['device']
volumes.append(volume)
except exc.OpenStackCloudException:
pass
server_vars['volumes'] = volumes
if mounts:
for mount in mounts: