Merge "Revert "Move vol_db_empty to NFS driver""
This commit is contained in:
commit
c5d7da27ab
@ -46,9 +46,6 @@ class FakeDb(object):
|
|||||||
"""Mock this if you want results from it."""
|
"""Mock this if you want results from it."""
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def volume_get_all(self, *a, **kw):
|
|
||||||
return []
|
|
||||||
|
|
||||||
|
|
||||||
class QuobyteDriverTestCase(test.TestCase):
|
class QuobyteDriverTestCase(test.TestCase):
|
||||||
"""Test case for Quobyte driver."""
|
"""Test case for Quobyte driver."""
|
||||||
|
@ -53,15 +53,12 @@ class WindowsSmbFsTestCase(test.TestCase):
|
|||||||
_FAKE_VOLUME_NAME)
|
_FAKE_VOLUME_NAME)
|
||||||
_FAKE_SHARE_OPTS = '-o username=Administrator,password=12345'
|
_FAKE_SHARE_OPTS = '-o username=Administrator,password=12345'
|
||||||
|
|
||||||
@mock.patch.object(remotefs.RemoteFSDriver,
|
|
||||||
'_check_if_volume_db_is_empty')
|
|
||||||
@mock.patch.object(smbfs, 'utilsfactory')
|
@mock.patch.object(smbfs, 'utilsfactory')
|
||||||
@mock.patch.object(smbfs, 'remotefs_brick')
|
@mock.patch.object(smbfs, 'remotefs_brick')
|
||||||
def setUp(self, mock_remotefs, mock_utilsfactory, mock_is_empty):
|
def setUp(self, mock_remotefs, mock_utilsfactory):
|
||||||
super(WindowsSmbFsTestCase, self).setUp()
|
super(WindowsSmbFsTestCase, self).setUp()
|
||||||
|
|
||||||
self.context = context.get_admin_context()
|
self.context = context.get_admin_context()
|
||||||
mock_is_empty.return_value = None
|
|
||||||
|
|
||||||
self._FAKE_SMBFS_CONFIG = mock.MagicMock(
|
self._FAKE_SMBFS_CONFIG = mock.MagicMock(
|
||||||
smbfs_oversub_ratio = 2,
|
smbfs_oversub_ratio = 2,
|
||||||
|
@ -30,7 +30,6 @@ from oslo_utils import units
|
|||||||
import six
|
import six
|
||||||
|
|
||||||
from cinder import compute
|
from cinder import compute
|
||||||
from cinder import context
|
|
||||||
from cinder import coordination
|
from cinder import coordination
|
||||||
from cinder import db
|
from cinder import db
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
@ -155,39 +154,13 @@ class RemoteFSDriver(driver.BaseVD):
|
|||||||
self.shares = {}
|
self.shares = {}
|
||||||
self._mounted_shares = []
|
self._mounted_shares = []
|
||||||
self._execute_as_root = True
|
self._execute_as_root = True
|
||||||
self._is_voldb_empty_at_startup = self._check_if_volume_db_is_empty()
|
self._is_voldb_empty_at_startup = kwargs.pop('is_vol_db_empty', None)
|
||||||
self._supports_encryption = False
|
self._supports_encryption = False
|
||||||
|
|
||||||
if self.configuration:
|
if self.configuration:
|
||||||
self.configuration.append_config_values(nas_opts)
|
self.configuration.append_config_values(nas_opts)
|
||||||
self.configuration.append_config_values(volume_opts)
|
self.configuration.append_config_values(volume_opts)
|
||||||
|
|
||||||
def _set_voldb_empty_at_startup_indicator(self, ctxt):
|
|
||||||
"""Determine if the Cinder volume DB is empty.
|
|
||||||
|
|
||||||
A check of the volume DB is done to determine whether it is empty or
|
|
||||||
not at this point.
|
|
||||||
|
|
||||||
:param ctxt: our working context
|
|
||||||
"""
|
|
||||||
if not self.db:
|
|
||||||
return False
|
|
||||||
vol_entries = self.db.volume_get_all(ctxt, None, 1, filters=None)
|
|
||||||
|
|
||||||
if len(vol_entries) == 0:
|
|
||||||
LOG.info("Determined volume DB was empty at startup.")
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
LOG.info("Determined volume DB was not empty at startup.")
|
|
||||||
return False
|
|
||||||
|
|
||||||
def _check_if_volume_db_is_empty(self):
|
|
||||||
vol_db_empty = self._set_voldb_empty_at_startup_indicator(
|
|
||||||
context.get_admin_context())
|
|
||||||
LOG.debug("Cinder Volume DB check: vol_db_empty=%s", vol_db_empty)
|
|
||||||
|
|
||||||
return vol_db_empty
|
|
||||||
|
|
||||||
def check_for_setup_error(self):
|
def check_for_setup_error(self):
|
||||||
"""Just to override parent behavior."""
|
"""Just to override parent behavior."""
|
||||||
pass
|
pass
|
||||||
|
@ -215,6 +215,10 @@ class VolumeManager(manager.CleanableManager,
|
|||||||
"configuration to the new path.", volume_driver)
|
"configuration to the new path.", volume_driver)
|
||||||
volume_driver = MAPPING[volume_driver]
|
volume_driver = MAPPING[volume_driver]
|
||||||
|
|
||||||
|
vol_db_empty = self._set_voldb_empty_at_startup_indicator(
|
||||||
|
context.get_admin_context())
|
||||||
|
LOG.debug("Cinder Volume DB check: vol_db_empty=%s", vol_db_empty)
|
||||||
|
|
||||||
# We pass the current setting for service.active_backend_id to
|
# We pass the current setting for service.active_backend_id to
|
||||||
# the driver on init, in case there was a restart or something
|
# the driver on init, in case there was a restart or something
|
||||||
curr_active_backend_id = None
|
curr_active_backend_id = None
|
||||||
@ -246,6 +250,7 @@ class VolumeManager(manager.CleanableManager,
|
|||||||
db=self.db,
|
db=self.db,
|
||||||
host=self.host,
|
host=self.host,
|
||||||
cluster_name=self.cluster,
|
cluster_name=self.cluster,
|
||||||
|
is_vol_db_empty=vol_db_empty,
|
||||||
active_backend_id=curr_active_backend_id)
|
active_backend_id=curr_active_backend_id)
|
||||||
|
|
||||||
if self.cluster and not self.driver.SUPPORTS_ACTIVE_ACTIVE:
|
if self.cluster and not self.driver.SUPPORTS_ACTIVE_ACTIVE:
|
||||||
@ -335,6 +340,23 @@ class VolumeManager(manager.CleanableManager,
|
|||||||
self.stats['pools'][pool]['allocated_capacity_gb'] = pool_sum
|
self.stats['pools'][pool]['allocated_capacity_gb'] = pool_sum
|
||||||
self.stats['allocated_capacity_gb'] += volume['size']
|
self.stats['allocated_capacity_gb'] += volume['size']
|
||||||
|
|
||||||
|
def _set_voldb_empty_at_startup_indicator(self, ctxt):
|
||||||
|
"""Determine if the Cinder volume DB is empty.
|
||||||
|
|
||||||
|
A check of the volume DB is done to determine whether it is empty or
|
||||||
|
not at this point.
|
||||||
|
|
||||||
|
:param ctxt: our working context
|
||||||
|
"""
|
||||||
|
vol_entries = self.db.volume_get_all(ctxt, None, 1, filters=None)
|
||||||
|
|
||||||
|
if len(vol_entries) == 0:
|
||||||
|
LOG.info("Determined volume DB was empty at startup.")
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
LOG.info("Determined volume DB was not empty at startup.")
|
||||||
|
return False
|
||||||
|
|
||||||
def _sync_provider_info(self, ctxt, volumes, snapshots):
|
def _sync_provider_info(self, ctxt, volumes, snapshots):
|
||||||
# NOTE(jdg): For now this just updates provider_id, we can add more
|
# NOTE(jdg): For now this just updates provider_id, we can add more
|
||||||
# items to the update if they're relevant but we need to be safe in
|
# items to the update if they're relevant but we need to be safe in
|
||||||
|
Loading…
x
Reference in New Issue
Block a user