python-openstackclient 8.0.0__py3-none-any.whl → 8.2.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 (106) hide show
  1. openstackclient/api/compute_v2.py +2 -2
  2. openstackclient/api/volume_v2.py +60 -0
  3. openstackclient/api/volume_v3.py +60 -0
  4. openstackclient/compute/client.py +5 -0
  5. openstackclient/compute/v2/console.py +7 -0
  6. openstackclient/compute/v2/console_connection.py +48 -0
  7. openstackclient/compute/v2/flavor.py +14 -1
  8. openstackclient/compute/v2/keypair.py +10 -3
  9. openstackclient/compute/v2/server.py +76 -13
  10. openstackclient/compute/v2/server_event.py +1 -1
  11. openstackclient/identity/common.py +85 -11
  12. openstackclient/identity/v3/application_credential.py +88 -87
  13. openstackclient/identity/v3/domain.py +67 -49
  14. openstackclient/identity/v3/group.py +113 -68
  15. openstackclient/identity/v3/project.py +42 -20
  16. openstackclient/identity/v3/role.py +7 -2
  17. openstackclient/identity/v3/user.py +38 -5
  18. openstackclient/image/client.py +5 -0
  19. openstackclient/image/v1/image.py +16 -1
  20. openstackclient/image/v2/cache.py +10 -6
  21. openstackclient/image/v2/image.py +59 -12
  22. openstackclient/image/v2/metadef_objects.py +8 -2
  23. openstackclient/image/v2/metadef_properties.py +9 -2
  24. openstackclient/network/client.py +0 -6
  25. openstackclient/network/v2/floating_ip.py +58 -29
  26. openstackclient/network/v2/network_qos_rule.py +3 -11
  27. openstackclient/network/v2/port.py +16 -0
  28. openstackclient/network/v2/router.py +1 -1
  29. openstackclient/network/v2/security_group.py +49 -7
  30. openstackclient/network/v2/security_group_rule.py +18 -1
  31. openstackclient/shell.py +1 -1
  32. openstackclient/tests/functional/base.py +5 -1
  33. openstackclient/tests/functional/compute/v2/test_keypair.py +41 -5
  34. openstackclient/tests/functional/identity/v3/test_access_rule.py +1 -1
  35. openstackclient/tests/functional/identity/v3/test_application_credential.py +7 -7
  36. openstackclient/tests/functional/image/v2/test_image.py +36 -14
  37. openstackclient/tests/functional/volume/v2/test_volume.py +1 -1
  38. openstackclient/tests/functional/volume/v3/test_volume.py +2 -2
  39. openstackclient/tests/unit/api/test_volume_v2.py +124 -0
  40. openstackclient/tests/unit/api/test_volume_v3.py +124 -0
  41. openstackclient/tests/unit/compute/v2/fakes.py +81 -305
  42. openstackclient/tests/unit/compute/v2/test_console.py +18 -1
  43. openstackclient/tests/unit/compute/v2/test_console_connection.py +72 -0
  44. openstackclient/tests/unit/compute/v2/test_flavor.py +160 -175
  45. openstackclient/tests/unit/compute/v2/test_keypair.py +12 -5
  46. openstackclient/tests/unit/compute/v2/test_server.py +211 -97
  47. openstackclient/tests/unit/compute/v2/test_server_backup.py +32 -71
  48. openstackclient/tests/unit/compute/v2/test_server_event.py +2 -2
  49. openstackclient/tests/unit/compute/v2/test_server_image.py +33 -72
  50. openstackclient/tests/unit/compute/v2/test_server_migration.py +4 -4
  51. openstackclient/tests/unit/identity/v3/test_application_credential.py +93 -65
  52. openstackclient/tests/unit/identity/v3/test_domain.py +117 -107
  53. openstackclient/tests/unit/identity/v3/test_group.py +353 -202
  54. openstackclient/tests/unit/identity/v3/test_project.py +46 -53
  55. openstackclient/tests/unit/identity/v3/test_role.py +2 -8
  56. openstackclient/tests/unit/identity/v3/test_user.py +86 -6
  57. openstackclient/tests/unit/image/v1/test_image.py +55 -9
  58. openstackclient/tests/unit/image/v2/test_image.py +128 -58
  59. openstackclient/tests/unit/image/v2/test_metadef_objects.py +22 -0
  60. openstackclient/tests/unit/image/v2/test_metadef_properties.py +24 -10
  61. openstackclient/tests/unit/network/v2/fakes.py +406 -485
  62. openstackclient/tests/unit/network/v2/test_floating_ip_network.py +13 -19
  63. openstackclient/tests/unit/network/v2/test_l3_conntrack_helper.py +2 -2
  64. openstackclient/tests/unit/network/v2/test_ndp_proxy.py +3 -5
  65. openstackclient/tests/unit/network/v2/test_network.py +4 -4
  66. openstackclient/tests/unit/network/v2/test_network_agent.py +15 -29
  67. openstackclient/tests/unit/network/v2/test_network_qos_policy.py +16 -19
  68. openstackclient/tests/unit/network/v2/test_network_qos_rule.py +79 -152
  69. openstackclient/tests/unit/network/v2/test_network_qos_rule_type.py +4 -6
  70. openstackclient/tests/unit/network/v2/test_network_rbac.py +2 -2
  71. openstackclient/tests/unit/network/v2/test_port.py +57 -17
  72. openstackclient/tests/unit/network/v2/test_router.py +73 -57
  73. openstackclient/tests/unit/network/v2/test_security_group_network.py +31 -27
  74. openstackclient/tests/unit/network/v2/test_security_group_rule_compute.py +1 -3
  75. openstackclient/tests/unit/network/v2/test_security_group_rule_network.py +82 -39
  76. openstackclient/tests/unit/volume/v2/fakes.py +1 -2
  77. openstackclient/tests/unit/volume/v2/test_service.py +57 -91
  78. openstackclient/tests/unit/volume/v2/test_volume.py +466 -410
  79. openstackclient/tests/unit/volume/v2/test_volume_backup.py +141 -148
  80. openstackclient/tests/unit/volume/v2/test_volume_snapshot.py +293 -283
  81. openstackclient/tests/unit/volume/v3/test_block_storage_log_level.py +61 -71
  82. openstackclient/tests/unit/volume/v3/test_service.py +221 -141
  83. openstackclient/tests/unit/volume/v3/test_volume.py +569 -534
  84. openstackclient/tests/unit/volume/v3/test_volume_attachment.py +1 -1
  85. openstackclient/tests/unit/volume/v3/test_volume_backup.py +198 -203
  86. openstackclient/tests/unit/volume/v3/test_volume_snapshot.py +682 -47
  87. openstackclient/volume/v2/service.py +41 -38
  88. openstackclient/volume/v2/volume.py +140 -88
  89. openstackclient/volume/v2/volume_backup.py +9 -3
  90. openstackclient/volume/v2/volume_snapshot.py +121 -84
  91. openstackclient/volume/v3/block_storage_log_level.py +22 -28
  92. openstackclient/volume/v3/service.py +105 -14
  93. openstackclient/volume/v3/volume.py +287 -99
  94. openstackclient/volume/v3/volume_backup.py +24 -19
  95. openstackclient/volume/v3/volume_group.py +1 -1
  96. openstackclient/volume/v3/volume_snapshot.py +485 -10
  97. {python_openstackclient-8.0.0.dist-info → python_openstackclient-8.2.0.dist-info}/AUTHORS +13 -0
  98. python_openstackclient-8.2.0.dist-info/METADATA +264 -0
  99. {python_openstackclient-8.0.0.dist-info → python_openstackclient-8.2.0.dist-info}/RECORD +104 -98
  100. {python_openstackclient-8.0.0.dist-info → python_openstackclient-8.2.0.dist-info}/entry_points.txt +7 -6
  101. python_openstackclient-8.2.0.dist-info/pbr.json +1 -0
  102. python_openstackclient-8.0.0.dist-info/METADATA +0 -166
  103. python_openstackclient-8.0.0.dist-info/pbr.json +0 -1
  104. {python_openstackclient-8.0.0.dist-info → python_openstackclient-8.2.0.dist-info}/LICENSE +0 -0
  105. {python_openstackclient-8.0.0.dist-info → python_openstackclient-8.2.0.dist-info}/WHEEL +0 -0
  106. {python_openstackclient-8.0.0.dist-info → python_openstackclient-8.2.0.dist-info}/top_level.txt +0 -0
