commit aa16dd09ebeb21d0b81682b0b6026de0fe4f23b7 Author: Lee Yarwood Date: Wed Aug 19 10:57:25 2020 +0100 libvirt: Log exception when unable to import rbd or rados This should help provide some context when the RbdDriver later raises a RuntimeError if rbd or rados hasn't been imported correctly. Change-Id: Ie8bb5e5622bd37dfe8073cca12f77174e8e7d98c diff --git a/nova/storage/rbd_utils.py b/nova/storage/rbd_utils.py index 22bafe5..b22d9ac 100644 --- a/nova/storage/rbd_utils.py +++ b/nova/storage/rbd_utils.py @@ -17,13 +17,6 @@ from eventlet import tpool from six.moves import urllib -try: - import rados - import rbd -except ImportError: - rados = None - rbd = None - from oslo_concurrency import processutils from oslo_log import log as logging from oslo_serialization import jsonutils @@ -42,6 +35,25 @@ LOG = logging.getLogger(__name__) RESIZE_SNAPSHOT_NAME = 'nova-resize' +# NOTE(lyarwood): Log exceptions if we fail to import rbd or rados in order to +# provide context later if we end up attempting to use the RbdDriver and +# raising RuntimeError +try: + import rados +except ImportError: + rados = None + LOG.exception( + "Unable to import the rados module, this can be ignored if Ceph is " + "not used within this environment") + +try: + import rbd +except ImportError: + rbd = None + LOG.exception( + "Unable to import the rbd module, this can be ignored if Ceph is not " + "used within this environment") + class RbdProxy(object): """A wrapper around rbd.RBD class instance to avoid blocking of process.