Fix handling of share-networks with single_svm drivers
If we create share with share driver that is enabled with "single_svm" mode and provide share network, entity of "share server" will be created and status "ACTIVE" will be set to it, because driver's interface of share-server creation will return "Ok". So, raise error before share server creation if share network provided using "single_svm" mode with any share driver. Change-Id: I4aa8e84659ae428c5155a81c2ff6aab710a7832e Closes-Bug: #1407923
This commit is contained in:
parent
978dd4a8ab
commit
96ba32011a
|
@ -195,6 +195,14 @@ class ShareManager(manager.SchedulerDependentManager):
|
|||
filter_properties = {}
|
||||
|
||||
share_ref = self.db.share_get(context, share_id)
|
||||
share_network_id = share_ref.get('share_network_id', None)
|
||||
|
||||
if share_network_id and self.driver.mode == constants.SINGLE_SVM_MODE:
|
||||
self.db.share_update(context, share_id, {'status': 'error'})
|
||||
raise exception.ManilaException(
|
||||
"Driver with single SVM mode does not expect share-network "
|
||||
"to be provided.")
|
||||
|
||||
if snapshot_id is not None:
|
||||
snapshot_ref = self.db.share_snapshot_get(context, snapshot_id)
|
||||
parent_share_server_id = snapshot_ref['share']['share_server_id']
|
||||
|
@ -202,8 +210,6 @@ class ShareManager(manager.SchedulerDependentManager):
|
|||
snapshot_ref = None
|
||||
parent_share_server_id = None
|
||||
|
||||
share_network_id = share_ref.get('share_network_id', None)
|
||||
|
||||
if parent_share_server_id:
|
||||
try:
|
||||
share_server = self.db.share_server_get(context,
|
||||
|
|
|
@ -460,6 +460,27 @@ class ShareManagerTestCase(test.TestCase):
|
|||
utils.IsAMatcher(models.ShareSnapshot),
|
||||
share_server=None)
|
||||
|
||||
def test_create_share_with_share_network_using_single_svm_driver(self):
|
||||
share_id = 'fake_share_id'
|
||||
share_network_id = 'fake_sn'
|
||||
self.stubs.Set(
|
||||
self.share_manager.db, 'share_get',
|
||||
mock.Mock(return_value=self._create_share(
|
||||
share_network_id=share_network_id)))
|
||||
self.stubs.Set(self.share_manager.db, 'share_update', mock.Mock())
|
||||
self.stubs.Set(
|
||||
self.share_manager.driver, 'mode', constants.SINGLE_SVM_MODE)
|
||||
|
||||
self.assertRaises(
|
||||
exception.ManilaException,
|
||||
self.share_manager.create_share, self.context, share_id)
|
||||
|
||||
self.share_manager.db.share_get.assert_called_once_with(
|
||||
utils.IsAMatcher(context.RequestContext), share_id)
|
||||
self.share_manager.db.share_update.assert_called_once_with(
|
||||
utils.IsAMatcher(context.RequestContext), share_id,
|
||||
{'status': 'error'})
|
||||
|
||||
def test_create_share_with_share_network_server_not_exists(self):
|
||||
"""Test share can be created without share server."""
|
||||
|
||||
|
|
Loading…
Reference in New Issue