Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
use cluster client to check vserver exists before using vserver client

Change-Id: I80f1e802ddd9c90225b39f1a5e2e9df866cb4936
  • Loading branch information
Carthaca committed Mar 21, 2022
1 parent 1eb4928 commit 01b9d7c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,17 @@ def _get_vserver(self, share_server=None, vserver_name=None,
msg = _('Share server or vserver name not provided')
raise exception.InvalidInput(reason=msg)

if not reexport:
if not self._client.vserver_exists(vserver):
raise exception.VserverNotFound(vserver=vserver)

if backend_name:
vserver_client = data_motion.get_client_for_backend(
backend_name, vserver
)
else:
vserver_client = self._get_api_client(vserver)

if not reexport:
if not vserver_client.vserver_exists(vserver):
raise exception.VserverNotFound(vserver=vserver)

return vserver, vserver_client

def _get_ems_pool_info(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,21 +221,15 @@ def test_get_vserver_no_share_server(self):
self.library._get_vserver)

def test_get_vserver_no_share_server_with_vserver_name(self):
self.library._client.vserver_exists.return_value = True
fake_vserver_client = mock.Mock()

mock_vserver_exists = self.mock_object(
fake_vserver_client, 'vserver_exists',
mock.Mock(return_value=True))
self.mock_object(self.library,
'_get_api_client',
mock.Mock(return_value=fake_vserver_client))

result_vserver, result_vserver_client = self.library._get_vserver(
share_server=None, vserver_name=fake.VSERVER1)

mock_vserver_exists.assert_called_once_with(
fake.VSERVER1
)
self.assertEqual(fake.VSERVER1, result_vserver)
self.assertEqual(fake_vserver_client, result_vserver_client)

Expand Down Expand Up @@ -281,11 +275,7 @@ def test_get_vserver_none_vserver(self):

def test_get_vserver_not_found(self):

mock_client = mock.Mock()
mock_client.vserver_exists.return_value = False
self.mock_object(self.library,
'_get_api_client',
mock.Mock(return_value=mock_client))
self.library._client.vserver_exists.return_value = False
kwargs = {'share_server': fake.SHARE_SERVER}

self.assertRaises(exception.VserverNotFound,
Expand Down

0 comments on commit 01b9d7c

Please sign in to comment.