Add access key column to rules table

To align with the functionality offered by the CLI, this patch
adds an "Access Key" column to the rules table.

The access key is also added to the share details overview.

For completeness, also the access level and the state are now
listed in the details overview.

Change-Id: I38516e453e300b4c08a7da5de4acf09d2bdac4d2
Closes-Bug: #1638934
This commit is contained in:
Arne Wiebalck 2016-11-04 11:43:07 +01:00
parent 5d9ce74c40
commit 1e6f23cd7c
4 changed files with 27 additions and 7 deletions

View File

@ -281,6 +281,7 @@ class RulesTable(tables.DataTable):
access_level = tables.Column( access_level = tables.Column(
"access_level", verbose_name=_("Access Level")) "access_level", verbose_name=_("Access Level"))
status = tables.Column("state", verbose_name=_("Status")) status = tables.Column("state", verbose_name=_("Status"))
access_key = tables.Column("access_key", verbose_name=_("Access Key"))
def get_object_display(self, obj): def get_object_display(self, obj):
return obj.id return obj.id

View File

@ -76,7 +76,12 @@
<dl class="dl-horizontal"> <dl class="dl-horizontal">
{% for rule in share.rules %} {% for rule in share.rules %}
<dt>{{ rule.access_type }}</dt> <dt>{{ rule.access_type }}</dt>
<dd>{{ rule.access_to }}</dd> <dd><p>
<div><b>Access to: </b>{{ rule.access_to }}</div>
<div><b>Access Level: </b>{{ rule.access_level }}</div>
<div><b>Status: </b>{{ rule.state }}</div>
<div><b>Access Key: </b>{{ rule.access_key }}</div>
</p></dd>
{% endfor %} {% endfor %}
</dl> </dl>
</div> </div>

View File

@ -211,7 +211,20 @@ class ShareViewTests(test.TestCase):
2, 200) 2, 200)
for rule in rules: for rule in rules:
self.assertContains(res, "<dt>%s</dt>" % rule.access_type, 1, 200) self.assertContains(res, "<dt>%s</dt>" % rule.access_type, 1, 200)
self.assertContains(res, "<dd>%s</dd>" % rule.access_to, 1, 200) self.assertContains(
res, "<div><b>Access to: </b>%s</div>" % rule.access_to,
1, 200)
if 'cephx' == rule.access_type:
self.assertContains(
res, "<div><b>Access Key: </b>%s</div>" % rule.access_key,
1, 200)
self.assertContains(
res, "<div><b>Access Key: </b></div>",
len(rules) - sum(r.access_type == 'cephx' for r in rules), 200)
self.assertContains(
res, "<div><b>Access Level: </b>rw</div>", len(rules), 200)
self.assertContains(
res, "<div><b>Status: </b>active</div>", len(rules), 200)
self.assertNoMessages() self.assertNoMessages()
api_manila.share_rules_list.assert_called_once_with( api_manila.share_rules_list.assert_called_once_with(
mock.ANY, self.share.id) mock.ANY, self.share.id)

View File

@ -160,15 +160,16 @@ user_export_location = share_export_locations.ShareExportLocation(
export_locations = [admin_export_location, user_export_location] export_locations = [admin_export_location, user_export_location]
rule = collections.namedtuple('Access', ['access_type', 'access_to', 'status', rule = collections.namedtuple('Access', ['access_type', 'access_to', 'state',
'id']) 'id', 'access_level', 'access_key'])
user_rule = rule('user', 'someuser', 'active', user_rule = rule('user', 'someuser', 'active',
'10837072-c49e-11e3-bd64-60a44c371189') '10837072-c49e-11e3-bd64-60a44c371189', 'rw', '')
ip_rule = rule('ip', '1.1.1.1', 'active', ip_rule = rule('ip', '1.1.1.1', 'active',
'2cc8e2f8-c49e-11e3-bd64-60a44c371189') '2cc8e2f8-c49e-11e3-bd64-60a44c371189', 'rw', '')
cephx_rule = rule('cephx', 'alice', 'active', cephx_rule = rule('cephx', 'alice', 'active',
'235481bc-1a84-11e6-9666-68f728a0492e') '235481bc-1a84-11e6-9666-68f728a0492e', 'rw',
'AQAdFCNYDCapMRAANuK/CiEZbog2911a+t5dcQ==')
snapshot = share_snapshots.ShareSnapshot( snapshot = share_snapshots.ShareSnapshot(
share_snapshots.ShareSnapshotManager(FakeAPIClient), share_snapshots.ShareSnapshotManager(FakeAPIClient),