@@ -31,8 +31,24 @@ from openstack.network.v2 import network as _network
31
31
  from openstack.network.v2 import network_ip_availability as _ip_availability
32
32
  from openstack.network.v2 import network_segment_range as _segment_range
33
33
  from openstack.network.v2 import port as _port
34
+ from openstack.network.v2 import (
35
+ qos_bandwidth_limit_rule as _qos_bandwidth_limit_rule,
36
+ )
37
+ from openstack.network.v2 import (
38
+ qos_dscp_marking_rule as _qos_dscp_marking_rule,
39
+ )
40
+ from openstack.network.v2 import (
41
+ qos_minimum_bandwidth_rule as _qos_minimum_bandwidth_rule,
42
+ )
43
+ from openstack.network.v2 import (
44
+ qos_minimum_packet_rate_rule as _qos_minimum_packet_rate_rule,
45
+ )
46
+ from openstack.network.v2 import qos_policy as _qos_policy
47
+ from openstack.network.v2 import qos_rule_type as _qos_rule_type
34
48
  from openstack.network.v2 import rbac_policy as network_rbac
49
+ from openstack.network.v2 import router as _router
35
50
  from openstack.network.v2 import security_group as _security_group
51
+ from openstack.network.v2 import security_group_rule as _security_group_rule
36
52
  from openstack.network.v2 import segment as _segment
37
53
  from openstack.network.v2 import service_profile as _service_profile
38
54
  from openstack.network.v2 import trunk as _trunk
@@ -118,485 +134,6 @@ def create_one_extension(attrs=None):
118
134
  return extension
119
135
 
120
136
 
