Merge "Unity: Use job for NFS share creation"

This commit is contained in:
Jenkins 2016-09-01 15:50:28 +00:00 committed by Gerrit Code Review
commit d2201f800b
4 changed files with 53 additions and 13 deletions

View File

@ -69,6 +69,19 @@ class UnityClient(object):
except storops_ex.UnityNfsShareNameExistedError:
return self.get_share(share_name, 'NFS')
@staticmethod
def create_nfs_filesystem_and_share(
pool, nas_server, share_name, size):
"""Create filesystem and share from pool/NAS server.
:param pool: pool for file system creation
:param nas_server: nas server for file system creation
:param share_name: file system and share name
:param size: file system size
"""
pool.create_nfs_share(
nas_server, share_name, size)
def get_share(self, name, share_proto):
# Validate the share protocol
proto = share_proto.upper()

View File

@ -120,17 +120,18 @@ class UnityStorageConnection(driver.StorageConnection):
LOG.error(message)
raise exception.EMCUnityError(err=message)
filesystem = self.client.create_filesystem(
pool, nas_server, share_name, size, proto=proto_enum)
locations = None
if share_proto == 'CIFS':
filesystem = self.client.create_filesystem(
pool, nas_server, share_name,
size, proto=proto_enum)
self.client.create_cifs_share(filesystem, share_name)
locations = self._get_cifs_location(
nas_server.file_interface, share_name)
elif share_proto == 'NFS':
self.client.create_nfs_share(filesystem, share_name)
self.client.create_nfs_filesystem_and_share(
pool, nas_server, share_name, size)
locations = self._get_nfs_location(
nas_server.file_interface, share_name)

View File

@ -148,19 +148,12 @@ test_create_nfs_share:
<<: *nfs_share_base_prop
name: 'cb532599-8dc6-4c3e-bb21-74ea54be566c'
filesystem: &filesystem__test_create_nfs_share
_properties: &filesystem_prop__test_create_nfs_share
<<: *filesystem_base_prop
name: '716100cc-e0b4-416b-ac27-d38dd4587340'
_methods:
create_nfs_share: *nfs_share__test_create_nfs_share
pool: &pool__test_create_nfs_share
_properties:
<<: *pool_base_prop
name: 'Pool_2'
_methods:
create_filesystem: *filesystem__test_create_nfs_share
create_nfs_share: None
unity:
_methods:
@ -803,6 +796,29 @@ test_create_nfs_share__existed_expt:
_methods:
get_nfs_share: *nfs_share__test_create_nfs_share__existed_expt
test_create_nfs_share_batch:
nfs_share: &nfs_share__test_create_nfs_share_batch
_properties:
name: '716100cc-e0b4-416b-ac27-d38dd019330d'
unity:
_methods:
get_nfs_share: *nfs_share__test_create_nfs_share_batch
pool:
_methods:
create_nfs_share:
nas_server:
_properties:
<<: *nas_server_prop
nfs_share:
_properties:
name: '716100cc-e0b4-416b-ac27-d38dd019330d'
size: 151081080
test_get_share_with_invalid_proto:
share:
_properties:

View File

@ -34,11 +34,21 @@ class TestClient(test.TestCase):
def test_create_nfs_share__existed_expt(self, client, mocked_input):
resource = mocked_input['filesystem']
share = mocked_input['nfs_share']
new_share = client.create_nfs_share(resource, share.name)
self.assertEqual(share.name, new_share.name)
@res_mock.mock_client_input
@res_mock.patch_client
def test_create_nfs_filesystem_and_share(self, client, mocked_input):
pool = mocked_input['pool']
nas_server = mocked_input['nas_server']
share = mocked_input['nfs_share']
client.create_nfs_filesystem_and_share(
pool, nas_server, share.name,
share.size)
@res_mock.mock_client_input
@res_mock.patch_client
def test_get_share_with_invalid_proto(self, client, mocked_input):