Add mount_point_name option for manage shares
Implemented mount_point_name option for share manage API from microversion 2.92. Added mount_point_name set support. Implements: blueprint manage-with-mount-point-name Change-Id: Ifad39b7cbb836723416e403ad5b4bf7fa0bb195d Signed-off-by: eunkyung <ek121.kim@samsung.com>
This commit is contained in:
@@ -27,7 +27,7 @@ from manilaclient import utils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
MAX_VERSION = '2.91'
|
||||
MAX_VERSION = '2.92'
|
||||
MIN_VERSION = '2.0'
|
||||
DEPRECATED_VERSION = '1.0'
|
||||
_VERSIONED_METHOD_MAP = {}
|
||||
|
||||
@@ -1171,6 +1171,15 @@ class AdoptShare(command.ShowOne):
|
||||
'(Default=None)'
|
||||
),
|
||||
)
|
||||
parser.add_argument(
|
||||
'--mount-point-name',
|
||||
metavar="<mount_point_name>",
|
||||
default=None,
|
||||
help=_(
|
||||
'Optional custom export location. Available only for '
|
||||
'microversion >= 2.92. (Default=None)'
|
||||
),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--wait",
|
||||
action='store_true',
|
||||
@@ -1221,6 +1230,15 @@ class AdoptShare(command.ShowOne):
|
||||
'API microversion >= 2.49'
|
||||
)
|
||||
|
||||
if parsed_args.mount_point_name:
|
||||
if share_client.api_version >= api_versions.APIVersion("2.92"):
|
||||
kwargs['mount_point_name'] = parsed_args.mount_point_name
|
||||
else:
|
||||
raise exceptions.CommandError(
|
||||
'Setting share mount point name is available only for '
|
||||
'API microversion >= 2.92'
|
||||
)
|
||||
|
||||
share = share_client.shares.manage(**kwargs)
|
||||
|
||||
if parsed_args.wait:
|
||||
|
||||
@@ -236,6 +236,7 @@ class SharesTest(utils.TestCase):
|
||||
("2.8", "/shares/manage", True),
|
||||
("2.8", "/shares/manage", False),
|
||||
("2.49", "/shares/manage", False, '1234'),
|
||||
("2.92", "/shares/manage", False, None, 'fake_mount_pt1'),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_manage_share(
|
||||
@@ -244,6 +245,7 @@ class SharesTest(utils.TestCase):
|
||||
resource_path,
|
||||
is_public=False,
|
||||
share_server_id=None,
|
||||
mount_point_name=None,
|
||||
):
|
||||
service_host = "fake_service_host"
|
||||
protocol = "fake_protocol"
|
||||
@@ -266,6 +268,9 @@ class SharesTest(utils.TestCase):
|
||||
if version >= api_versions.APIVersion('2.8'):
|
||||
expected_body["is_public"] = is_public
|
||||
|
||||
if version >= api_versions.APIVersion('2.92'):
|
||||
expected_body["mount_point_name"] = mount_point_name
|
||||
|
||||
mock_microversion = mock.Mock(api_version=version)
|
||||
manager = shares.ShareManager(api=mock_microversion)
|
||||
|
||||
@@ -297,6 +302,22 @@ class SharesTest(utils.TestCase):
|
||||
description,
|
||||
is_public,
|
||||
)
|
||||
elif (
|
||||
api_versions.APIVersion('2.49')
|
||||
<= version
|
||||
< api_versions.APIVersion('2.92')
|
||||
):
|
||||
result = manager.manage(
|
||||
service_host,
|
||||
protocol,
|
||||
export_path,
|
||||
driver_options,
|
||||
share_type,
|
||||
name,
|
||||
description,
|
||||
is_public,
|
||||
share_server_id,
|
||||
)
|
||||
else:
|
||||
result = manager.manage(
|
||||
service_host,
|
||||
@@ -308,6 +329,7 @@ class SharesTest(utils.TestCase):
|
||||
description,
|
||||
is_public,
|
||||
share_server_id,
|
||||
mount_point_name,
|
||||
)
|
||||
|
||||
self.assertEqual(manager._create.return_value, result)
|
||||
|
||||
@@ -287,6 +287,7 @@ class ShareManager(base.MetadataCapableManager):
|
||||
description=None,
|
||||
is_public=None,
|
||||
share_server_id=None,
|
||||
mount_point_name=None,
|
||||
resource_path="/shares/manage",
|
||||
):
|
||||
"""Manage some existing share.
|
||||
@@ -300,6 +301,7 @@ class ShareManager(base.MetadataCapableManager):
|
||||
:param description: - description for new share
|
||||
:param is_public: - visibility for new share
|
||||
:param share_server_id: text - id of share server associated with share
|
||||
:param mount_point_name: text - mount point name of share
|
||||
"""
|
||||
driver_options = driver_options if driver_options else dict()
|
||||
body = {
|
||||
@@ -316,6 +318,9 @@ class ShareManager(base.MetadataCapableManager):
|
||||
if is_public is not None:
|
||||
body['is_public'] = is_public
|
||||
|
||||
if mount_point_name is not None:
|
||||
body['mount_point_name'] = mount_point_name
|
||||
|
||||
return self._create(resource_path, {'share': body}, 'share')
|
||||
|
||||
@api_versions.wraps("1.0", "2.6")
|
||||
@@ -386,7 +391,7 @@ class ShareManager(base.MetadataCapableManager):
|
||||
resource_path="/shares/manage",
|
||||
)
|
||||
|
||||
@api_versions.wraps("2.49") # noqa
|
||||
@api_versions.wraps("2.49", "2.91") # noqa
|
||||
def manage( # noqa
|
||||
self,
|
||||
service_host,
|
||||
@@ -412,6 +417,34 @@ class ShareManager(base.MetadataCapableManager):
|
||||
resource_path="/shares/manage",
|
||||
)
|
||||
|
||||
@api_versions.wraps("2.92") # noqa
|
||||
def manage( # noqa
|
||||
self,
|
||||
service_host,
|
||||
protocol,
|
||||
export_path,
|
||||
driver_options=None,
|
||||
share_type=None,
|
||||
name=None,
|
||||
description=None,
|
||||
is_public=False,
|
||||
share_server_id=None,
|
||||
mount_point_name=None,
|
||||
):
|
||||
return self._do_manage(
|
||||
service_host,
|
||||
protocol,
|
||||
export_path,
|
||||
driver_options=driver_options,
|
||||
share_type=share_type,
|
||||
name=name,
|
||||
description=description,
|
||||
is_public=is_public,
|
||||
share_server_id=share_server_id,
|
||||
mount_point_name=mount_point_name,
|
||||
resource_path="/shares/manage",
|
||||
)
|
||||
|
||||
@api_versions.wraps("1.0", "2.6")
|
||||
def unmanage(self, share):
|
||||
"""Unmanage a share.
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
---
|
||||
features:
|
||||
- Updated CLI command for managing shares to accept
|
||||
``mount_point_name`` parameter as a option.
|
||||
Reference in New Issue
Block a user