121
- class FakeNetworkQosPolicy:
122
- """Fake one or more QoS policies."""
123
-
124
- @staticmethod
125
- def create_one_qos_policy(attrs=None):
126
- """Create a fake QoS policy.
127
-
128
- :param Dictionary attrs:
129
- A dictionary with all attributes
130
- :return:
131
- A FakeResource object with name, id, etc.
132
- """
133
- attrs = attrs or {}
134
- qos_id = attrs.get('id') or 'qos-policy-id-' + uuid.uuid4().hex
135
- rule_attrs = {'qos_policy_id': qos_id}
136
- rules = [FakeNetworkQosRule.create_one_qos_rule(rule_attrs)]
137
-
138
- # Set default attributes.
139
- qos_policy_attrs = {
140
- 'name': 'qos-policy-name-' + uuid.uuid4().hex,
141
- 'id': qos_id,
142
- 'is_default': False,
143
- 'project_id': 'project-id-' + uuid.uuid4().hex,
144
- 'shared': False,
145
- 'description': 'qos-policy-description-' + uuid.uuid4().hex,
146
- 'rules': rules,
147
- 'location': 'MUNCHMUNCHMUNCH',
148
- }
149
-
150
- # Overwrite default attributes.
151
- qos_policy_attrs.update(attrs)
152
-
153
- qos_policy = fakes.FakeResource(
154
- info=copy.deepcopy(qos_policy_attrs), loaded=True
155
- )
156
-
157
- # Set attributes with special mapping in OpenStack SDK.
158
- qos_policy.is_shared = qos_policy_attrs['shared']
159
-
160
- return qos_policy
161
-
162
- @staticmethod
163
- def create_qos_policies(attrs=None, count=2):
164
- """Create multiple fake QoS policies.
165
-
166
- :param Dictionary attrs:
167
- A dictionary with all attributes
168
- :param int count:
169
- The number of QoS policies to fake
170
- :return:
171
- A list of FakeResource objects faking the QoS policies
172
- """
173
- qos_policies = []
174
- for i in range(0, count):
175
- qos_policies.append(
176
- FakeNetworkQosPolicy.create_one_qos_policy(attrs)
177
- )
178
-
179
- return qos_policies
180
-
181
- @staticmethod
182
- def get_qos_policies(qos_policies=None, count=2):
183
- """Get an iterable MagicMock object with a list of faked QoS policies.
184
-
185
- If qos policies list is provided, then initialize the Mock object
186
- with the list. Otherwise create one.
187
-
188
- :param List qos_policies:
189
- A list of FakeResource objects faking qos policies
190
- :param int count:
191
- The number of QoS policies to fake
192
- :return:
193
- An iterable Mock object with side_effect set to a list of faked
194
- QoS policies
195
- """
196
- if qos_policies is None:
197
- qos_policies = FakeNetworkQosPolicy.create_qos_policies(count)
198
- return mock.Mock(side_effect=qos_policies)
199
-
200
-
201
- class FakeNetworkSecGroup:
202
- """Fake one security group."""
203
-
204
- @staticmethod
205
- def create_one_security_group(attrs=None):
206
- """Create a fake security group.
207
-
208
- :param Dictionary attrs:
209
- A dictionary with all attributes
210
- :return:
211
- A FakeResource object with name, id, etc.
212
- """
213
- attrs = attrs or {}
214
- sg_id = attrs.get('id') or 'security-group-id-' + uuid.uuid4().hex
215
-
216
- # Set default attributes.
217
- security_group_attrs = {
218
- 'name': 'security-group-name-' + uuid.uuid4().hex,
219
- 'id': sg_id,
220
- 'project_id': 'project-id-' + uuid.uuid4().hex,
221
- 'description': 'security-group-description-' + uuid.uuid4().hex,
222
- 'location': 'MUNCHMUNCHMUNCH',
223
- }
224
-
225
- security_group = fakes.FakeResource(
226
- info=copy.deepcopy(security_group_attrs), loaded=True
227
- )
228
-
229
- return security_group
230
-
231
-
232
- class FakeNetworkQosRule:
233
- """Fake one or more Network QoS rules."""
234
-
235
- @staticmethod
236
- def create_one_qos_rule(attrs=None):
237
- """Create a fake Network QoS rule.
238
-
239
- :param Dictionary attrs:
240
- A dictionary with all attributes
241
- :return:
242
- A FakeResource object with name, id, etc.
243
- """
244
- attrs = attrs or {}
245
-
246
- # Set default attributes.
247
- type = attrs.get('type') or choice(VALID_QOS_RULES)
248
- qos_rule_attrs = {
249
- 'id': 'qos-rule-id-' + uuid.uuid4().hex,
250
- 'qos_policy_id': 'qos-policy-id-' + uuid.uuid4().hex,
251
- 'project_id': 'project-id-' + uuid.uuid4().hex,
252
- 'type': type,
253
- 'location': 'MUNCHMUNCHMUNCH',
254
- }
255
- if type == RULE_TYPE_BANDWIDTH_LIMIT:
256
- qos_rule_attrs['max_kbps'] = randint(1, 10000)
257
- qos_rule_attrs['max_burst_kbits'] = randint(1, 10000)
258
- qos_rule_attrs['direction'] = 'egress'
259
- elif type == RULE_TYPE_DSCP_MARKING:
260
- qos_rule_attrs['dscp_mark'] = choice(VALID_DSCP_MARKS)
261
- elif type == RULE_TYPE_MINIMUM_BANDWIDTH:
262
- qos_rule_attrs['min_kbps'] = randint(1, 10000)
263
- qos_rule_attrs['direction'] = 'egress'
264
- elif type == RULE_TYPE_MINIMUM_PACKET_RATE:
265
- qos_rule_attrs['min_kpps'] = randint(1, 10000)
266
- qos_rule_attrs['direction'] = 'egress'
267
-
268
- # Overwrite default attributes.
269
- qos_rule_attrs.update(attrs)
270
-
271
- qos_rule = fakes.FakeResource(
272
- info=copy.deepcopy(qos_rule_attrs), loaded=True
273
- )
274
-
275
- return qos_rule
276
-
277
- @staticmethod
278
- def create_qos_rules(attrs=None, count=2):
279
- """Create multiple fake Network QoS rules.
280
-
281
- :param Dictionary attrs:
282
- A dictionary with all attributes
283
- :param int count:
284
- The number of Network QoS rule to fake
285
- :return:
286
- A list of FakeResource objects faking the Network QoS rules
287
- """
288
- qos_rules = []
289
- for i in range(0, count):
290
- qos_rules.append(FakeNetworkQosRule.create_one_qos_rule(attrs))
291
- return qos_rules
292
-
293
- @staticmethod
294
- def get_qos_rules(qos_rules=None, count=2):
295
- """Get a list of faked Network QoS rules.
296
-
297
- If Network QoS rules list is provided, then initialize the Mock
298
- object with the list. Otherwise create one.
299
-
300
- :param List qos_rules:
301
- A list of FakeResource objects faking Network QoS rules
302
- :param int count:
303
- The number of QoS minimum bandwidth rules to fake
304
- :return:
305
- An iterable Mock object with side_effect set to a list of faked
306
- qos minimum bandwidth rules
307
- """
308
- if qos_rules is None:
309
- qos_rules = FakeNetworkQosRule.create_qos_rules(count)
310
- return mock.Mock(side_effect=qos_rules)
311
-
312
-
313
- class FakeNetworkQosRuleType:
314
- """Fake one or more Network QoS rule types."""
315
-
316
- @staticmethod
317
- def create_one_qos_rule_type(attrs=None):
318
- """Create a fake Network QoS rule type.
319
-
320
- :param Dictionary attrs:
321
- A dictionary with all attributes
322
- :return:
323
- A FakeResource object with name, id, etc.
324
- """
325
- attrs = attrs or {}
326
-
327
- # Set default attributes.
328
- qos_rule_type_attrs = {
329
- 'type': 'rule-type-' + uuid.uuid4().hex,
330
- 'location': 'MUNCHMUNCHMUNCH',
331
- }
332
-
333
- # Overwrite default attributes.
334
- qos_rule_type_attrs.update(attrs)
335
-
336
- return fakes.FakeResource(
337
- info=copy.deepcopy(qos_rule_type_attrs), loaded=True
338
- )
339
-
340
- @staticmethod
341
- def create_qos_rule_types(attrs=None, count=2):
342
- """Create multiple fake Network QoS rule types.
343
-
344
- :param Dictionary attrs:
345
- A dictionary with all attributes
346
- :param int count:
347
- The number of QoS rule types to fake
348
- :return:
349
- A list of FakeResource objects faking the QoS rule types
350
- """
351
- qos_rule_types = []
352
- for i in range(0, count):
353
- qos_rule_types.append(
354
- FakeNetworkQosRuleType.create_one_qos_rule_type(attrs)
355
- )
356
-
357
- return qos_rule_types
358
-
359
-
360
- class FakeRouter:
361
- """Fake one or more routers."""
362
-
363
- @staticmethod
364
- def create_one_router(attrs=None):
365
- """Create a fake router.
366
-
367
- :param Dictionary attrs:
368
- A dictionary with all attributes
369
- :return:
370
- A FakeResource object, with id, name, admin_state_up,
371
- status, project_id
372
- """
373
- attrs = attrs or {}
374
-
375
- # Set default attributes.
376
- router_attrs = {
377
- 'id': 'router-id-' + uuid.uuid4().hex,
378
- 'name': 'router-name-' + uuid.uuid4().hex,
379
- 'status': 'ACTIVE',
380
- 'admin_state_up': True,
381
- 'description': 'router-description-' + uuid.uuid4().hex,
382
- 'distributed': False,
383
- 'ha': False,
384
- 'project_id': 'project-id-' + uuid.uuid4().hex,
385
- 'routes': [],
386
- 'external_gateway_info': {},
387
- 'availability_zone_hints': [],
388
- 'availability_zones': [],
389
- 'tags': [],
390
- 'location': 'MUNCHMUNCHMUNCH',
391
- }
392
-
393
- # Overwrite default attributes.
394
- router_attrs.update(attrs)
395
-
396
- router = fakes.FakeResource(
397
- info=copy.deepcopy(router_attrs), loaded=True
398
- )
399
-
400
- # Set attributes with special mapping in OpenStack SDK.
401
- router.is_admin_state_up = router_attrs['admin_state_up']
402
- router.is_distributed = router_attrs['distributed']
403
- router.is_ha = router_attrs['ha']
404
-
405
- return router
406
-
407
- @staticmethod
408
- def create_routers(attrs=None, count=2):
409
- """Create multiple fake routers.
410
-
411
- :param Dictionary attrs:
412
- A dictionary with all attributes
413
- :param int count:
414
- The number of routers to fake
415
- :return:
416
- A list of FakeResource objects faking the routers
417
- """
418
- routers = []
419
- for i in range(0, count):
420
- routers.append(FakeRouter.create_one_router(attrs))
421
-
422
- return routers
423
-
424
- @staticmethod
425
- def get_routers(routers=None, count=2):
426
- """Get an iterable Mock object with a list of faked routers.
427
-
428
- If routers list is provided, then initialize the Mock object with the
429
- list. Otherwise create one.
430
-
431
- :param List routers:
432
- A list of FakeResource objects faking routers
433
- :param int count:
434
- The number of routers to fake
435
- :return:
436
- An iterable Mock object with side_effect set to a list of faked
437
- routers
438
- """
439
- if routers is None:
440
- routers = FakeRouter.create_routers(count)
441
- return mock.Mock(side_effect=routers)
442
-
443
-
444
- class FakeSecurityGroup:
445
- """Fake one or more security groups."""
446
-
447
- @staticmethod
448
- def create_one_security_group(attrs=None):
449
- """Create a fake security group.
450
-
451
- :param Dictionary attrs:
452
- A dictionary with all attributes
453
- :return:
454
- A FakeResource object, with id, name, etc.
455
- """
456
- attrs = attrs or {}
457
-
458
- # Set default attributes.
459
- security_group_attrs = {
460
- 'id': 'security-group-id-' + uuid.uuid4().hex,
461
- 'name': 'security-group-name-' + uuid.uuid4().hex,
462
- 'description': 'security-group-description-' + uuid.uuid4().hex,
463
- 'stateful': True,
464
- 'project_id': 'project-id-' + uuid.uuid4().hex,
465
- 'security_group_rules': [],
466
- 'tags': [],
467
- 'location': 'MUNCHMUNCHMUNCH',
468
- }
469
-
470
- # Overwrite default attributes.
471
- security_group_attrs.update(attrs)
472
-
473
- security_group = fakes.FakeResource(
474
- info=copy.deepcopy(security_group_attrs), loaded=True
475
- )
476
-
477
- return security_group
478
-
479
- @staticmethod
480
- def create_security_groups(attrs=None, count=2):
481
- """Create multiple fake security groups.
482
-
483
- :param Dictionary attrs:
484
- A dictionary with all attributes
485
- :param int count:
486
- The number of security groups to fake
487
- :return:
488
- A list of FakeResource objects faking the security groups
489
- """
490
- security_groups = []
491
- for i in range(0, count):
492
- security_groups.append(
493
- FakeSecurityGroup.create_one_security_group(attrs)
494
- )
495
-
496
- return security_groups
497
-
498
- @staticmethod
499
- def get_security_groups(security_groups=None, count=2):
500
- """Get an iterable Mock object with a list of faked security groups.
501
-
502
- If security groups list is provided, then initialize the Mock object
503
- with the list. Otherwise create one.
504
-
505
- :param List security_groups:
506
- A list of FakeResource objects faking security groups
507
- :param int count:
508
- The number of security groups to fake
509
- :return:
510
- An iterable Mock object with side_effect set to a list of faked
511
- security groups
512
- """
513
- if security_groups is None:
514
- security_groups = FakeSecurityGroup.create_security_groups(count)
515
- return mock.Mock(side_effect=security_groups)
516
-
517
-
518
- class FakeSecurityGroupRule:
519
- """Fake one or more security group rules."""
520
-
521
- @staticmethod
522
- def create_one_security_group_rule(attrs=None):
523
- """Create a fake security group rule.
524
-
525
- :param Dictionary attrs:
526
- A dictionary with all attributes
527
- :return:
528
- A FakeResource object, with id, etc.
529
- """
530
- attrs = attrs or {}
531
-
532
- # Set default attributes.
533
- security_group_rule_attrs = {
534
- 'description': 'security-group-rule-description-'
535
- + uuid.uuid4().hex,
536
- 'direction': 'ingress',
537
- 'ether_type': 'IPv4',
538
- 'id': 'security-group-rule-id-' + uuid.uuid4().hex,
539
- 'port_range_max': None,
540
- 'port_range_min': None,
541
- 'protocol': None,
542
- 'remote_group_id': None,
543
- 'remote_address_group_id': None,
544
- 'remote_ip_prefix': '0.0.0.0/0',
545
- 'security_group_id': 'security-group-id-' + uuid.uuid4().hex,
546
- 'project_id': 'project-id-' + uuid.uuid4().hex,
547
- 'location': 'MUNCHMUNCHMUNCH',
548
- }
549
-
550
- # Overwrite default attributes.
551
- security_group_rule_attrs.update(attrs)
552
-
553
- security_group_rule = fakes.FakeResource(
554
- info=copy.deepcopy(security_group_rule_attrs), loaded=True
555
- )
556
-
557
- return security_group_rule
558
-
559
- @staticmethod
560
- def create_security_group_rules(attrs=None, count=2):
561
- """Create multiple fake security group rules.
562
-
563
- :param Dictionary attrs:
564
- A dictionary with all attributes
565
- :param int count:
566
- The number of security group rules to fake
567
- :return:
568
- A list of FakeResource objects faking the security group rules
569
- """
570
- security_group_rules = []
571
- for i in range(0, count):
572
- security_group_rules.append(
573
- FakeSecurityGroupRule.create_one_security_group_rule(attrs)
574
- )
575
-
576
- return security_group_rules
577
-
578
- @staticmethod
579
- def get_security_group_rules(security_group_rules=None, count=2):
580
- """Get an iterable Mock with a list of faked security group rules.
581
-
582
- If security group rules list is provided, then initialize the Mock
583
- object with the list. Otherwise create one.
584
-
585
- :param List security_group_rules:
586
- A list of FakeResource objects faking security group rules
587
- :param int count:
588
- The number of security group rules to fake
589
- :return:
590
- An iterable Mock object with side_effect set to a list of faked
591
- security group rules
592
- """
593
- if security_group_rules is None:
594
- security_group_rules = (
595
- FakeSecurityGroupRule.create_security_group_rules(count)
596
- )
597
- return mock.Mock(side_effect=security_group_rules)
598
-
599
-
600
137
  class FakeSubnet:
