python-openstackclient 8.3.0__py3-none-any.whl → 9.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. openstackclient/common/module.py +1 -1
  2. openstackclient/common/quota.py +31 -17
  3. openstackclient/compute/v2/server.py +2 -2
  4. openstackclient/identity/common.py +31 -0
  5. openstackclient/identity/v2_0/service.py +3 -1
  6. openstackclient/identity/v3/federation_protocol.py +39 -40
  7. openstackclient/identity/v3/limit.py +85 -84
  8. openstackclient/identity/v3/project.py +181 -112
  9. openstackclient/identity/v3/registered_limit.py +82 -99
  10. openstackclient/identity/v3/tag.py +0 -11
  11. openstackclient/image/v2/image.py +2 -1
  12. openstackclient/tests/functional/identity/v3/test_limit.py +47 -0
  13. openstackclient/tests/functional/image/v2/test_metadef_objects.py +69 -0
  14. openstackclient/tests/functional/volume/v3/test_volume_snapshot.py +46 -132
  15. openstackclient/tests/unit/common/test_quota.py +59 -0
  16. openstackclient/tests/unit/compute/v2/test_server.py +6 -8
  17. openstackclient/tests/unit/identity/v3/test_limit.py +197 -145
  18. openstackclient/tests/unit/identity/v3/test_project.py +831 -512
  19. openstackclient/tests/unit/identity/v3/test_protocol.py +97 -88
  20. openstackclient/tests/unit/identity/v3/test_registered_limit.py +355 -220
  21. openstackclient/tests/unit/image/v2/test_image.py +5 -5
  22. openstackclient/tests/unit/volume/v2/test_consistency_group.py +8 -2
  23. openstackclient/tests/unit/volume/v2/test_volume.py +7 -6
  24. openstackclient/tests/unit/volume/v3/test_volume.py +34 -12
  25. openstackclient/volume/v2/consistency_group.py +8 -8
  26. openstackclient/volume/v2/consistency_group_snapshot.py +2 -2
  27. openstackclient/volume/v2/qos_specs.py +2 -2
  28. openstackclient/volume/v2/volume.py +12 -5
  29. openstackclient/volume/v2/volume_backup.py +2 -2
  30. openstackclient/volume/v2/volume_snapshot.py +2 -2
  31. openstackclient/volume/v2/volume_transfer_request.py +2 -2
  32. openstackclient/volume/v2/volume_type.py +5 -5
  33. openstackclient/volume/v3/volume.py +14 -7
  34. openstackclient/volume/v3/volume_backup.py +2 -2
  35. openstackclient/volume/v3/volume_snapshot.py +2 -2
  36. openstackclient/volume/v3/volume_transfer_request.py +2 -2
  37. openstackclient/volume/v3/volume_type.py +5 -5
  38. {python_openstackclient-8.3.0.dist-info → python_openstackclient-9.0.0.dist-info}/METADATA +1 -1
  39. {python_openstackclient-8.3.0.dist-info → python_openstackclient-9.0.0.dist-info}/RECORD +45 -44
  40. {python_openstackclient-8.3.0.dist-info → python_openstackclient-9.0.0.dist-info}/WHEEL +1 -1
  41. {python_openstackclient-8.3.0.dist-info → python_openstackclient-9.0.0.dist-info}/licenses/AUTHORS +5 -0
  42. python_openstackclient-9.0.0.dist-info/pbr.json +1 -0
  43. python_openstackclient-8.3.0.dist-info/pbr.json +0 -1
  44. {python_openstackclient-8.3.0.dist-info → python_openstackclient-9.0.0.dist-info}/entry_points.txt +0 -0
  45. {python_openstackclient-8.3.0.dist-info → python_openstackclient-9.0.0.dist-info}/licenses/LICENSE +0 -0
  46. {python_openstackclient-8.3.0.dist-info → python_openstackclient-9.0.0.dist-info}/top_level.txt +0 -0
@@ -100,6 +100,53 @@ class LimitTestCase(common.IdentityTests):
100
100
  self.assert_show_fields(items, self.LIMIT_FIELDS)
101
101
  registered_limit_id = self._create_dummy_registered_limit()
102
102
 
