Handle drivers that do not support list manageable

Listing manageable volumes and snapshots is not a required feature for
drivers and not all of them support it. If a user attempts to list
objects when using a backend that does not support it, they currently
get a somewhat cryptic and internally-exposing error message:

AttributeError: 'RBDDriver' object has no attribute 'get_manageable_snapshots'

This updates the manager to better handle the case where a driver does
not support listing volumes and snapshots.

Closes-bug: #1796784

Change-Id: Ib6cdbe22ad22841c7a166f722eee981913396af4
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
This commit is contained in:
Sean McGinnis 2018-10-09 08:44:17 -05:00
parent fccd84cb2e
commit b07c91abda
No known key found for this signature in database
GPG Key ID: CE7EE4BFAF8D70C8
1 changed files with 6 additions and 0 deletions

View File

@ -2922,6 +2922,9 @@ class VolumeManager(manager.CleanableManager,
if want_objects:
driver_entries = (objects.ManageableVolumeList.
from_primitives(ctxt, driver_entries))
except AttributeError:
LOG.debug('Driver does not support listing manageable volumes.')
return []
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception("Listing manageable volumes failed, due "
@ -4290,6 +4293,9 @@ class VolumeManager(manager.CleanableManager,
if want_objects:
driver_entries = (objects.ManageableSnapshotList.
from_primitives(ctxt, driver_entries))
except AttributeError:
LOG.debug('Driver does not support listing manageable snapshots.')
return []
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception("Listing manageable snapshots failed, due "