601
138
  """Fake one or more subnets."""
602
139
 
@@ -1856,20 +1393,33 @@ def get_network_rbacs(rbac_policies=None, count=2):
1856
1393
 
1857
1394
 
1858
1395
  def create_one_security_group(attrs=None):
1859
- """Create a security group."""
1396
+ """Create a fake security group.
1397
+
1398
+ :param Dictionary attrs:
1399
+ A dictionary with all attributes
1400
+ :return:
1401
+ A SecurityGroup object, with id, name, etc.
1402
+ """
1860
1403
  attrs = attrs or {}
1861
1404
 
1405
+ # Set default attributes.
1862
1406
  security_group_attrs = {
1863
- 'name': 'security-group-name-' + uuid.uuid4().hex,
1864
1407
  'id': 'security-group-id-' + uuid.uuid4().hex,
1865
- 'project_id': 'project-id-' + uuid.uuid4().hex,
1408
+ 'name': 'security-group-name-' + uuid.uuid4().hex,
1866
1409
  'description': 'security-group-description-' + uuid.uuid4().hex,
1410
+ 'stateful': True,
1411
+ 'project_id': 'project-id-' + uuid.uuid4().hex,
1412
+ 'security_group_rules': [],
1413
+ 'tags': [],
1867
1414
  'location': 'MUNCHMUNCHMUNCH',
1415
+ 'is_shared': False,
1868
1416
  }
