python-openstackclient 8.0.0__py3-none-any.whl → 8.1.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.
- openstackclient/compute/client.py +5 -0
- openstackclient/compute/v2/console.py +7 -0
- openstackclient/compute/v2/console_connection.py +48 -0
- openstackclient/compute/v2/keypair.py +10 -3
- openstackclient/compute/v2/server.py +75 -10
- openstackclient/compute/v2/server_event.py +1 -1
- openstackclient/identity/common.py +79 -0
- openstackclient/identity/v3/application_credential.py +2 -2
- openstackclient/identity/v3/domain.py +62 -43
- openstackclient/identity/v3/group.py +113 -68
- openstackclient/identity/v3/project.py +17 -0
- openstackclient/identity/v3/user.py +38 -5
- openstackclient/image/client.py +5 -0
- openstackclient/image/v2/image.py +11 -11
- openstackclient/network/client.py +0 -6
- openstackclient/network/v2/floating_ip.py +58 -29
- openstackclient/network/v2/network_qos_rule.py +3 -11
- openstackclient/network/v2/router.py +1 -1
- openstackclient/network/v2/security_group.py +5 -4
- openstackclient/network/v2/security_group_rule.py +1 -1
- openstackclient/shell.py +1 -1
- openstackclient/tests/functional/base.py +5 -1
- openstackclient/tests/functional/compute/v2/test_keypair.py +41 -5
- openstackclient/tests/unit/compute/v2/fakes.py +81 -305
- openstackclient/tests/unit/compute/v2/test_console.py +18 -1
- openstackclient/tests/unit/compute/v2/test_console_connection.py +72 -0
- openstackclient/tests/unit/compute/v2/test_flavor.py +1 -1
- openstackclient/tests/unit/compute/v2/test_keypair.py +12 -5
- openstackclient/tests/unit/compute/v2/test_server.py +169 -46
- openstackclient/tests/unit/compute/v2/test_server_backup.py +32 -71
- openstackclient/tests/unit/compute/v2/test_server_event.py +2 -2
- openstackclient/tests/unit/compute/v2/test_server_image.py +33 -72
- openstackclient/tests/unit/compute/v2/test_server_migration.py +4 -4
- openstackclient/tests/unit/identity/v3/test_application_credential.py +47 -25
- openstackclient/tests/unit/identity/v3/test_domain.py +115 -105
- openstackclient/tests/unit/identity/v3/test_group.py +353 -202
- openstackclient/tests/unit/identity/v3/test_project.py +16 -0
- openstackclient/tests/unit/identity/v3/test_user.py +86 -6
- openstackclient/tests/unit/image/v1/test_image.py +8 -9
- openstackclient/tests/unit/image/v2/test_image.py +49 -49
- openstackclient/tests/unit/network/v2/fakes.py +405 -485
- openstackclient/tests/unit/network/v2/test_floating_ip_network.py +13 -19
- openstackclient/tests/unit/network/v2/test_l3_conntrack_helper.py +2 -2
- openstackclient/tests/unit/network/v2/test_ndp_proxy.py +1 -3
- openstackclient/tests/unit/network/v2/test_network.py +4 -4
- openstackclient/tests/unit/network/v2/test_network_agent.py +15 -29
- openstackclient/tests/unit/network/v2/test_network_qos_policy.py +16 -19
- openstackclient/tests/unit/network/v2/test_network_qos_rule.py +79 -152
- openstackclient/tests/unit/network/v2/test_network_qos_rule_type.py +4 -6
- openstackclient/tests/unit/network/v2/test_network_rbac.py +2 -2
- openstackclient/tests/unit/network/v2/test_port.py +17 -17
- openstackclient/tests/unit/network/v2/test_router.py +73 -57
- openstackclient/tests/unit/network/v2/test_security_group_network.py +25 -27
- openstackclient/tests/unit/network/v2/test_security_group_rule_compute.py +1 -3
- openstackclient/tests/unit/network/v2/test_security_group_rule_network.py +33 -39
- openstackclient/tests/unit/volume/v2/fakes.py +1 -2
- openstackclient/tests/unit/volume/v2/test_service.py +57 -91
- openstackclient/tests/unit/volume/v2/test_volume.py +108 -105
- openstackclient/tests/unit/volume/v2/test_volume_backup.py +141 -148
- openstackclient/tests/unit/volume/v2/test_volume_snapshot.py +293 -283
- openstackclient/tests/unit/volume/v3/test_block_storage_log_level.py +61 -71
- openstackclient/tests/unit/volume/v3/test_service.py +221 -141
- openstackclient/tests/unit/volume/v3/test_volume.py +130 -119
- openstackclient/tests/unit/volume/v3/test_volume_attachment.py +1 -1
- openstackclient/tests/unit/volume/v3/test_volume_backup.py +198 -203
- openstackclient/tests/unit/volume/v3/test_volume_snapshot.py +682 -47
- openstackclient/volume/v2/service.py +41 -38
- openstackclient/volume/v2/volume.py +63 -37
- openstackclient/volume/v2/volume_backup.py +9 -3
- openstackclient/volume/v2/volume_snapshot.py +121 -84
- openstackclient/volume/v3/block_storage_log_level.py +22 -28
- openstackclient/volume/v3/service.py +105 -14
- openstackclient/volume/v3/volume.py +200 -39
- openstackclient/volume/v3/volume_backup.py +24 -19
- openstackclient/volume/v3/volume_snapshot.py +485 -10
- {python_openstackclient-8.0.0.dist-info → python_openstackclient-8.1.0.dist-info}/AUTHORS +8 -0
- python_openstackclient-8.1.0.dist-info/METADATA +264 -0
- {python_openstackclient-8.0.0.dist-info → python_openstackclient-8.1.0.dist-info}/RECORD +83 -81
- {python_openstackclient-8.0.0.dist-info → python_openstackclient-8.1.0.dist-info}/entry_points.txt +7 -6
- python_openstackclient-8.1.0.dist-info/pbr.json +1 -0
- python_openstackclient-8.0.0.dist-info/METADATA +0 -166
- python_openstackclient-8.0.0.dist-info/pbr.json +0 -1
- {python_openstackclient-8.0.0.dist-info → python_openstackclient-8.1.0.dist-info}/LICENSE +0 -0
- {python_openstackclient-8.0.0.dist-info → python_openstackclient-8.1.0.dist-info}/WHEEL +0 -0
- {python_openstackclient-8.0.0.dist-info → python_openstackclient-8.1.0.dist-info}/top_level.txt +0 -0
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
# under the License.
|
|
14
14
|
#
|
|
15
15
|
|
|
16
|
-
import copy
|
|
17
16
|
import random
|
|
18
17
|
import re
|
|
19
18
|
from unittest import mock
|
|
@@ -32,68 +31,13 @@ from openstack.compute.v2 import server_interface as _server_interface
|
|
|
32
31
|
from openstack.compute.v2 import server_migration as _server_migration
|
|
33
32
|
from openstack.compute.v2 import volume_attachment as _volume_attachment
|
|
34
33
|
|
|
35
|
-
from openstackclient.tests.unit import fakes
|
|
36
|
-
from openstackclient.tests.unit.identity.v2_0 import fakes as identity_fakes
|
|
34
|
+
from openstackclient.tests.unit.identity.v3 import fakes as identity_fakes
|
|
37
35
|
from openstackclient.tests.unit.image.v2 import fakes as image_fakes
|
|
38
36
|
from openstackclient.tests.unit.network.v2 import fakes as network_fakes
|
|
39
37
|
from openstackclient.tests.unit import utils
|
|
40
38
|
from openstackclient.tests.unit.volume.v3 import fakes as volume_fakes
|
|
41
39
|
|
|
42
40
|
|
|
43
|
-
class FakeComputev2Client:
|
|
44
|
-
def __init__(self, **kwargs):
|
|
45
|
-
self.agents = mock.Mock()
|
|
46
|
-
self.agents.resource_class = fakes.FakeResource(None, {})
|
|
47
|
-
|
|
48
|
-
self.images = mock.Mock()
|
|
49
|
-
self.images.resource_class = fakes.FakeResource(None, {})
|
|
50
|
-
|
|
51
|
-
self.servers = mock.Mock()
|
|
52
|
-
self.servers.resource_class = fakes.FakeResource(None, {})
|
|
53
|
-
|
|
54
|
-
self.services = mock.Mock()
|
|
55
|
-
self.services.resource_class = fakes.FakeResource(None, {})
|
|
56
|
-
|
|
57
|
-
self.extensions = mock.Mock()
|
|
58
|
-
self.extensions.resource_class = fakes.FakeResource(None, {})
|
|
59
|
-
|
|
60
|
-
self.flavors = mock.Mock()
|
|
61
|
-
|
|
62
|
-
self.flavor_access = mock.Mock()
|
|
63
|
-
self.flavor_access.resource_class = fakes.FakeResource(None, {})
|
|
64
|
-
|
|
65
|
-
self.usage = mock.Mock()
|
|
66
|
-
self.usage.resource_class = fakes.FakeResource(None, {})
|
|
67
|
-
|
|
68
|
-
self.volumes = mock.Mock()
|
|
69
|
-
self.volumes.resource_class = fakes.FakeResource(None, {})
|
|
70
|
-
|
|
71
|
-
self.hypervisors = mock.Mock()
|
|
72
|
-
self.hypervisors.resource_class = fakes.FakeResource(None, {})
|
|
73
|
-
|
|
74
|
-
self.hypervisors_stats = mock.Mock()
|
|
75
|
-
self.hypervisors_stats.resource_class = fakes.FakeResource(None, {})
|
|
76
|
-
|
|
77
|
-
self.keypairs = mock.Mock()
|
|
78
|
-
self.keypairs.resource_class = fakes.FakeResource(None, {})
|
|
79
|
-
|
|
80
|
-
self.server_groups = mock.Mock()
|
|
81
|
-
self.server_groups.resource_class = fakes.FakeResource(None, {})
|
|
82
|
-
|
|
83
|
-
self.server_migrations = mock.Mock()
|
|
84
|
-
self.server_migrations.resource_class = fakes.FakeResource(None, {})
|
|
85
|
-
|
|
86
|
-
self.instance_action = mock.Mock()
|
|
87
|
-
self.instance_action.resource_class = fakes.FakeResource(None, {})
|
|
88
|
-
|
|
89
|
-
self.migrations = mock.Mock()
|
|
90
|
-
self.migrations.resource_class = fakes.FakeResource(None, {})
|
|
91
|
-
|
|
92
|
-
self.auth_token = kwargs['token']
|
|
93
|
-
|
|
94
|
-
self.management_url = kwargs['endpoint']
|
|
95
|
-
|
|
96
|
-
|
|
97
41
|
class FakeClientMixin:
|
|
98
42
|
def setUp(self):
|
|
99
43
|
super().setUp()
|
|
@@ -121,10 +65,10 @@ class FakeClientMixin:
|
|
|
121
65
|
|
|
122
66
|
|
|
123
67
|
class TestComputev2(
|
|
68
|
+
identity_fakes.FakeClientMixin,
|
|
124
69
|
network_fakes.FakeClientMixin,
|
|
125
70
|
image_fakes.FakeClientMixin,
|
|
126
71
|
volume_fakes.FakeClientMixin,
|
|
127
|
-
identity_fakes.FakeClientMixin,
|
|
128
72
|
FakeClientMixin,
|
|
129
73
|
utils.TestCommand,
|
|
130
74
|
): ...
|
|
@@ -133,16 +77,14 @@ class TestComputev2(
|
|
|
133
77
|
def create_one_agent(attrs=None):
|
|
134
78
|
"""Create a fake agent.
|
|
135
79
|
|
|
136
|
-
:param dict attrs:
|
|
137
|
-
|
|
138
|
-
:return:
|
|
139
|
-
A FakeResource object, with agent_id, os, and so on
|
|
80
|
+
:param dict attrs: A dictionary with all attributes
|
|
81
|
+
:return: A dicionarty faking the agent
|
|
140
82
|
"""
|
|
141
83
|
|
|
142
84
|
attrs = attrs or {}
|
|
143
85
|
|
|
144
86
|
# set default attributes.
|
|
145
|
-
|
|
87
|
+
agent_attrs = {
|
|
146
88
|
'agent_id': 'agent-id-' + uuid.uuid4().hex,
|
|
147
89
|
'os': 'agent-os-' + uuid.uuid4().hex,
|
|
148
90
|
'architecture': 'agent-architecture',
|
|
@@ -152,22 +94,20 @@ def create_one_agent(attrs=None):
|
|
|
152
94
|
'hypervisor': 'hypervisor',
|
|
153
95
|
}
|
|
154
96
|
|
|
97
|
+
assert not set(attrs) - set(agent_attrs), 'unknown keys'
|
|
98
|
+
|
|
155
99
|
# Overwrite default attributes.
|
|
156
|
-
|
|
100
|
+
agent_attrs.update(attrs)
|
|
157
101
|
|
|
158
|
-
|
|
159
|
-
return agent
|
|
102
|
+
return agent_attrs
|
|
160
103
|
|
|
161
104
|
|
|
162
105
|
def create_agents(attrs=None, count=2):
|
|
163
106
|
"""Create multiple fake agents.
|
|
164
107
|
|
|
165
|
-
:param dict attrs:
|
|
166
|
-
|
|
167
|
-
:
|
|
168
|
-
The number of agents to fake
|
|
169
|
-
:return:
|
|
170
|
-
A list of FakeResource objects faking the agents
|
|
108
|
+
:param dict attrs: A dictionary with all attributes
|
|
109
|
+
:param int count: The number of agents to fake
|
|
110
|
+
:return: A list of dictionaries faking the agents
|
|
171
111
|
"""
|
|
172
112
|
agents = []
|
|
173
113
|
for i in range(0, count):
|
|
@@ -180,7 +120,7 @@ def create_one_extension(attrs=None):
|
|
|
180
120
|
"""Create a fake extension.
|
|
181
121
|
|
|
182
122
|
:param dict attrs: A dictionary with all attributes
|
|
183
|
-
:return: A fake openstack.compute.v2.extension.Extension object
|
|
123
|
+
:return: A fake :class:`~openstack.compute.v2.extension.Extension` object
|
|
184
124
|
"""
|
|
185
125
|
attrs = attrs or {}
|
|
186
126
|
|
|
@@ -212,10 +152,8 @@ def create_one_extension(attrs=None):
|
|
|
212
152
|
def create_one_security_group(attrs=None):
|
|
213
153
|
"""Create a fake security group.
|
|
214
154
|
|
|
215
|
-
:param dict attrs:
|
|
216
|
-
|
|
217
|
-
:return:
|
|
218
|
-
A FakeResource object, with id, name, etc.
|
|
155
|
+
:param dict attrs: A dictionary with all attributes
|
|
156
|
+
:return: A dictionary faking the security group
|
|
219
157
|
"""
|
|
220
158
|
attrs = attrs or {}
|
|
221
159
|
|
|
@@ -228,6 +166,8 @@ def create_one_security_group(attrs=None):
|
|
|
228
166
|
'rules': [],
|
|
229
167
|
}
|
|
230
168
|
|
|
169
|
+
assert not set(attrs) - set(security_group_attrs), 'unknown keys'
|
|
170
|
+
|
|
231
171
|
# Overwrite default attributes.
|
|
232
172
|
security_group_attrs.update(attrs)
|
|
233
173
|
return security_group_attrs
|
|
@@ -236,12 +176,9 @@ def create_one_security_group(attrs=None):
|
|
|
236
176
|
def create_security_groups(attrs=None, count=2):
|
|
237
177
|
"""Create multiple fake security groups.
|
|
238
178
|
|
|
239
|
-
:param dict attrs:
|
|
240
|
-
|
|
241
|
-
:
|
|
242
|
-
The number of security groups to fake
|
|
243
|
-
:return:
|
|
244
|
-
A list of FakeResource objects faking the security groups
|
|
179
|
+
:param dict attrs: A dictionary with all attributes
|
|
180
|
+
:param int count: The number of security groups to fake
|
|
181
|
+
:return: A list of dictionaries faking the security groups
|
|
245
182
|
"""
|
|
246
183
|
security_groups = []
|
|
247
184
|
for i in range(0, count):
|
|
@@ -250,32 +187,11 @@ def create_security_groups(attrs=None, count=2):
|
|
|
250
187
|
return security_groups
|
|
251
188
|
|
|
252
189
|
|
|
253
|
-
def get_security_groups(security_groups=None, count=2):
|
|
254
|
-
"""Get an iterable MagicMock with a list of faked security groups.
|
|
255
|
-
|
|
256
|
-
If security groups list is provided, then initialize the Mock object
|
|
257
|
-
with the list. Otherwise create one.
|
|
258
|
-
|
|
259
|
-
:param List security_groups:
|
|
260
|
-
A list of FakeResource objects faking security groups
|
|
261
|
-
:param int count:
|
|
262
|
-
The number of security groups to fake
|
|
263
|
-
:return:
|
|
264
|
-
An iterable Mock object with side_effect set to a list of faked
|
|
265
|
-
security groups
|
|
266
|
-
"""
|
|
267
|
-
if security_groups is None:
|
|
268
|
-
security_groups = create_security_groups(count)
|
|
269
|
-
return mock.Mock(side_effect=security_groups)
|
|
270
|
-
|
|
271
|
-
|
|
272
190
|
def create_one_security_group_rule(attrs=None):
|
|
273
191
|
"""Create a fake security group rule.
|
|
274
192
|
|
|
275
|
-
:param dict attrs:
|
|
276
|
-
|
|
277
|
-
:return:
|
|
278
|
-
A FakeResource object, with id, etc.
|
|
193
|
+
:param dict attrs: A dictionary with all attributes
|
|
194
|
+
:return: A dictionary faking the security group rule
|
|
279
195
|
"""
|
|
280
196
|
attrs = attrs or {}
|
|
281
197
|
|
|
@@ -290,6 +206,8 @@ def create_one_security_group_rule(attrs=None):
|
|
|
290
206
|
'to_port': 0,
|
|
291
207
|
}
|
|
292
208
|
|
|
209
|
+
assert not set(attrs) - set(security_group_rule_attrs), 'unknown keys'
|
|
210
|
+
|
|
293
211
|
# Overwrite default attributes.
|
|
294
212
|
security_group_rule_attrs.update(attrs)
|
|
295
213
|
|
|
@@ -299,12 +217,9 @@ def create_one_security_group_rule(attrs=None):
|
|
|
299
217
|
def create_security_group_rules(attrs=None, count=2):
|
|
300
218
|
"""Create multiple fake security group rules.
|
|
301
219
|
|
|
302
|
-
:param dict attrs:
|
|
303
|
-
|
|
304
|
-
:
|
|
305
|
-
The number of security group rules to fake
|
|
306
|
-
:return:
|
|
307
|
-
A list of FakeResource objects faking the security group rules
|
|
220
|
+
:param dict attrs: A dictionary with all attributes
|
|
221
|
+
:param int count: The number of security group rules to fake
|
|
222
|
+
:return: A list of dictionaries faking the security group rules
|
|
308
223
|
"""
|
|
309
224
|
security_group_rules = []
|
|
310
225
|
for i in range(0, count):
|
|
@@ -313,66 +228,11 @@ def create_security_group_rules(attrs=None, count=2):
|
|
|
313
228
|
return security_group_rules
|
|
314
229
|
|
|
315
230
|
|
|
316
|
-
def create_one_server(attrs=None
|
|
317
|
-
"""Create a fake server
|
|
318
|
-
|
|
319
|
-
:param dict attrs:
|
|
320
|
-
A dictionary with all attributes
|
|
321
|
-
:param dict methods:
|
|
322
|
-
A dictionary with all methods
|
|
323
|
-
:return:
|
|
324
|
-
A FakeResource object, with id, name, metadata, and so on
|
|
325
|
-
"""
|
|
326
|
-
attrs = attrs or {}
|
|
327
|
-
methods = methods or {}
|
|
328
|
-
|
|
329
|
-
# Set default attributes.
|
|
330
|
-
server_info = {
|
|
331
|
-
'id': 'server-id-' + uuid.uuid4().hex,
|
|
332
|
-
'name': 'server-name-' + uuid.uuid4().hex,
|
|
333
|
-
'metadata': {},
|
|
334
|
-
'image': {
|
|
335
|
-
'id': 'image-id-' + uuid.uuid4().hex,
|
|
336
|
-
},
|
|
337
|
-
'flavor': {
|
|
338
|
-
'id': 'flavor-id-' + uuid.uuid4().hex,
|
|
339
|
-
},
|
|
340
|
-
'OS-EXT-STS:power_state': 1,
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
# Overwrite default attributes.
|
|
344
|
-
server_info.update(attrs)
|
|
345
|
-
|
|
346
|
-
server = fakes.FakeResource(
|
|
347
|
-
info=copy.deepcopy(server_info), methods=methods, loaded=True
|
|
348
|
-
)
|
|
349
|
-
return server
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
def create_servers(attrs=None, methods=None, count=2):
|
|
353
|
-
"""Create multiple fake servers.
|
|
354
|
-
|
|
355
|
-
:param dict attrs:
|
|
356
|
-
A dictionary with all attributes
|
|
357
|
-
:param dict methods:
|
|
358
|
-
A dictionary with all methods
|
|
359
|
-
:param int count:
|
|
360
|
-
The number of servers to fake
|
|
361
|
-
:return:
|
|
362
|
-
A list of FakeResource objects faking the servers
|
|
363
|
-
"""
|
|
364
|
-
servers = []
|
|
365
|
-
for i in range(0, count):
|
|
366
|
-
servers.append(create_one_server(attrs, methods))
|
|
367
|
-
|
|
368
|
-
return servers
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
def create_one_sdk_server(attrs=None):
|
|
372
|
-
"""Create a fake server for testing migration to sdk
|
|
231
|
+
def create_one_server(attrs=None):
|
|
232
|
+
"""Create a fake server
|
|
373
233
|
|
|
374
234
|
:param dict attrs: A dictionary with all attributes
|
|
375
|
-
:return: A fake openstack.compute.v2.server.Server object,
|
|
235
|
+
:return: A fake :class:`~openstack.compute.v2.server.Server` object,
|
|
376
236
|
"""
|
|
377
237
|
attrs = attrs or {}
|
|
378
238
|
|
|
@@ -400,43 +260,26 @@ def create_one_sdk_server(attrs=None):
|
|
|
400
260
|
return server
|
|
401
261
|
|
|
402
262
|
|
|
403
|
-
def
|
|
404
|
-
"""Create multiple fake servers
|
|
263
|
+
def create_servers(attrs=None, count=2):
|
|
264
|
+
"""Create multiple fake servers
|
|
405
265
|
|
|
406
266
|
:param dict attrs: A dictionary with all attributes
|
|
407
267
|
:param int count: The number of servers to fake
|
|
408
|
-
:return: A list of fake openstack.compute.v2.server.Server objects
|
|
268
|
+
:return: A list of fake :class:`openstack.compute.v2.server.Server` objects
|
|
409
269
|
"""
|
|
410
270
|
servers = []
|
|
411
271
|
for i in range(0, count):
|
|
412
|
-
servers.append(
|
|
272
|
+
servers.append(create_one_server(attrs))
|
|
413
273
|
|
|
414
274
|
return servers
|
|
415
275
|
|
|
416
276
|
|
|
417
|
-
def get_servers(servers=None, count=2):
|
|
418
|
-
"""Get an iterable MagicMock object with a list of faked servers.
|
|
419
|
-
|
|
420
|
-
If servers list is provided, then initialize the Mock object with the
|
|
421
|
-
list. Otherwise create one.
|
|
422
|
-
|
|
423
|
-
:param list servers: A list of fake openstack.compute.v2.server.Server
|
|
424
|
-
objects
|
|
425
|
-
:param int count:
|
|
426
|
-
The number of servers to fake
|
|
427
|
-
:return: An iterable Mock object with side_effect set to a list of faked
|
|
428
|
-
servers
|
|
429
|
-
"""
|
|
430
|
-
if servers is None:
|
|
431
|
-
servers = create_servers(count)
|
|
432
|
-
return mock.Mock(side_effect=servers)
|
|
433
|
-
|
|
434
|
-
|
|
435
277
|
def create_one_server_action(attrs=None):
|
|
436
278
|
"""Create a fake server action.
|
|
437
279
|
|
|
438
280
|
:param attrs: A dictionary with all attributes
|
|
439
|
-
:return: A fake openstack.compute.v2.server_action.ServerAction
|
|
281
|
+
:return: A fake :class:`~openstack.compute.v2.server_action.ServerAction`
|
|
282
|
+
object
|
|
440
283
|
"""
|
|
441
284
|
attrs = attrs or {}
|
|
442
285
|
|
|
@@ -479,7 +322,7 @@ def create_one_flavor(attrs=None):
|
|
|
479
322
|
"""Create a fake flavor.
|
|
480
323
|
|
|
481
324
|
:param dict attrs: A dictionary with all attributes
|
|
482
|
-
:return: A fake openstack.compute.v2.flavor.Flavor object
|
|
325
|
+
:return: A fake :class:`~openstack.compute.v2.flavor.Flavor` object
|
|
483
326
|
"""
|
|
484
327
|
attrs = attrs or {}
|
|
485
328
|
|
|
@@ -512,7 +355,7 @@ def create_flavors(attrs=None, count=2):
|
|
|
512
355
|
|
|
513
356
|
:param dict attrs: A dictionary with all attributes
|
|
514
357
|
:param int count: The number of flavors to fake
|
|
515
|
-
:return: A list of fake openstack.compute.v2.flavor.Flavor objects
|
|
358
|
+
:return: A list of fake :class:`openstack.compute.v2.flavor.Flavor` objects
|
|
516
359
|
"""
|
|
517
360
|
flavors = []
|
|
518
361
|
for i in range(0, count):
|
|
@@ -521,30 +364,11 @@ def create_flavors(attrs=None, count=2):
|
|
|
521
364
|
return flavors
|
|
522
365
|
|
|
523
366
|
|
|
524
|
-
def get_flavors(flavors=None, count=2):
|
|
525
|
-
"""Get an iterable MagicMock object with a list of faked flavors.
|
|
526
|
-
|
|
527
|
-
If flavors list is provided, then initialize the Mock object with the
|
|
528
|
-
list. Otherwise create one.
|
|
529
|
-
|
|
530
|
-
:param list flavors: A list of fake openstack.compute.v2.flavor.Flavor
|
|
531
|
-
objects
|
|
532
|
-
:param int count: The number of flavors to fake
|
|
533
|
-
:return: An iterable Mock object with side_effect set to a list of faked
|
|
534
|
-
flavors
|
|
535
|
-
"""
|
|
536
|
-
if flavors is None:
|
|
537
|
-
flavors = create_flavors(count)
|
|
538
|
-
return mock.Mock(side_effect=flavors)
|
|
539
|
-
|
|
540
|
-
|
|
541
367
|
def create_one_flavor_access(attrs=None):
|
|
542
368
|
"""Create a fake flavor access.
|
|
543
369
|
|
|
544
|
-
:param dict attrs:
|
|
545
|
-
|
|
546
|
-
:return:
|
|
547
|
-
A FakeResource object, with flavor_id, tenat_id
|
|
370
|
+
:param dict attrs: A dictionary with all attributes
|
|
371
|
+
:return: A dictionary faking the flavor access
|
|
548
372
|
"""
|
|
549
373
|
attrs = attrs or {}
|
|
550
374
|
|
|
@@ -554,22 +378,20 @@ def create_one_flavor_access(attrs=None):
|
|
|
554
378
|
'tenant_id': 'tenant-id-' + uuid.uuid4().hex,
|
|
555
379
|
}
|
|
556
380
|
|
|
381
|
+
assert not set(attrs) - set(flavor_access_info), 'unknown keys'
|
|
382
|
+
|
|
557
383
|
# Overwrite default attributes.
|
|
558
384
|
flavor_access_info.update(attrs)
|
|
559
385
|
|
|
560
|
-
|
|
561
|
-
info=copy.deepcopy(flavor_access_info), loaded=True
|
|
562
|
-
)
|
|
563
|
-
|
|
564
|
-
return flavor_access
|
|
386
|
+
return flavor_access_info
|
|
565
387
|
|
|
566
388
|
|
|
567
389
|
def create_one_availability_zone(attrs=None):
|
|
568
390
|
"""Create a fake AZ.
|
|
569
391
|
|
|
570
392
|
:param dict attrs: A dictionary with all attributes
|
|
571
|
-
:return: A fake
|
|
572
|
-
object
|
|
393
|
+
:return: A fake
|
|
394
|
+
:class:`~openstack.compute.v2.availability_zone.AvailabilityZone` object
|
|
573
395
|
"""
|
|
574
396
|
attrs = attrs or {}
|
|
575
397
|
|
|
@@ -616,12 +438,10 @@ def create_availability_zones(attrs=None, count=2):
|
|
|
616
438
|
|
|
617
439
|
|
|
618
440
|
def create_one_floating_ip(attrs=None):
|
|
619
|
-
"""Create a fake floating
|
|
441
|
+
"""Create a fake floating IP.
|
|
620
442
|
|
|
621
|
-
:param dict attrs:
|
|
622
|
-
|
|
623
|
-
:return:
|
|
624
|
-
A FakeResource object, with id, ip, and so on
|
|
443
|
+
:param dict attrs: A dictionary with all attributes
|
|
444
|
+
:return: A dictionary faking the floating IP
|
|
625
445
|
"""
|
|
626
446
|
attrs = attrs or {}
|
|
627
447
|
|
|
@@ -634,6 +454,8 @@ def create_one_floating_ip(attrs=None):
|
|
|
634
454
|
'pool': 'public',
|
|
635
455
|
}
|
|
636
456
|
|
|
457
|
+
assert not set(attrs) - set(floating_ip_attrs), 'unknown keys'
|
|
458
|
+
|
|
637
459
|
# Overwrite default attributes.
|
|
638
460
|
floating_ip_attrs.update(attrs)
|
|
639
461
|
|
|
@@ -641,14 +463,11 @@ def create_one_floating_ip(attrs=None):
|
|
|
641
463
|
|
|
642
464
|
|
|
643
465
|
def create_floating_ips(attrs=None, count=2):
|
|
644
|
-
"""Create multiple fake floating
|
|
645
|
-
|
|
646
|
-
:param dict attrs:
|
|
647
|
-
|
|
648
|
-
:
|
|
649
|
-
The number of floating ips to fake
|
|
650
|
-
:return:
|
|
651
|
-
A list of FakeResource objects faking the floating ips
|
|
466
|
+
"""Create multiple fake floating IPs.
|
|
467
|
+
|
|
468
|
+
:param dict attrs: A dictionary with all attributes
|
|
469
|
+
:param int count: The number of floating IPs to fake
|
|
470
|
+
:return: A list of dictionaries faking the floating IPs
|
|
652
471
|
"""
|
|
653
472
|
floating_ips = []
|
|
654
473
|
for i in range(0, count):
|
|
@@ -656,32 +475,11 @@ def create_floating_ips(attrs=None, count=2):
|
|
|
656
475
|
return floating_ips
|
|
657
476
|
|
|
658
477
|
|
|
659
|
-
def get_floating_ips(floating_ips=None, count=2):
|
|
660
|
-
"""Get an iterable MagicMock object with a list of faked floating ips.
|
|
661
|
-
|
|
662
|
-
If floating_ips list is provided, then initialize the Mock object
|
|
663
|
-
with the list. Otherwise create one.
|
|
664
|
-
|
|
665
|
-
:param List floating_ips:
|
|
666
|
-
A list of FakeResource objects faking floating ips
|
|
667
|
-
:param int count:
|
|
668
|
-
The number of floating ips to fake
|
|
669
|
-
:return:
|
|
670
|
-
An iterable Mock object with side_effect set to a list of faked
|
|
671
|
-
floating ips
|
|
672
|
-
"""
|
|
673
|
-
if floating_ips is None:
|
|
674
|
-
floating_ips = create_floating_ips(count)
|
|
675
|
-
return mock.Mock(side_effect=floating_ips)
|
|
676
|
-
|
|
677
|
-
|
|
678
478
|
def create_one_floating_ip_pool(attrs=None):
|
|
679
|
-
"""Create a fake floating
|
|
479
|
+
"""Create a fake floating IP pool.
|
|
680
480
|
|
|
681
|
-
:param dict attrs:
|
|
682
|
-
|
|
683
|
-
:return:
|
|
684
|
-
A FakeResource object, with name, etc
|
|
481
|
+
:param dict attrs: A dictionary with all attributes
|
|
482
|
+
:return: A dictionary faking the floating IP pool
|
|
685
483
|
"""
|
|
686
484
|
if attrs is None:
|
|
687
485
|
attrs = {}
|
|
@@ -691,6 +489,8 @@ def create_one_floating_ip_pool(attrs=None):
|
|
|
691
489
|
'name': 'floating-ip-pool-name-' + uuid.uuid4().hex,
|
|
692
490
|
}
|
|
693
491
|
|
|
492
|
+
assert not set(attrs) - set(floating_ip_pool_attrs), 'unknown keys'
|
|
493
|
+
|
|
694
494
|
# Overwrite default attributes.
|
|
695
495
|
floating_ip_pool_attrs.update(attrs)
|
|
696
496
|
|
|
@@ -698,14 +498,11 @@ def create_one_floating_ip_pool(attrs=None):
|
|
|
698
498
|
|
|
699
499
|
|
|
700
500
|
def create_floating_ip_pools(attrs=None, count=2):
|
|
701
|
-
"""Create multiple fake floating
|
|
702
|
-
|
|
703
|
-
:param dict attrs:
|
|
704
|
-
|
|
705
|
-
:
|
|
706
|
-
The number of floating ip pools to fake
|
|
707
|
-
:return:
|
|
708
|
-
A list of FakeResource objects faking the floating ip pools
|
|
501
|
+
"""Create multiple fake floating IP pools.
|
|
502
|
+
|
|
503
|
+
:param dict attrs: A dictionary with all attributes
|
|
504
|
+
:param int count: The number of floating IP pools to fake
|
|
505
|
+
:return: A list of dictionaries faking the floating IP pools
|
|
709
506
|
"""
|
|
710
507
|
floating_ip_pools = []
|
|
711
508
|
for i in range(0, count):
|
|
@@ -716,10 +513,8 @@ def create_floating_ip_pools(attrs=None, count=2):
|
|
|
716
513
|
def create_one_network(attrs=None):
|
|
717
514
|
"""Create a fake network.
|
|
718
515
|
|
|
719
|
-
:param dict attrs:
|
|
720
|
-
|
|
721
|
-
:return:
|
|
722
|
-
A FakeResource object, with id, label, cidr and so on
|
|
516
|
+
:param dict attrs: A dictionary with all attributes
|
|
517
|
+
:return: A dictionary faking the network
|
|
723
518
|
"""
|
|
724
519
|
attrs = attrs or {}
|
|
725
520
|
|
|
@@ -759,6 +554,8 @@ def create_one_network(attrs=None):
|
|
|
759
554
|
'vpn_public_port': None,
|
|
760
555
|
}
|
|
761
556
|
|
|
557
|
+
assert not set(attrs) - set(network_attrs), 'unknown keys'
|
|
558
|
+
|
|
762
559
|
# Overwrite default attributes.
|
|
763
560
|
network_attrs.update(attrs)
|
|
764
561
|
|
|
@@ -768,12 +565,9 @@ def create_one_network(attrs=None):
|
|
|
768
565
|
def create_networks(attrs=None, count=2):
|
|
769
566
|
"""Create multiple fake networks.
|
|
770
567
|
|
|
771
|
-
:param dict attrs:
|
|
772
|
-
|
|
773
|
-
:
|
|
774
|
-
The number of networks to fake
|
|
775
|
-
:return:
|
|
776
|
-
A list of FakeResource objects faking the networks
|
|
568
|
+
:param dict attrs: A dictionary with all attributes
|
|
569
|
+
:param int count: The number of networks to fake
|
|
570
|
+
:return: A list of dictionaries faking the networks
|
|
777
571
|
"""
|
|
778
572
|
networks = []
|
|
779
573
|
for i in range(0, count):
|
|
@@ -782,25 +576,6 @@ def create_networks(attrs=None, count=2):
|
|
|
782
576
|
return networks
|
|
783
577
|
|
|
784
578
|
|
|
785
|
-
def get_networks(networks=None, count=2):
|
|
786
|
-
"""Get an iterable MagicMock object with a list of faked networks.
|
|
787
|
-
|
|
788
|
-
If networks list is provided, then initialize the Mock object with the
|
|
789
|
-
list. Otherwise create one.
|
|
790
|
-
|
|
791
|
-
:param List networks:
|
|
792
|
-
A list of FakeResource objects faking networks
|
|
793
|
-
:param int count:
|
|
794
|
-
The number of networks to fake
|
|
795
|
-
:return:
|
|
796
|
-
An iterable Mock object with side_effect set to a list of faked
|
|
797
|
-
networks
|
|
798
|
-
"""
|
|
799
|
-
if networks is None:
|
|
800
|
-
networks = create_networks(count=count)
|
|
801
|
-
return mock.Mock(side_effect=networks)
|
|
802
|
-
|
|
803
|
-
|
|
804
579
|
def create_limits(attrs=None):
|
|
805
580
|
"""Create a fake limits object."""
|
|
806
581
|
attrs = attrs or {}
|
|
@@ -866,7 +641,7 @@ def create_one_migration(attrs=None):
|
|
|
866
641
|
"""Create a fake migration.
|
|
867
642
|
|
|
868
643
|
:param dict attrs: A dictionary with all attributes
|
|
869
|
-
:return: A fake openstack.compute.v2.migration.Migration object
|
|
644
|
+
:return: A fake :class:`~openstack.compute.v2.migration.Migration` object
|
|
870
645
|
"""
|
|
871
646
|
attrs = attrs or {}
|
|
872
647
|
|
|
@@ -902,7 +677,7 @@ def create_migrations(attrs=None, count=2):
|
|
|
902
677
|
|
|
903
678
|
:param dict attrs: A dictionary with all attributes
|
|
904
679
|
:param int count: The number of migrations to fake
|
|
905
|
-
:return: A list of fake openstack.compute.v2.migration.Migration objects
|
|
680
|
+
:return: A list of fake :class:`openstack.compute.v2.migration.Migration` objects
|
|
906
681
|
"""
|
|
907
682
|
migrations = []
|
|
908
683
|
for i in range(0, count):
|
|
@@ -915,7 +690,8 @@ def create_one_server_migration(attrs=None):
|
|
|
915
690
|
"""Create a fake server migration.
|
|
916
691
|
|
|
917
692
|
:param dict attrs: A dictionary with all attributes
|
|
918
|
-
:return A fake
|
|
693
|
+
:return: A fake
|
|
694
|
+
:class:`~openstack.compute.v2.server_migration.ServerMigration` object
|
|
919
695
|
"""
|
|
920
696
|
attrs = attrs or {}
|
|
921
697
|
|
|
@@ -971,8 +747,8 @@ def create_one_volume_attachment(attrs=None):
|
|
|
971
747
|
"""Create a fake volume attachment.
|
|
972
748
|
|
|
973
749
|
:param dict attrs: A dictionary with all attributes
|
|
974
|
-
:return: A fake
|
|
975
|
-
object
|
|
750
|
+
:return: A fake
|
|
751
|
+
:class:`~openstack.compute.v2.volume_attachment.VolumeAttachment` object
|
|
976
752
|
"""
|
|
977
753
|
attrs = attrs or {}
|
|
978
754
|
|
|
@@ -1013,12 +789,12 @@ def create_volume_attachments(attrs=None, count=2):
|
|
|
1013
789
|
|
|
1014
790
|
|
|
1015
791
|
def create_one_server_interface(attrs=None):
|
|
1016
|
-
"""Create a fake
|
|
792
|
+
"""Create a fake ServerInterface.
|
|
1017
793
|
|
|
1018
794
|
:param dict attrs: A dictionary with all attributes
|
|
1019
795
|
:param dict methods: A dictionary with all methods
|
|
1020
|
-
:return: A fake
|
|
1021
|
-
object
|
|
796
|
+
:return: A fake
|
|
797
|
+
:class:`~openstack.compute.v2.server_interface.ServerInterface` object
|
|
1022
798
|
"""
|
|
1023
799
|
attrs = attrs or {}
|
|
1024
800
|
|
|
@@ -157,7 +157,7 @@ class TestConsoleUrlShow(compute_fakes.TestComputev2):
|
|
|
157
157
|
self.assertEqual(self.columns, columns)
|
|
158
158
|
self.assertEqual(self.data, data)
|
|
159
159
|
|
|
160
|
-
def
|
|
160
|
+
def test_console_url_show_with_spice_html5(self):
|
|
161
161
|
arglist = [
|
|
162
162
|
'--spice',
|
|
163
163
|
'foo_vm',
|
|
@@ -174,6 +174,23 @@ class TestConsoleUrlShow(compute_fakes.TestComputev2):
|
|
|
174
174
|
self.assertEqual(self.columns, columns)
|
|
175
175
|
self.assertEqual(self.data, data)
|
|
176
176
|
|
|
177
|
+
def test_console_url_show_with_spice_direct(self):
|
|
178
|
+
arglist = [
|
|
179
|
+
'--spice-direct',
|
|
180
|
+
'foo_vm',
|
|
181
|
+
]
|
|
182
|
+
verifylist = [
|
|
183
|
+
('url_type', 'spice-direct'),
|
|
184
|
+
('server', 'foo_vm'),
|
|
185
|
+
]
|
|
186
|
+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
187
|
+
columns, data = self.cmd.take_action(parsed_args)
|
|
188
|
+
self.compute_client.create_console.assert_called_once_with(
|
|
189
|
+
self._server.id, console_type='spice-direct'
|
|
190
|
+
)
|
|
191
|
+
self.assertEqual(self.columns, columns)
|
|
192
|
+
self.assertEqual(self.data, data)
|
|
193
|
+
|
|
177
194
|
def test_console_url_show_with_rdp(self):
|
|
178
195
|
arglist = [
|
|
179
196
|
'--rdp',
|