Skip to content

Commit bc53b05

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Enable specifying domain for group and role commands"
2 parents 7cf7790 + f7feef7 commit bc53b05

5 files changed

Lines changed: 315 additions & 250 deletions

File tree

‎doc/source/command-objects/group.rst‎

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,25 @@ Add user to group
1313
.. code:: bash
1414
1515
os group add user
16+
[--group-domain <group-domain>]
17+
[--user-domain <user-domain>]
1618
<group>
1719
<user>
1820
21+
.. option:: --group-domain <group-domain>
22+
23+
Domain the group belongs to (name or ID). This can be
24+
used in case collisions between group names exist.
25+
26+
.. versionadded:: 3
27+
28+
.. option:: --user-domain <user-domain>
29+
30+
Domain the user belongs to (name or ID). This can be
31+
used in case collisions between user names exist.
32+
33+
.. versionadded:: 3
34+
1935
.. describe:: <group>
2036

2137
Group to contain <user> (name or ID)
@@ -33,9 +49,25 @@ Check user membership in group
3349
.. code:: bash
3450
3551
os group contains user
52+
[--group-domain <group-domain>]
53+
[--user-domain <user-domain>]
3654
<group>
3755
<user>
3856
57+
.. option:: --group-domain <group-domain>
58+
59+
Domain the group belongs to (name or ID). This can be
60+
used in case collisions between group names exist.
61+
62+
.. versionadded:: 3
63+
64+
.. option:: --user-domain <user-domain>
65+
66+
Domain the user belongs to (name or ID). This can be
67+
used in case collisions between user names exist.
68+
69+
.. versionadded:: 3
70+
3971
.. describe:: <group>
4072

4173
Group to check (name or ID)
@@ -106,7 +138,7 @@ List groups
106138
107139
os group list
108140
[--domain <domain>]
109-
[--user <user>]
141+
[--user <user> [--user-domain <user-domain>]]
110142
[--long]
111143
112144
.. option:: --domain <domain>
@@ -117,6 +149,13 @@ List groups
117149
118150
Filter group list by <user> (name or ID)
119151
152+
.. option:: --user-domain <user-domain>
153+
154+
Domain the user belongs to (name or ID). This can be
155+
used in case collisions between user names exist.
156+
157+
.. versionadded:: 3
158+
120159
.. option:: --long
121160
122161
List additional fields in output
@@ -130,9 +169,25 @@ Remove user from group
130169
.. code:: bash
131170
132171
os group remove user
172+
[--group-domain <group-domain>]
173+
[--user-domain <user-domain>]
133174
<group>
134175
<user>
135176
177+
.. option:: --group-domain <group-domain>
178+
179+
Domain the group belongs to (name or ID). This can be
180+
used in case collisions between group names exist.
181+
182+
.. versionadded:: 3
183+
184+
.. option:: --user-domain <user-domain>
185+
186+
Domain the user belongs to (name or ID). This can be
187+
used in case collisions between user names exist.
188+
189+
.. versionadded:: 3
190+
136191
.. describe:: <group>
137192
138193
Group containing <user> (name or ID)
@@ -150,10 +205,15 @@ Set group properties
150205
.. code:: bash
151206
152207
os group set
208+
[--domain <domain>]
153209
[--name <name>]
154210
[--description <description>]
155211
<group>
156212
213+
.. option:: --domain <domain>
214+
215+
Domain containing <group> (name or ID)
216+
157217
.. option:: --name <name>
158218
159219
New group name

‎doc/source/command-objects/role.rst‎

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ List roles
101101
.. code:: bash
102102
103103
os role list
104-
[--domain <domain> | --project <project]
105-
[--user <user> | --group <group>]
104+
--domain <domain> | --project <project> [--project-domain <project-domain>]
105+
--user <user> [--user-domain <user-domain>] | --group <group> [--group-domain <group-domain>]
106106
107107
.. option:: --domain <domain>
108108

@@ -128,6 +128,27 @@ List roles
128128

129129
.. versionadded:: 3
130130

131+
.. option:: --user-domain <user-domain>
132+
133+
Domain the user belongs to (name or ID).
134+
This can be used in case collisions between user names exist.
135+
136+
.. versionadded:: 3
137+
138+
.. option:: --group-domain <group-domain>
139+
140+
Domain the group belongs to (name or ID).
141+
This can be used in case collisions between group names exist.
142+
143+
.. versionadded:: 3
144+
145+
.. option:: --project-domain <project-domain>
146+
147+
Domain the project belongs to (name or ID).
148+
This can be used in case collisions between project names exist.
149+
150+
.. versionadded:: 3
151+
131152
role remove
132153
-----------
133154

@@ -137,8 +158,8 @@ Remove role from domain/project : user/group
137158
.. code:: bash
138159
139160
os role remove
140-
[--domain <domain> | --project <project]
141-
[--user <user> | --group <group>]
161+
--domain <domain> | --project <project> [--project-domain <project-domain>]
162+
--user <user> [--user-domain <user-domain>] | --group <group> [--group-domain <group-domain>]
142163
<role>
143164
144165
.. option:: --domain <domain>
@@ -161,6 +182,27 @@ Remove role from domain/project : user/group
161182

162183
.. versionadded:: 3
163184

185+
.. option:: --user-domain <user-domain>
186+
187+
Domain the user belongs to (name or ID).
188+
This can be used in case collisions between user names exist.
189+
190+
.. versionadded:: 3
191+
192+
.. option:: --group-domain <group-domain>
193+
194+
Domain the group belongs to (name or ID).
195+
This can be used in case collisions between group names exist.
196+
197+
.. versionadded:: 3
198+
199+
.. option:: --project-domain <project-domain>
200+
201+
Domain the project belongs to (name or ID).
202+
This can be used in case collisions between project names exist.
203+
204+
.. versionadded:: 3
205+
164206
.. describe:: <role>
165207

166208
Role to remove (name or ID)

‎openstackclient/identity/common.py‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,32 @@ def find_service(identity_client, name_type_or_id):
4343
raise exceptions.CommandError(msg)
4444

4545

46+
def _get_domain_id_if_requested(identity_client, domain_name_or_id):
47+
if not domain_name_or_id:
48+
return None
49+
domain = find_domain(identity_client, domain_name_or_id)
50+
return domain.id
51+
52+
4653
def find_domain(identity_client, name_or_id):
4754
return _find_identity_resource(identity_client.domains, name_or_id,
4855
domains.Domain)
4956

5057

51-
def find_group(identity_client, name_or_id, domain_id=None):
58+
def find_group(identity_client, name_or_id, domain_name_or_id=None):
59+
domain_id = _get_domain_id_if_requested(identity_client, domain_name_or_id)
5260
return _find_identity_resource(identity_client.groups, name_or_id,
5361
groups.Group, domain_id=domain_id)
5462

5563

56-
def find_project(identity_client, name_or_id, domain_id=None):
64+
def find_project(identity_client, name_or_id, domain_name_or_id=None):
65+
domain_id = _get_domain_id_if_requested(identity_client, domain_name_or_id)
5766
return _find_identity_resource(identity_client.projects, name_or_id,
5867
projects.Project, domain_id=domain_id)
5968

6069

61-
def find_user(identity_client, name_or_id, domain_id=None):
70+
def find_user(identity_client, name_or_id, domain_name_or_id=None):
71+
domain_id = _get_domain_id_if_requested(identity_client, domain_name_or_id)
6272
return _find_identity_resource(identity_client.users, name_or_id,
6373
users.User, domain_id=domain_id)
6474

0 commit comments

Comments
 (0)