Merge "Fix pylxd hard dependencies"
This commit is contained in:
commit
cd72947258
|
@ -25,14 +25,30 @@ import re
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from pylxd import api as lxd_api
|
# NOTE(tbarron): pylxd module is unavailable in some distribtutions so
|
||||||
from pylxd import exceptions as pylxd_exc
|
# handle this circumstance gracefully. Also handle failure to import
|
||||||
|
# pylxd_exc directly in versions >= pylxd 2.
|
||||||
|
try:
|
||||||
|
from pylxd import api as lxd_api
|
||||||
|
try:
|
||||||
|
from pylxd import exceptions as pylxd_exc
|
||||||
|
NO_LXD = False
|
||||||
|
except ImportError:
|
||||||
|
try:
|
||||||
|
# pylint: disable=E0611
|
||||||
|
from pylxd.deprecated import exceptions as pylxd_exc
|
||||||
|
NO_LXD = False
|
||||||
|
except ImportError:
|
||||||
|
NO_LXD = True
|
||||||
|
except ImportError:
|
||||||
|
NO_LXD = True
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from manila.common import constants as const
|
from manila.common import constants as const
|
||||||
from manila import context
|
from manila import context
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila.i18n import _
|
from manila.i18n import _
|
||||||
|
from manila.i18n import _LI
|
||||||
from manila.i18n import _LW
|
from manila.i18n import _LW
|
||||||
from manila.share import driver
|
from manila.share import driver
|
||||||
from manila import utils
|
from manila import utils
|
||||||
|
@ -92,6 +108,10 @@ CONF.register_opts(lv_opts)
|
||||||
class LXDHelper(object):
|
class LXDHelper(object):
|
||||||
|
|
||||||
def __init__(self, lxd_api, config):
|
def __init__(self, lxd_api, config):
|
||||||
|
if NO_LXD:
|
||||||
|
LOG.info(_LI('pylxd modules are not present on this system: LXD '
|
||||||
|
'driver will not function.'))
|
||||||
|
return
|
||||||
super(LXDHelper, self).__init__()
|
super(LXDHelper, self).__init__()
|
||||||
self.api = lxd_api
|
self.api = lxd_api
|
||||||
self.conf = config
|
self.conf = config
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
import functools
|
import functools
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
import testtools
|
||||||
|
|
||||||
from manila.common import constants as const
|
from manila.common import constants as const
|
||||||
from manila import context
|
from manila import context
|
||||||
|
@ -28,7 +29,6 @@ from manila.tests.db import fakes as db_fakes
|
||||||
from manila.tests import fake_utils
|
from manila.tests import fake_utils
|
||||||
from manila import utils
|
from manila import utils
|
||||||
|
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,6 +71,7 @@ def fake_network(**kwargs):
|
||||||
return db_fakes.FakeModel(network)
|
return db_fakes.FakeModel(network)
|
||||||
|
|
||||||
|
|
||||||
|
@testtools.skipIf(lxd.NO_LXD, "pylxd is unavailable")
|
||||||
class LXDHelperTestCase(test.TestCase):
|
class LXDHelperTestCase(test.TestCase):
|
||||||
"""Tests LXDUnfs3Helper"""
|
"""Tests LXDUnfs3Helper"""
|
||||||
|
|
||||||
|
@ -219,6 +220,7 @@ class LXDHelperTestCase(test.TestCase):
|
||||||
fake_stream.close.assert_called_once_with()
|
fake_stream.close.assert_called_once_with()
|
||||||
|
|
||||||
|
|
||||||
|
@testtools.skipIf(lxd.NO_LXD, "pylxd is unavailable")
|
||||||
class LXDUnfs3HelperTestCase(test.TestCase):
|
class LXDUnfs3HelperTestCase(test.TestCase):
|
||||||
"""Tests LXDUnfs3Helper"""
|
"""Tests LXDUnfs3Helper"""
|
||||||
|
|
||||||
|
@ -432,6 +434,7 @@ class LXDUnfs3HelperTestCase(test.TestCase):
|
||||||
self.assertFalse(self.UNFS3Helper._deny_access.called)
|
self.assertFalse(self.UNFS3Helper._deny_access.called)
|
||||||
|
|
||||||
|
|
||||||
|
@testtools.skipIf(lxd.NO_LXD, "pylxd is unavailable")
|
||||||
class LXDCIFSHelperTestCase(test.TestCase):
|
class LXDCIFSHelperTestCase(test.TestCase):
|
||||||
"""Tests LXDCIFSHelper"""
|
"""Tests LXDCIFSHelper"""
|
||||||
|
|
||||||
|
@ -671,6 +674,7 @@ class LXDCIFSHelperTestCase(test.TestCase):
|
||||||
self.assertFalse(self.CIFSHelper._deny_access.called)
|
self.assertFalse(self.CIFSHelper._deny_access.called)
|
||||||
|
|
||||||
|
|
||||||
|
@testtools.skipIf(lxd.NO_LXD, "pylxd is unavailable")
|
||||||
class LXDDriverTestCase(test.TestCase):
|
class LXDDriverTestCase(test.TestCase):
|
||||||
"""Tests LXDDriver."""
|
"""Tests LXDDriver."""
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue