Merge "libvirt: Log exception when unable to import rbd or rados"

This commit is contained in:
Zuul 2020-10-14 18:02:26 +00:00 committed by Gerrit Code Review
commit 2c3ff1004e
1 changed files with 19 additions and 7 deletions

View File

@ -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.