Change to share access list API
When we do manila access-list, the 'created_at' and 'updated_at' time should be shown to the user. And then the user could determine which is the recent access rule. As designed, the recent access-allow rule caused the error access-status of share instance. The API change [1] has been merged. [1] Iad6070d60ec77b7de9cc9679cfa7478876084da1 Change-Id: I4b10faa18a5e4d7394083cd36851fd0260df86a2 Closes-Bug: #1682795
This commit is contained in:
parent
3229914644
commit
c95a58d65e
@ -27,7 +27,7 @@ from manilaclient import utils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
MAX_VERSION = '2.32'
|
||||
MAX_VERSION = '2.33'
|
||||
MIN_VERSION = '2.0'
|
||||
DEPRECATED_VERSION = '1.0'
|
||||
_VERSIONED_METHOD_MAP = {}
|
||||
|
@ -76,7 +76,7 @@ class ShareAccessReadWriteBase(base.BaseTestCase):
|
||||
|
||||
return access
|
||||
|
||||
@ddt.data("1.0", "2.0", "2.6", "2.7", "2.21")
|
||||
@ddt.data("1.0", "2.0", "2.6", "2.7", "2.21", "2.33")
|
||||
def test_create_list_access_rule_for_share(self, microversion):
|
||||
self.skip_if_microversion_not_supported(microversion)
|
||||
access = self._test_create_list_access_rule_for_share(
|
||||
@ -92,6 +92,11 @@ class ShareAccessReadWriteBase(base.BaseTestCase):
|
||||
self.assertTrue(any(a['access_level'] is not None
|
||||
for a in access_list))
|
||||
if (api_versions.APIVersion(microversion) >=
|
||||
api_versions.APIVersion("2.33")):
|
||||
self.assertTrue(
|
||||
all(('access_key' and 'created_at' and 'updated_at')
|
||||
in a for a in access_list))
|
||||
elif (api_versions.APIVersion(microversion) >=
|
||||
api_versions.APIVersion("2.21")):
|
||||
self.assertTrue(all('access_key' in a for a in access_list))
|
||||
else:
|
||||
@ -133,6 +138,11 @@ class ShareAccessReadWriteBase(base.BaseTestCase):
|
||||
access.get('access_to'))
|
||||
self.assertEqual(self.access_level, access.get('access_level'))
|
||||
if (api_versions.APIVersion(microversion) >=
|
||||
api_versions.APIVersion("2.33")):
|
||||
self.assertIn('access_key', access)
|
||||
self.assertIn('created_at', access)
|
||||
self.assertIn('updated_at', access)
|
||||
elif (api_versions.APIVersion(microversion) >=
|
||||
api_versions.APIVersion("2.21")):
|
||||
self.assertIn('access_key', access)
|
||||
else:
|
||||
@ -145,17 +155,17 @@ class ShareAccessReadWriteBase(base.BaseTestCase):
|
||||
self.assertRaises(tempest_lib_exc.NotFound,
|
||||
self.user_client.get_access, share_id, access['id'])
|
||||
|
||||
@ddt.data("1.0", "2.0", "2.6", "2.7", "2.21")
|
||||
@ddt.data("1.0", "2.0", "2.6", "2.7", "2.21", "2.33")
|
||||
def test_create_delete_ip_access_rule(self, microversion):
|
||||
self._create_delete_access_rule(
|
||||
self.share_id, 'ip', self.access_to['ip'].pop(), microversion)
|
||||
|
||||
@ddt.data("1.0", "2.0", "2.6", "2.7", "2.21")
|
||||
@ddt.data("1.0", "2.0", "2.6", "2.7", "2.21", "2.33")
|
||||
def test_create_delete_user_access_rule(self, microversion):
|
||||
self._create_delete_access_rule(
|
||||
self.share_id, 'user', CONF.username_for_user_rules, microversion)
|
||||
|
||||
@ddt.data("1.0", "2.0", "2.6", "2.7", "2.21")
|
||||
@ddt.data("1.0", "2.0", "2.6", "2.7", "2.21", "2.33")
|
||||
def test_create_delete_cert_access_rule(self, microversion):
|
||||
self._create_delete_access_rule(
|
||||
self.share_id, 'cert', self.access_to['cert'].pop(), microversion)
|
||||
|
@ -1546,7 +1546,7 @@ class ShellTest(test_utils.TestCase):
|
||||
cliutils.print_list.assert_called_with(
|
||||
mock.ANY,
|
||||
['id', 'access_type', 'access_to', 'access_level', 'state',
|
||||
'access_key'])
|
||||
'access_key', 'created_at', 'updated_at'])
|
||||
|
||||
@mock.patch.object(cliutils, 'print_list', mock.Mock())
|
||||
def test_access_list_select_column(self):
|
||||
|
@ -1320,6 +1320,33 @@ def do_access_list(cs, args):
|
||||
cliutils.print_list(access_list, list_of_keys)
|
||||
|
||||
|
||||
@api_versions.wraps("2.33") # noqa
|
||||
@cliutils.arg(
|
||||
'share',
|
||||
metavar='<share>',
|
||||
help='Name or ID of the share.')
|
||||
@cliutils.arg(
|
||||
'--columns',
|
||||
metavar='<columns>',
|
||||
type=str,
|
||||
default=None,
|
||||
help='Comma separated list of columns to be displayed '
|
||||
'example --columns "access_type,access_to".')
|
||||
def do_access_list(cs, args):
|
||||
"""Show access list for share."""
|
||||
list_of_keys = [
|
||||
'id', 'access_type', 'access_to', 'access_level', 'state',
|
||||
'access_key', 'created_at', 'updated_at',
|
||||
]
|
||||
|
||||
if args.columns is not None:
|
||||
list_of_keys = _split_columns(columns=args.columns)
|
||||
|
||||
share = _find_share(cs, args.share)
|
||||
access_list = share.access_list()
|
||||
cliutils.print_list(access_list, list_of_keys)
|
||||
|
||||
|
||||
@api_versions.wraps("2.32")
|
||||
@cliutils.arg(
|
||||
'snapshot',
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- Beginning in version 2.33, share access list API returns
|
||||
"created_at" and "updated_at" for each access rule as part
|
||||
of the JSON response.
|
Loading…
Reference in New Issue
Block a user