Skip to content

Commit e8509d8

Browse files
author
Miguel Lavalle
committed
Add 'address_group' type support to rbac commands
Depends-On: https://review.opendev.org/c/openstack/neutron/+/772460 Change-Id: Icd5e96d180364b979d1e93fcb39f9133a41a06e5
1 parent 01a53fa commit e8509d8

3 files changed

Lines changed: 23 additions & 9 deletions

File tree

openstackclient/network/v2/network_rbac.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ def _get_attrs(client_manager, parsed_args):
6060
object_id = network_client.find_subnet_pool(
6161
parsed_args.rbac_object,
6262
ignore_missing=False).id
63+
if parsed_args.type == 'address_group':
64+
object_id = network_client.find_address_group(
65+
parsed_args.rbac_object,
66+
ignore_missing=False).id
6367

6468
attrs['object_id'] = object_id
6569

@@ -100,11 +104,12 @@ def get_parser(self, prog_name):
100104
'--type',
101105
metavar="<type>",
102106
required=True,
103-
choices=['address_scope', 'security_group', 'subnetpool',
104-
'qos_policy', 'network'],
107+
choices=['address_group', 'address_scope', 'security_group',
108+
'subnetpool', 'qos_policy', 'network'],
105109
help=_('Type of the object that RBAC policy '
106-
'affects ("address_scope", "security_group", "subnetpool",'
107-
' "qos_policy" or "network")')
110+
'affects ("address_group", "address_scope", '
111+
'"security_group", "subnetpool", "qos_policy" or '
112+
'"network")')
108113
)
109114
parser.add_argument(
110115
'--action',
@@ -193,11 +198,12 @@ def get_parser(self, prog_name):
193198
parser.add_argument(
194199
'--type',
195200
metavar='<type>',
196-
choices=['address_scope', 'security_group', 'subnetpool',
197-
'qos_policy', 'network'],
201+
choices=['address_group', 'address_scope', 'security_group',
202+
'subnetpool', 'qos_policy', 'network'],
198203
help=_('List network RBAC policies according to '
199-
'given object type ("address_scope", "security_group", '
200-
'"subnetpool", "qos_policy" or "network")')
204+
'given object type ("address_group", "address_scope", '
205+
'"security_group", "subnetpool", "qos_policy" or '
206+
'"network")')
201207
)
202208
parser.add_argument(
203209
'--action',

openstackclient/tests/unit/network/v2/test_network_rbac.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class TestCreateNetworkRBAC(TestNetworkRBAC):
4242
sg_object = network_fakes.FakeNetworkSecGroup.create_one_security_group()
4343
as_object = network_fakes.FakeAddressScope.create_one_address_scope()
4444
snp_object = network_fakes.FakeSubnetPool.create_one_subnet_pool()
45+
ag_object = network_fakes.FakeAddressGroup.create_one_address_group()
4546
project = identity_fakes_v3.FakeProject.create_one_project()
4647
rbac_policy = network_fakes.FakeNetworkRBAC.create_one_network_rbac(
4748
attrs={'tenant_id': project.id,
@@ -85,6 +86,8 @@ def setUp(self):
8586
return_value=self.as_object)
8687
self.network.find_subnet_pool = mock.Mock(
8788
return_value=self.snp_object)
89+
self.network.find_address_group = mock.Mock(
90+
return_value=self.ag_object)
8891
self.projects_mock.get.return_value = self.project
8992

9093
def test_network_rbac_create_no_type(self):
@@ -236,7 +239,8 @@ def test_network_rbac_create_all_options(self):
236239
('qos_policy', "qos_object"),
237240
('security_group', "sg_object"),
238241
('subnetpool', "snp_object"),
239-
('address_scope', "as_object")
242+
('address_scope', "as_object"),
243+
('address_group', "ag_object")
240244
)
241245
@ddt.unpack
242246
def test_network_rbac_create_object(self, obj_type, obj_fake_attr):
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
features:
2+
- |
3+
Add ``address_group`` as a valid ``--type`` value for the
4+
``network rbac create`` and ``network rbac list`` commands.

0 commit comments

Comments
 (0)