103
+ def test_limit_create_with_project_domain(self):
104
+ registered_limit_id = self._create_dummy_registered_limit()
105
+ raw_output = self.openstack(
106
+ f'registered limit show {registered_limit_id}',
107
+ cloud=SYSTEM_CLOUD,
108
+ )
109
+ items = self.parse_show(raw_output)
110
+ service_id = self._extract_value_from_items('service_id', items)
111
+ resource_name = self._extract_value_from_items('resource_name', items)
112
+
113
+ raw_output = self.openstack(f'service show {service_id}')
114
+ items = self.parse_show(raw_output)
115
+ service_name = self._extract_value_from_items('name', items)
116
+
117
+ project_name = self._create_dummy_project()
118
+ raw_output = self.openstack(
119
+ f'project show {project_name}',
120
+ cloud=SYSTEM_CLOUD,
121
+ )
122
+ items = self.parse_show(raw_output)
123
+ domain_id = self._extract_value_from_items('domain_id', items)
124
+
125
+ params = {
126
+ 'project_name': project_name,
127
+ 'project_domain': domain_id,
128
+ 'service_name': service_name,
129
+ 'resource_name': resource_name,
130
+ 'resource_limit': 15,
131
+ }
132
+ raw_output = self.openstack(
133
+ 'limit create'
134
+ ' --project {project_name}'
135
+ ' --project-domain {project_domain}'
136
+ ' --service {service_name}'
137
+ ' --resource-limit {resource_limit}'
138
+ ' {resource_name}'.format(**params),
139
+ cloud=SYSTEM_CLOUD,
140
+ )
141
+ items = self.parse_show(raw_output)
142
+ limit_id = self._extract_value_from_items('id', items)
143
+ self.addCleanup(
144
+ self.openstack, f'limit delete {limit_id}', cloud=SYSTEM_CLOUD
145
+ )
146
+
147
+ self.assert_show_fields(items, self.LIMIT_FIELDS)
148
+ registered_limit_id = self._create_dummy_registered_limit()
149
+
103
150
  def test_limit_create_with_service_id(self):
104
151
  self._create_dummy_limit()
105
152
 
@@ -0,0 +1,69 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+
13
+ from openstackclient.tests.functional import base
14
+
15
+
16
+ class MetadefObjectTests(base.TestCase):
17
+ def setUp(self):
18
+ super().setUp()
19
+ self.obj_name = self.getUniqueString('metadef-obj')
20
+ self.ns_name = self.getUniqueString('metadef-ns')
21
+ self.openstack(f"image metadef namespace create {self.ns_name}")
22
+ self.addCleanup(
23
+ lambda: self.openstack(
24
+ f"image metadef namespace delete {self.ns_name}"
25
+ )
26
+ )
27
+
28
+ def test_metadef_objects(self):
29
+ # CREATE
30
+ created = self.openstack(
31
+ (
32
+ "image metadef object create "
33
+ f"--namespace {self.ns_name} "
34
+ f"{self.obj_name}"
35
+ ),
36
+ parse_output=True,
37
+ )
38
+ self.addCleanup(
39
+ lambda: self.openstack(
40
+ f"image metadef object delete {self.ns_name} {self.obj_name}"
41
+ )
42
+ )
43
+ self.assertEqual(self.obj_name, created["name"])
44
+ self.assertEqual(self.ns_name, created["namespace_name"])
45
+
46
+ # UPDATE
47
+ new_name = f"{self.obj_name}-updated"
48
+ self.openstack(
49
+ "image metadef object update "
50
+ f"{self.ns_name} {self.obj_name} "
51
+ f"--name {new_name}"
52
+ )
53
+ self.obj_name = new_name
54
+
55
+ # READ (get)
56
+ shown = self.openstack(
57
+ f"image metadef object show {self.ns_name} {self.obj_name}",
58
+ parse_output=True,
59
+ )
60
+ self.assertEqual(self.obj_name, shown["name"])
61
+ self.assertEqual(self.ns_name, shown["namespace_name"])
62
+
63
+ # READ (list)
64
+ rows = self.openstack(
65
+ f"image metadef object list {self.ns_name}",
66
+ parse_output=True,
67
+ )
68
+ names = {row["name"] for row in rows}
69
+ self.assertIn(self.obj_name, names)
@@ -23,7 +23,7 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
23
23
  @classmethod
24
24
  def setUpClass(cls):
25
25
  super().setUpClass()
