From e4edf76825c351cde2a486dbefed2a00211c5055 Mon Sep 17 00:00:00 2001 From: Eunkyung99 Date: Tue, 2 Dec 2025 10:39:38 +0900 Subject: [PATCH] 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 --- manilaclient/api_versions.py | 2 +- manilaclient/osc/v2/share.py | 18 ++++++++++ manilaclient/tests/unit/v2/test_shares.py | 22 ++++++++++++ manilaclient/v2/shares.py | 35 ++++++++++++++++++- ...ith-mount-point-name-69be3a8aa4fcaa1f.yaml | 4 +++ 5 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/bp-manage-with-mount-point-name-69be3a8aa4fcaa1f.yaml diff --git a/manilaclient/api_versions.py b/manilaclient/api_versions.py index 09eb8fd1f..73601af29 100644 --- a/manilaclient/api_versions.py +++ b/manilaclient/api_versions.py @@ -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 = {} diff --git a/manilaclient/osc/v2/share.py b/manilaclient/osc/v2/share.py index de2698945..c32e9ce2f 100644 --- a/manilaclient/osc/v2/share.py +++ b/manilaclient/osc/v2/share.py @@ -1171,6 +1171,15 @@ class AdoptShare(command.ShowOne): '(Default=None)' ), ) + parser.add_argument( + '--mount-point-name', + metavar="", + 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: diff --git a/manilaclient/tests/unit/v2/test_shares.py b/manilaclient/tests/unit/v2/test_shares.py index 1ee494111..038e202a6 100644 --- a/manilaclient/tests/unit/v2/test_shares.py +++ b/manilaclient/tests/unit/v2/test_shares.py @@ -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) diff --git a/manilaclient/v2/shares.py b/manilaclient/v2/shares.py index 73c2f8a05..a48fce686 100644 --- a/manilaclient/v2/shares.py +++ b/manilaclient/v2/shares.py @@ -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. diff --git a/releasenotes/notes/bp-manage-with-mount-point-name-69be3a8aa4fcaa1f.yaml b/releasenotes/notes/bp-manage-with-mount-point-name-69be3a8aa4fcaa1f.yaml new file mode 100644 index 000000000..d8f708174 --- /dev/null +++ b/releasenotes/notes/bp-manage-with-mount-point-name-69be3a8aa4fcaa1f.yaml @@ -0,0 +1,4 @@ +--- +features: + - Updated CLI command for managing shares to accept + ``mount_point_name`` parameter as a option.