1869
1417
 
1418
+ # Overwrite default attributes.
1870
1419
  security_group_attrs.update(attrs)
1871
1420
 
1872
1421
  security_group = _security_group.SecurityGroup(**security_group_attrs)
1422
+ security_group.tenant_id = None # unset deprecated opts
1873
1423
 
1874
1424
  return security_group
1875
1425
 
@@ -1877,9 +1427,12 @@ def create_one_security_group(attrs=None):
1877
1427
  def create_security_groups(attrs=None, count=2):
1878
1428
  """Create multiple fake security groups.
1879
1429
 
1880
- :param dict attrs: A dictionary with all attributes
1881
- :param int count: The number of security groups to fake
1882
- :return: A list of fake SecurityGroup objects
1430
+ :param Dictionary attrs:
1431
+ A dictionary with all attributes
1432
+ :param int count:
1433
+ The number of security groups to fake
1434
+ :return:
1435
+ A list of SecurityGroup objects faking the security groups
1883
1436
  """
1884
1437
  security_groups = []
1885
1438
  for i in range(0, count):
@@ -1888,6 +1441,99 @@ def create_security_groups(attrs=None, count=2):
1888
1441
  return security_groups
1889
1442
 
1890
1443
 
1444
+ def get_security_groups(security_groups=None, count=2):
1445
+ """Get an iterable Mock object with a list of faked security groups.
1446
+
1447
+ If security groups list is provided, then initialize the Mock object
1448
+ with the list. Otherwise create one.
1449
+
1450
+ :param List security_groups:
1451
+ A list of SecurityGroup objects faking security groups
1452
+ :param int count:
1453
+ The number of security groups to fake
1454
+ :return:
1455
+ An iterable Mock object with side_effect set to a list of faked
1456
+ security groups
1457
+ """
1458
+ if security_groups is None:
1459
+ security_groups = create_security_groups(count)
1460
+ return mock.Mock(side_effect=security_groups)
1461
+
1462
+
1463
+ def create_one_security_group_rule(attrs=None):
1464
+ """Create a fake security group rule.
1465
+
1466
+ :param Dictionary attrs:
1467
+ A dictionary with all attributes
1468
+ :return:
1469
+ A FakeResource object, with id, etc.
1470
+ """
1471
+ attrs = attrs or {}
1472
+
1473
+ # Set default attributes.
1474
+ security_group_rule_attrs = {
1475
+ 'description': 'security-group-rule-description-' + uuid.uuid4().hex,
1476
+ 'direction': 'ingress',
1477
+ 'ether_type': 'IPv4',
1478
+ 'id': 'security-group-rule-id-' + uuid.uuid4().hex,
1479
+ 'port_range_max': None,
1480
+ 'port_range_min': None,
1481
+ 'protocol': None,
1482
+ 'remote_group_id': None,
1483
+ 'remote_address_group_id': None,
1484
+ 'remote_ip_prefix': '0.0.0.0/0',
1485
+ 'security_group_id': 'security-group-id-' + uuid.uuid4().hex,
1486
+ 'project_id': 'project-id-' + uuid.uuid4().hex,
1487
+ 'location': 'MUNCHMUNCHMUNCH',
1488
+ }
1489
+
1490
+ # Overwrite default attributes.
1491
+ security_group_rule_attrs.update(attrs)
1492
+
1493
+ security_group_rule = _security_group_rule.SecurityGroupRule(
1494
+ **security_group_rule_attrs
1495
+ )
1496
+ security_group_rule.tenant_id = None # unset deprecated opts
1497
+
1498
+ return security_group_rule
1499
+
1500
+
1501
+ def create_security_group_rules(attrs=None, count=2):
1502
+ """Create multiple fake security group rules.
1503
+
1504
+ :param Dictionary attrs:
1505
+ A dictionary with all attributes
1506
+ :param int count:
1507
+ The number of security group rules to fake
1508
+ :return:
1509
+ A list of SecurityGroupRule objects faking the security group rules
1510
+ """
1511
+ security_group_rules = []
1512
+ for i in range(0, count):
1513
+ security_group_rules.append(create_one_security_group_rule(attrs))
1514
+
1515
+ return security_group_rules
1516
+
1517
+
1518
+ def get_security_group_rules(security_group_rules=None, count=2):
1519
+ """Get an iterable Mock with a list of faked security group rules.
1520
+
1521
+ If security group rules list is provided, then initialize the Mock
1522
+ object with the list. Otherwise create one.
1523
+
1524
+ :param List security_group_rules:
1525
+ A list of SecurityGroupRule objects faking security group rules
1526
+ :param int count:
1527
+ The number of security group rules to fake
1528
+ :return:
1529
+ An iterable Mock object with side_effect set to a list of faked
1530
+ security group rules
1531
+ """
1532
+ if security_group_rules is None:
1533
+ security_group_rules = create_security_group_rules(count)
1534
+ return mock.Mock(side_effect=security_group_rules)
1535
+
1536
+
1891
1537
  def create_one_service_profile(attrs=None):