26
- # create a volume for all tests to create snapshot
26
+ # create a test volume used by all snapshot tests
27
27
  cmd_output = cls.openstack(
28
28
  'volume create ' + '--size 1 ' + cls.VOLLY,
29
29
  parse_output=True,
@@ -40,147 +40,57 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
40
40
  finally:
41
41
  super().tearDownClass()
42
42
 
43
- def test_volume_snapshot_delete(self):
44
- """Test create, delete multiple"""
45
- name1 = uuid.uuid4().hex
46
- cmd_output = self.openstack(
47
- 'volume snapshot create ' + name1 + ' --volume ' + self.VOLLY,
48
- parse_output=True,
49
- )
50
- self.assertEqual(
51
- name1,
52
- cmd_output["name"],
53
- )
43
+ def test_volume_snapshot(self):
44
+ # create volume snapshot
45
+ name = uuid.uuid4().hex
54
46
 
55
- name2 = uuid.uuid4().hex
56
47
  cmd_output = self.openstack(
57
- 'volume snapshot create ' + name2 + ' --volume ' + self.VOLLY,
48
+ 'volume snapshot create '
49
+ + '--volume '
50
+ + self.VOLLY
51
+ + ' --description aaaa '
52
+ + '--property Alpha=a '
53
+ + name,
58
54
  parse_output=True,
59
55
  )
60
- self.assertEqual(
61
- name2,
62
- cmd_output["name"],
63
- )
64
-
65
- self.wait_for_status('volume snapshot', name1, 'available')
66
- self.wait_for_status('volume snapshot', name2, 'available')
56
+ snap_id = cmd_output['id']
67
57
 
68
- del_output = self.openstack(
69
- 'volume snapshot delete ' + name1 + ' ' + name2
58
+ self.addCleanup(self.wait_for_delete, 'volume snapshot', snap_id)
59
+ # delete volume snapshot
60
+ self.addCleanup(
61
+ self.openstack,
62
+ 'volume snapshot delete ' + snap_id,
70
63
  )
71
- self.assertOutput('', del_output)
72
- self.wait_for_delete('volume snapshot', name1)
73
- self.wait_for_delete('volume snapshot', name2)
64
+ self.wait_for_status('volume snapshot', snap_id, 'available')
74
65
 
75
- def test_volume_snapshot_list(self):
76
- """Test create, list filter"""
77
- name1 = uuid.uuid4().hex
78
- cmd_output = self.openstack(
79
- 'volume snapshot create ' + name1 + ' --volume ' + self.VOLLY,
66
+ # show volume snapshot
67
+ snapshot_info = self.openstack(
68
+ 'volume snapshot show ' + name,
80
69
  parse_output=True,
81
70
  )
82
- self.addCleanup(self.wait_for_delete, 'volume snapshot', name1)
83
- self.addCleanup(self.openstack, 'volume snapshot delete ' + name1)
84
- self.assertEqual(
85
- name1,
86
- cmd_output["name"],
87
- )
88
- self.assertEqual(
89
- self.VOLUME_ID,
90
- cmd_output["volume_id"],
91
- )
92
- self.assertEqual(
93
- 1,
94
- cmd_output["size"],
95
- )
96
- self.wait_for_status('volume snapshot', name1, 'available')
97
71
 
98
- name2 = uuid.uuid4().hex
99
- cmd_output = self.openstack(
100
- 'volume snapshot create ' + name2 + ' --volume ' + self.VOLLY,
101
- parse_output=True,
102
- )
103
- self.addCleanup(self.wait_for_delete, 'volume snapshot', name2)
104
- self.addCleanup(self.openstack, 'volume snapshot delete ' + name2)
105
- self.assertEqual(
106
- name2,
107
- cmd_output["name"],
108
- )
109
- self.assertEqual(
110
- self.VOLUME_ID,
111
- cmd_output["volume_id"],
112
- )
113
- self.assertEqual(
114
- 1,
115
- cmd_output["size"],
116
- )
117
- self.wait_for_status('volume snapshot', name2, 'available')
118
- raw_output = self.openstack(
119
- 'volume snapshot set ' + '--state error ' + name2
120
- )
121
- self.assertOutput('', raw_output)
72
+ self.assertEqual(name, snapshot_info['name'])
73
+ self.assertEqual('aaaa', snapshot_info["description"])
74
+ self.assertEqual({'Alpha': 'a'}, snapshot_info["properties"])
122
75
 
123
- # Test list --long, --status
76
+ # list volume snapshot --name
124
77
  cmd_output = self.openstack(
125
- 'volume snapshot list ' + '--long ' + '--status error',
78
+ 'volume snapshot list --name ' + name,
126
79
  parse_output=True,
127
80
  )
128
- names = [x["Name"] for x in cmd_output]
129
- self.assertNotIn(name1, names)
130
- self.assertIn(name2, names)
81
+ names = [x['Name'] for x in cmd_output]
82
+ self.assertIn(name, names)
131
83
 
132
- # Test list --volume
84
+ # list volume snapshot --volume
133
85
  cmd_output = self.openstack(
134
86
  'volume snapshot list ' + '--volume ' + self.VOLLY,
135
87
  parse_output=True,
136
88
  )
137
89
  names = [x["Name"] for x in cmd_output]
138
- self.assertIn(name1, names)
139
- self.assertIn(name2, names)
90
+ self.assertIn(name, names)
140
91
 
141
- # Test list --name
142
- cmd_output = self.openstack(
143
- 'volume snapshot list ' + '--name ' + name1,
144
- parse_output=True,
145
- )
146
- names = [x["Name"] for x in cmd_output]
147
- self.assertIn(name1, names)
148
- self.assertNotIn(name2, names)
149
-
150
- def test_volume_snapshot_set(self):
151
- """Test create, set, unset, show, delete volume snapshot"""
152
- name = uuid.uuid4().hex
92
+ # set volume snapshot
153
93
  new_name = name + "_"
154
- cmd_output = self.openstack(
155
- 'volume snapshot create '
156
- + '--volume '
157
- + self.VOLLY
158
- + ' --description aaaa '
159
- + '--property Alpha=a '
160
- + name,
161
- parse_output=True,
162
- )
163
- self.addCleanup(self.wait_for_delete, 'volume snapshot', new_name)
164
- self.addCleanup(self.openstack, 'volume snapshot delete ' + new_name)
165
- self.assertEqual(
166
- name,
167
- cmd_output["name"],
168
- )
169
- self.assertEqual(
170
- 1,
171
- cmd_output["size"],
172
- )
173
- self.assertEqual(
174
- 'aaaa',
175
- cmd_output["description"],
176
- )
177
- self.assertEqual(
178
- {'Alpha': 'a'},
179
- cmd_output["properties"],
180
- )
181
- self.wait_for_status('volume snapshot', name, 'available')
182
-
183
- # Test volume snapshot set
184
94
  raw_output = self.openstack(
185
95
  'volume snapshot set '
186
96
  + '--name '
@@ -188,11 +98,10 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
188
98
  + ' --description bbbb '
189
99
  + '--property Alpha=c '
190
100
  + '--property Beta=b '
191
- + name,
101
+ + snap_id,
192
102
  )
193
103
  self.assertOutput('', raw_output)
194
104
 
195
- # Show snapshot set result
196
105
  cmd_output = self.openstack(
197
106
  'volume snapshot show ' + new_name,
198
107
  parse_output=True,
@@ -201,10 +110,6 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
201
110
  new_name,
202
111
  cmd_output["name"],
203
112
  )
204
- self.assertEqual(
205
- 1,
206
- cmd_output["size"],
207
- )
208
113
  self.assertEqual(
209
114
  'bbbb',
210
115
  cmd_output["description"],
@@ -214,7 +119,7 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
214
119
  cmd_output["properties"],
215
120
  )
216
121
 
217
- # Test volume snapshot unset
122
+ # unset volume snapshot
218
123
  raw_output = self.openstack(
219
124
  'volume snapshot unset ' + '--property Alpha ' + new_name,
220
125
  )
@@ -229,16 +134,25 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
229
134
  cmd_output["properties"],
230
135
  )
231
136
 
232
- # Test volume snapshot set --no-property
137
+ # set volume snapshot --no-property, --state error
233
138
  raw_output = self.openstack(
234
- 'volume snapshot set ' + '--no-property ' + new_name,
139
+ 'volume snapshot set '
140
+ + '--no-property '
141
+ + '--state error '
142
+ + new_name,
235
143
  )
236
144
  self.assertOutput('', raw_output)
145
+
237
146
  cmd_output = self.openstack(
238
147
  'volume snapshot show ' + new_name,
239
148
  parse_output=True,
240
149
  )
241
- self.assertNotIn(
242
- {'Beta': 'b'},
243
- cmd_output["properties"],
150
+ self.assertEqual({}, cmd_output["properties"])
151
+
152
+ # list volume snapshot --long --status
153
+ cmd_output = self.openstack(
154
+ 'volume snapshot list ' + '--long ' + '--status error',
155
+ parse_output=True,
244
156
  )
157
+ names = [x["Name"] for x in cmd_output]
158
+ self.assertIn(new_name, names)
@@ -10,6 +10,7 @@
10
10
  # License for the specific language governing permissions and limitations
11
11
  # under the License.
12
12
 
13
+ import copy
13
14
  from unittest import mock
14
15
 
15
16
  from openstack.block_storage.v3 import quota_set as _volume_quota_set
@@ -1122,6 +1123,64 @@ class TestQuotaShow(TestQuota):
1122
1123
  )
1123
1124
  self.assertNotCalled(self.network_client.get_quota_default)
1124
1125
 
1126
+ def test_quota_show__with_network_and_usage(self):
1127
+ # ensure we do not interfere with other tests
1128
+ self._network_quota_details = copy.deepcopy(
1129
+ self._network_quota_details
1130
+ )
1131
+ # set a couple of resources
1132
+ self._network_quota_details["floating_ips"].update(
1133
+ limit=30, reserved=20, used=7
1134
+ )
1135
+ self._network_quota_details["security_group_rules"].update(
1136
+ limit=9, reserved=7, used=5
1137
+ )
1138
+
1139
+ arglist = [
1140
+ '--network',
1141
+ '--usage',
1142
+ self.projects[0].name,
1143
+ ]
1144
+ verifylist = [
1145
+ ('service', 'network'),
1146
+ ('project', self.projects[0].name),
1147
+ ]
1148
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
1149
+
1150
+ headers, result_gen = self.cmd.take_action(parsed_args)
1151
+
1152
+ self.assertEqual(('Resource', 'Limit', 'In Use', 'Reserved'), headers)
1153
+
1154
+ result = sorted(result_gen)
1155
+
1156
+ self.assertEqual(
1157
+ [
1158
+ ('floating-ips', 30, 7, 20),
1159
+ ('health_monitors', 0, 0, 0),
1160
+ ('l7_policies', 0, 0, 0),
1161
+ ('listeners', 0, 0, 0),
1162
+ ('load_balancers', 0, 0, 0),
1163
+ ('networks', 0, 0, 0),
1164
+ ('pools', 0, 0, 0),
1165
+ ('ports', 0, 0, 0),
1166
+ ('rbac_policies', 0, 0, 0),
1167
+ ('routers', 0, 0, 0),
1168
+ ('secgroup-rules', 9, 5, 7),
1169
+ ('secgroups', 0, 0, 0),
1170
+ ('subnet_pools', 0, 0, 0),
1171
+ ('subnets', 0, 0, 0),
1172
+ ],
1173
+ result,
1174
+ )
1175
+
1176
+ self.compute_client.get_quota_set.assert_not_called()
1177
+ self.volume_sdk_client.get_quota_set.assert_not_called()
1178
+ self.network_client.get_quota.assert_called_once_with(
1179
+ self.projects[0].id,
1180
+ details=True,
1181
+ )
1182
+ self.assertNotCalled(self.network_client.get_quota_default)
1183
+
1125
1184
  def test_quota_show__with_default(self):
1126
1185
  arglist = [
1127
1186
  '--default',
@@ -7896,15 +7896,13 @@ class TestServerResize(compute_fakes.TestComputev2):
7896
7896
  ('server', self.server.id),
7897
7897
  ]
7898
7898
 
7899
- parsed_args = self.check_parser(self.cmd, arglist, verifylist)
7900
- result = self.cmd.take_action(parsed_args)
7901
-
7902
- self.compute_client.find_server.assert_called_once_with(
7903
- self.server.id, ignore_missing=False
7899
+ self.assertRaises(
7900
+ test_utils.ParserException,
7901
+ self.check_parser,
7902
+ self.cmd,
7903
+ arglist,
7904
+ verifylist,
7904
7905
  )
7905
- self.compute_client.find_flavor.assert_not_called()
7906
- self.compute_client.resize_server.assert_not_called()
7907
- self.assertIsNone(result)
7908
7906
 
7909
7907
  def test_server_resize(self):
7910
7908
  arglist = [