1892
1538
  """Create service profile."""
1893
1539
  attrs = attrs or {}
@@ -1926,6 +1572,281 @@ def get_service_profile(flavor_profile=None, count=2):
1926
1572
  return mock.Mock(side_effect=flavor_profile)
1927
1573
 
1928
1574
 
1575
+ def create_one_qos_policy(attrs=None):
1576
+ """Create a fake QoS policy.
1577
+
1578
+ :param Dictionary attrs:
1579
+ A dictionary with all attributes
1580
+ :return:
1581
+ A QoSPolicy object with name, id, etc.
1582
+ """
1583
+ attrs = attrs or {}
1584
+ qos_id = attrs.get('id') or 'qos-policy-id-' + uuid.uuid4().hex
1585
+ rules = []
1586
+
1587
+ # Set default attributes.
1588
+ qos_policy_attrs = {
1589
+ 'name': 'qos-policy-name-' + uuid.uuid4().hex,
1590
+ 'id': qos_id,
1591
+ 'is_default': False,
1592
+ 'project_id': 'project-id-' + uuid.uuid4().hex,
1593
+ 'shared': False,
1594
+ 'description': 'qos-policy-description-' + uuid.uuid4().hex,
1595
+ 'rules': rules,
1596
+ 'location': 'MUNCHMUNCHMUNCH',
1597
+ }
1598
+
1599
+ # Overwrite default attributes.
1600
+ qos_policy_attrs.update(attrs)
1601
+
1602
+ qos_policy = _qos_policy.QoSPolicy(**qos_policy_attrs)
1603
+
1604
+ return qos_policy
1605
+
1606
+
1607
+ def create_qos_policies(attrs=None, count=2):
1608
+ """Create multiple fake QoS policies.
1609
+
1610
+ :param Dictionary attrs:
1611
+ A dictionary with all attributes
1612
+ :param int count:
1613
+ The number of QoS policies to fake
1614
+ :return:
1615
+ A list of QoSPolicy objects faking the QoS policies
1616
+ """
1617
+ qos_policies = []
1618
+ for i in range(0, count):
1619
+ qos_policies.append(create_one_qos_policy(attrs))
1620
+
1621
+ return qos_policies
1622
+
1623
+
1624
+ def get_qos_policies(qos_policies=None, count=2):
1625
+ """Get an iterable MagicMock object with a list of faked QoS policies.
1626
+
1627
+ If qos policies list is provided, then initialize the Mock object
1628
+ with the list. Otherwise create one.
1629
+
1630
+ :param List qos_policies:
1631
+ A list of QoSPolicy objects faking qos policies
1632
+ :param int count:
1633
+ The number of QoS policies to fake
1634
+ :return:
1635
+ An iterable Mock object with side_effect set to a list of faked
1636
+ QoS policies
1637
+ """
1638
+ if qos_policies is None:
1639
+ qos_policies = create_qos_policies(count)
1640
+ return mock.Mock(side_effect=qos_policies)
1641
+
1642
+
1643
+ def create_one_qos_rule(attrs=None):
1644
+ """Create a fake Network QoS rule.
1645
+
1646
+ :param Dictionary attrs:
1647
+ A dictionary with all attributes
1648
+ :return:
1649
+ A QoSRule object with id, type, etc.
1650
+ """
1651
+ attrs = attrs or {}
1652
+
1653
+ # Set default attributes.
1654
+ type = attrs.get('type') or choice(VALID_QOS_RULES)
1655
+ qos_rule_attrs = {
1656
+ 'id': 'qos-rule-id-' + uuid.uuid4().hex,
1657
+ 'qos_policy_id': 'qos-policy-id-' + uuid.uuid4().hex,
1658
+ 'project_id': 'project-id-' + uuid.uuid4().hex,
1659
+ 'type': type,
1660
+ 'location': 'MUNCHMUNCHMUNCH',
1661
+ }
1662
+
1663
+ if type == RULE_TYPE_BANDWIDTH_LIMIT:
1664
+ qos_rule_attrs['max_kbps'] = randint(1, 10000)
1665
+ qos_rule_attrs['max_burst_kbps'] = randint(1, 10000)
1666
+ qos_rule_attrs['direction'] = 'egress'
1667
+
1668
+ qos_rule_attrs.update(attrs)
1669
+ qos_rule = _qos_bandwidth_limit_rule.QoSBandwidthLimitRule(
1670
+ **qos_rule_attrs
1671
+ )
1672
+
1673
+ elif type == RULE_TYPE_DSCP_MARKING:
1674
+ qos_rule_attrs['dscp_mark'] = choice(VALID_DSCP_MARKS)
1675
+
1676
+ qos_rule_attrs.update(attrs)
1677
+ qos_rule = _qos_dscp_marking_rule.QoSDSCPMarkingRule(**qos_rule_attrs)
1678
+
1679
+ elif type == RULE_TYPE_MINIMUM_BANDWIDTH:
1680
+ qos_rule_attrs['min_kbps'] = randint(1, 10000)
1681
+ qos_rule_attrs['direction'] = 'egress'
1682
+
1683
+ qos_rule_attrs.update(attrs)
1684
+
1685
+ qos_rule = _qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule(
1686
+ **qos_rule_attrs
1687
+ )
1688
+ else: # type == RULE_TYPE_MINIMUM_PACKET_RATE:
1689
+ qos_rule_attrs['min_kpps'] = randint(1, 10000)
1690
+ qos_rule_attrs['direction'] = 'egress'
1691
+
1692
+ qos_rule_attrs.update(attrs)
1693
+
1694
+ qos_rule = _qos_minimum_packet_rate_rule.QoSMinimumPacketRateRule(
1695
+ **qos_rule_attrs
1696
+ )
1697
+
1698
+ return qos_rule
1699
+
1700
+
1701
+ def create_qos_rules(attrs=None, count=2):
1702
+ """Create multiple fake Network QoS rules.
1703
+
1704
+ :param Dictionary attrs:
1705
+ A dictionary with all attributes
1706
+ :param int count:
1707
+ The number of Network QoS rule to fake
1708
+ :return:
1709
+ A list of QoS Rules objects faking the Network QoS rules
1710
+ """
1711
+ qos_rules = []
1712
+ for i in range(0, count):
1713
+ qos_rules.append(create_one_qos_rule(attrs))
1714
+ return qos_rules
1715
+
1716
+
1717
+ def get_qos_rules(qos_rules=None, count=2):
1718
+ """Get a list of faked Network QoS rules.
1719
+
1720
+ If Network QoS rules list is provided, then initialize the Mock
1721
+ object with the list. Otherwise create one.
1722
+
1723
+ :param List qos_rules:
1724
+ A list of FakeResource objects faking Network QoS rules
1725
+ :param int count:
1726
+ The number of QoS minimum bandwidth rules to fake
1727
+ :return:
1728
+ An iterable Mock object with side_effect set to a list of faked
1729
+ qos minimum bandwidth rules
1730
+ """
1731
+ if qos_rules is None:
1732
+ qos_rules = create_qos_rules(count)
1733
+ return mock.Mock(side_effect=qos_rules)
1734
+
1735
+
1736
+ def create_one_qos_rule_type(attrs=None):
1737
+ """Create a fake Network QoS rule type.
1738
+
1739
+ :param Dictionary attrs:
1740
+ A dictionary with all attributes
1741
+ :return:
1742
+ A QoSRuleType object with name, id, etc.
1743
+ """
1744
+ attrs = attrs or {}
1745
+
1746
+ # Set default attributes.
1747
+ qos_rule_type_attrs = {
1748
+ 'type': 'rule-type-' + uuid.uuid4().hex,
1749
+ 'location': 'MUNCHMUNCHMUNCH',
1750
+ }
1751
+
1752
+ # Overwrite default attributes.
1753
+ qos_rule_type_attrs.update(attrs)
1754
+ qos_rule_type = _qos_rule_type.QoSRuleType(**qos_rule_type_attrs)
1755
+
1756
+ return qos_rule_type
1757
+
1758
+
1759
+ def create_qos_rule_types(attrs=None, count=2):
1760
+ """Create multiple fake Network QoS rule types.
1761
+
1762
+ :param Dictionary attrs:
1763
+ A dictionary with all attributes
1764
+ :param int count:
1765
+ The number of QoS rule types to fake
1766
+ :return:
1767
+ A list of QoSRuleType objects faking the QoS rule types
1768
+ """
1769
+ qos_rule_types = []
1770
+ for i in range(0, count):
1771
+ qos_rule_types.append(create_one_qos_rule_type(attrs))
1772
+
1773
+ return qos_rule_types
1774
+
1775
+
1776
+ def create_one_router(attrs=None):
1777
+ """Create a fake router.
1778
+
1779
+ :param Dictionary attrs:
1780
+ A dictionary with all attributes
1781
+ :return:
1782
+ A Router object, with id, name, admin_state_up,
1783
+ status, project_id
1784
+ """
1785
+ attrs = attrs or {}
1786
+
1787
+ # Set default attributes.
1788
+ router_attrs = {
1789
+ 'id': 'router-id-' + uuid.uuid4().hex,
1790
+ 'name': 'router-name-' + uuid.uuid4().hex,
1791
+ 'status': 'ACTIVE',
1792
+ 'is_admin_state_up': True,
1793
+ 'description': 'router-description-' + uuid.uuid4().hex,
1794
+ 'distributed': False,
1795
+ 'ha': False,
1796
+ 'project_id': 'project-id-' + uuid.uuid4().hex,
1797
+ 'routes': [],
1798
+ 'external_gateway_info': {},
1799
+ 'availability_zone_hints': [],
1800
+ 'availability_zones': [],
1801
+ 'tags': [],
1802
+ 'location': 'MUNCHMUNCHMUNCH',
1803
+ }
1804
+
1805
+ # Overwrite default attributes.
1806
+ router_attrs.update(attrs)
1807
+
1808
+ router = _router.Router(**router_attrs)
1809
+ router.tenant_id = None # unset deprecated opts
1810
+
1811
+ return router
1812
+
1813
+
1814
+ def create_routers(attrs=None, count=2):
1815
+ """Create multiple fake routers.
1816
+
1817
+ :param Dictionary attrs:
1818
+ A dictionary with all attributes
1819
+ :param int count:
1820
+ The number of routers to fake
1821
+ :return:
1822
+ A list of Router objects faking the routers
1823
+ """
1824
+ routers = []
1825
+ for i in range(0, count):
1826
+ routers.append(create_one_router(attrs))
1827
+
1828
+ return routers
1829
+
1830
+
1831
+ def get_routers(routers=None, count=2):
1832
+ """Get an iterable Mock object with a list of faked routers.
1833
+
1834
+ If routers list is provided, then initialize the Mock object with the
1835
+ list. Otherwise create one.
1836
+
1837
+ :param List routers:
1838
+ A list of Router objects faking routers
1839
+ :param int count:
1840
+ The number of routers to fake
1841
+ :return:
1842
+ An iterable Mock object with side_effect set to a list of faked
1843
+ routers
1844
+ """
1845
+ if routers is None:
1846
+ routers = create_routers(count)
1847
+ return mock.Mock(side_effect=routers)
1848
+
1849
+
1929
1850
  def create_one_local_ip(attrs=None):
1930
1851
  """Create a fake local ip.
1931
1852