python-openstackclient 10.0.0__py3-none-any.whl → 10.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/common/availability_zone.py +1 -1
- openstackclient/common/module.py +21 -27
- openstackclient/common/pagination.py +42 -4
- openstackclient/common/project_cleanup.py +1 -2
- openstackclient/common/quota.py +9 -5
- openstackclient/compute/v2/flavor.py +3 -1
- openstackclient/compute/v2/hypervisor.py +2 -0
- openstackclient/compute/v2/keypair.py +6 -2
- openstackclient/compute/v2/server.py +21 -12
- openstackclient/compute/v2/server_event.py +8 -1
- openstackclient/compute/v2/server_group.py +2 -0
- openstackclient/compute/v2/server_migration.py +3 -0
- openstackclient/compute/v2/server_volume.py +3 -1
- openstackclient/compute/v2/service.py +3 -1
- openstackclient/compute/v2/usage.py +2 -2
- openstackclient/identity/common.py +5 -1
- openstackclient/identity/v3/access_rule.py +6 -0
- openstackclient/identity/v3/application_credential.py +10 -3
- openstackclient/identity/v3/credential.py +4 -2
- openstackclient/identity/v3/domain.py +4 -2
- openstackclient/identity/v3/endpoint.py +57 -45
- openstackclient/identity/v3/federation_protocol.py +7 -5
- openstackclient/identity/v3/group.py +11 -10
- openstackclient/identity/v3/identity_provider.py +4 -1
- openstackclient/identity/v3/limit.py +5 -2
- openstackclient/identity/v3/mapping.py +36 -19
- openstackclient/identity/v3/project.py +18 -5
- openstackclient/identity/v3/region.py +4 -2
- openstackclient/identity/v3/registered_limit.py +3 -2
- openstackclient/identity/v3/role.py +2 -1
- openstackclient/identity/v3/role_assignment.py +3 -2
- openstackclient/identity/v3/service.py +4 -2
- openstackclient/identity/v3/service_provider.py +4 -2
- openstackclient/identity/v3/trust.py +8 -5
- openstackclient/identity/v3/user.py +38 -11
- openstackclient/image/v2/cache.py +2 -2
- openstackclient/image/v2/image.py +15 -9
- openstackclient/image/v2/metadef_namespaces.py +11 -10
- openstackclient/image/v2/metadef_objects.py +5 -5
- openstackclient/image/v2/metadef_properties.py +7 -4
- openstackclient/image/v2/task.py +11 -22
- openstackclient/network/utils.py +0 -41
- openstackclient/network/v2/address_group.py +13 -1
- openstackclient/network/v2/address_scope.py +13 -8
- openstackclient/network/v2/bgpvpn/bgpvpn.py +33 -19
- openstackclient/network/v2/bgpvpn/network_association.py +25 -13
- openstackclient/network/v2/bgpvpn/port_association.py +35 -21
- openstackclient/network/v2/bgpvpn/router_association.py +27 -14
- openstackclient/network/v2/default_security_group_rule.py +14 -6
- openstackclient/network/v2/floating_ip.py +12 -4
- openstackclient/network/v2/floating_ip_port_forwarding.py +12 -2
- openstackclient/network/v2/fwaas/group.py +34 -1
- openstackclient/network/v2/fwaas/rule.py +39 -3
- openstackclient/network/v2/ip_availability.py +13 -4
- openstackclient/network/v2/l3_conntrack_helper.py +14 -1
- openstackclient/network/v2/local_ip.py +4 -1
- openstackclient/network/v2/local_ip_association.py +4 -1
- openstackclient/network/v2/ndp_proxy.py +4 -1
- openstackclient/network/v2/network.py +87 -20
- openstackclient/network/v2/network_agent.py +32 -10
- openstackclient/network/v2/network_auto_allocated_topology.py +6 -5
- openstackclient/network/v2/network_flavor.py +19 -6
- openstackclient/network/v2/network_flavor_profile.py +20 -6
- openstackclient/network/v2/network_meter.py +19 -6
- openstackclient/network/v2/network_meter_rule.py +20 -2
- openstackclient/network/v2/network_qos_policy.py +15 -7
- openstackclient/network/v2/network_qos_rule.py +16 -1
- openstackclient/network/v2/network_qos_rule_type.py +16 -5
- openstackclient/network/v2/network_rbac.py +12 -5
- openstackclient/network/v2/network_segment.py +13 -1
- openstackclient/network/v2/network_segment_range.py +15 -3
- openstackclient/network/v2/network_trunk.py +4 -1
- openstackclient/network/v2/port.py +88 -12
- openstackclient/network/v2/router.py +27 -16
- openstackclient/network/v2/security_group.py +18 -49
- openstackclient/network/v2/security_group_rule.py +18 -5
- openstackclient/network/v2/subnet.py +15 -7
- openstackclient/network/v2/subnet_pool.py +13 -8
- openstackclient/network/v2/taas/tap_flow.py +13 -3
- openstackclient/network/v2/taas/tap_mirror.py +7 -4
- openstackclient/network/v2/taas/tap_service.py +4 -1
- openstackclient/object/v1/container.py +3 -1
- openstackclient/object/v1/object.py +3 -1
- openstackclient/tests/functional/identity/v3/common.py +34 -0
- openstackclient/tests/functional/identity/v3/test_application_credential.py +1 -1
- openstackclient/tests/functional/identity/v3/test_mapping.py +81 -0
- openstackclient/tests/functional/volume/v3/test_volume_group.py +163 -0
- openstackclient/tests/unit/common/test_limits.py +1 -1
- openstackclient/tests/unit/common/test_module.py +77 -44
- openstackclient/tests/unit/common/test_quota.py +9 -0
- openstackclient/tests/unit/compute/v2/fakes.py +1 -57
- openstackclient/tests/unit/compute/v2/test_agent.py +4 -4
- openstackclient/tests/unit/compute/v2/test_aggregate.py +1 -1
- openstackclient/tests/unit/compute/v2/test_console.py +2 -2
- openstackclient/tests/unit/compute/v2/test_console_connection.py +1 -1
- openstackclient/tests/unit/compute/v2/test_flavor.py +1 -1
- openstackclient/tests/unit/compute/v2/test_host.py +3 -3
- openstackclient/tests/unit/compute/v2/test_hypervisor.py +2 -2
- openstackclient/tests/unit/compute/v2/test_hypervisor_stats.py +1 -1
- openstackclient/tests/unit/compute/v2/test_keypair.py +1 -1
- openstackclient/tests/unit/compute/v2/test_server.py +15 -15
- openstackclient/tests/unit/compute/v2/test_server_backup.py +1 -1
- openstackclient/tests/unit/compute/v2/test_server_event.py +2 -2
- openstackclient/tests/unit/compute/v2/test_server_group.py +1 -1
- openstackclient/tests/unit/compute/v2/test_server_image.py +1 -1
- openstackclient/tests/unit/compute/v2/test_server_migration.py +4 -4
- openstackclient/tests/unit/compute/v2/test_server_share.py +4 -4
- openstackclient/tests/unit/compute/v2/test_server_volume.py +2 -2
- openstackclient/tests/unit/compute/v2/test_service.py +3 -3
- openstackclient/tests/unit/compute/v2/test_usage.py +1 -1
- openstackclient/tests/unit/identity/v2_0/fakes.py +3 -7
- openstackclient/tests/unit/identity/v2_0/test_endpoint.py +1 -1
- openstackclient/tests/unit/identity/v2_0/test_project.py +1 -1
- openstackclient/tests/unit/identity/v2_0/test_role.py +1 -1
- openstackclient/tests/unit/identity/v2_0/test_role_assignment.py +1 -1
- openstackclient/tests/unit/identity/v2_0/test_service.py +1 -1
- openstackclient/tests/unit/identity/v2_0/test_token.py +2 -2
- openstackclient/tests/unit/identity/v2_0/test_user.py +1 -1
- openstackclient/tests/unit/identity/v3/fakes.py +5 -38
- openstackclient/tests/unit/identity/v3/test_access_rule.py +3 -3
- openstackclient/tests/unit/identity/v3/test_application_credential.py +4 -4
- openstackclient/tests/unit/identity/v3/test_credential.py +5 -5
- openstackclient/tests/unit/identity/v3/test_domain.py +5 -5
- openstackclient/tests/unit/identity/v3/test_endpoint.py +6 -6
- openstackclient/tests/unit/identity/v3/test_endpoint_group.py +1 -1
- openstackclient/tests/unit/identity/v3/test_group.py +8 -8
- openstackclient/tests/unit/identity/v3/test_implied_role.py +1 -1
- openstackclient/tests/unit/identity/v3/test_limit.py +5 -5
- openstackclient/tests/unit/identity/v3/test_mappings.py +163 -79
- openstackclient/tests/unit/identity/v3/test_project.py +28 -5
- openstackclient/tests/unit/identity/v3/test_protocol.py +3 -3
- openstackclient/tests/unit/identity/v3/test_region.py +5 -5
- openstackclient/tests/unit/identity/v3/test_registered_limit.py +5 -5
- openstackclient/tests/unit/identity/v3/test_role.py +8 -8
- openstackclient/tests/unit/identity/v3/test_role_assignment.py +1 -1
- openstackclient/tests/unit/identity/v3/test_service.py +5 -5
- openstackclient/tests/unit/identity/v3/test_token.py +2 -2
- openstackclient/tests/unit/identity/v3/test_trust.py +4 -4
- openstackclient/tests/unit/identity/v3/test_user.py +73 -6
- openstackclient/tests/unit/network/v2/fakes.py +5 -77
- openstackclient/tests/unit/network/v2/fwaas/test_group.py +28 -2
- openstackclient/tests/unit/network/v2/fwaas/test_rule.py +28 -3
- openstackclient/tests/unit/network/v2/test_address_group.py +24 -0
- openstackclient/tests/unit/network/v2/test_address_scope.py +24 -0
- openstackclient/tests/unit/network/v2/test_floating_ip.py +24 -0
- openstackclient/tests/unit/network/v2/test_floating_ip_port_forwarding.py +24 -0
- openstackclient/tests/unit/network/v2/test_ip_availability.py +25 -0
- openstackclient/tests/unit/network/v2/test_l3_conntrack_helper.py +29 -3
- openstackclient/tests/unit/network/v2/test_network.py +74 -12
- openstackclient/tests/unit/network/v2/test_network_agent.py +50 -1
- openstackclient/tests/unit/network/v2/test_network_flavor.py +24 -0
- openstackclient/tests/unit/network/v2/test_network_flavor_profile.py +24 -0
- openstackclient/tests/unit/network/v2/test_network_meter.py +24 -0
- openstackclient/tests/unit/network/v2/test_network_qos_policy.py +24 -0
- openstackclient/tests/unit/network/v2/test_network_qos_rule_type.py +24 -0
- openstackclient/tests/unit/network/v2/test_network_rbac.py +24 -0
- openstackclient/tests/unit/network/v2/test_network_segment.py +24 -0
- openstackclient/tests/unit/network/v2/test_network_segment_range.py +24 -0
- openstackclient/tests/unit/network/v2/test_port.py +166 -0
- openstackclient/tests/unit/network/v2/test_router.py +28 -7
- openstackclient/tests/unit/network/v2/test_security_group.py +22 -0
- openstackclient/tests/unit/network/v2/test_security_group_rule.py +25 -0
- openstackclient/tests/unit/network/v2/test_subnet.py +28 -4
- openstackclient/tests/unit/network/v2/test_subnet_pool.py +24 -0
- openstackclient/tests/unit/volume/v2/fakes.py +20 -140
- openstackclient/tests/unit/volume/v2/test_volume_backup.py +5 -9
- openstackclient/tests/unit/volume/v2/test_volume_snapshot.py +6 -0
- openstackclient/tests/unit/volume/v3/fakes.py +204 -100
- openstackclient/tests/unit/volume/v3/test_backup_record.py +114 -0
- openstackclient/tests/unit/volume/v3/test_consistency_group.py +720 -0
- openstackclient/tests/unit/volume/v3/test_consistency_group_snapshot.py +354 -0
- openstackclient/tests/unit/volume/v3/test_qos_specs.py +455 -0
- openstackclient/tests/unit/volume/v3/test_volume_attachment.py +2 -0
- openstackclient/tests/unit/volume/v3/test_volume_backend.py +158 -0
- openstackclient/tests/unit/volume/v3/test_volume_backup.py +5 -9
- openstackclient/tests/unit/volume/v3/test_volume_group_type.py +65 -0
- openstackclient/tests/unit/volume/v3/test_volume_host.py +115 -0
- openstackclient/tests/unit/volume/v3/test_volume_snapshot.py +6 -0
- openstackclient/volume/v2/volume.py +4 -2
- openstackclient/volume/v2/volume_backup.py +2 -3
- openstackclient/volume/v2/volume_snapshot.py +3 -4
- openstackclient/volume/v3/backup_record.py +94 -0
- openstackclient/volume/v3/consistency_group.py +400 -0
- openstackclient/volume/v3/consistency_group_snapshot.py +225 -0
- openstackclient/volume/v3/qos_specs.py +389 -0
- openstackclient/volume/v3/volume.py +4 -2
- openstackclient/volume/v3/volume_attachment.py +5 -1
- openstackclient/volume/v3/volume_backend.py +130 -0
- openstackclient/volume/v3/volume_backup.py +2 -3
- openstackclient/volume/v3/volume_group_snapshot.py +4 -6
- openstackclient/volume/v3/volume_group_type.py +1 -1
- openstackclient/volume/v3/volume_host.py +74 -0
- openstackclient/volume/v3/volume_message.py +3 -1
- openstackclient/volume/v3/volume_snapshot.py +2 -1
- {python_openstackclient-10.0.0.dist-info → python_openstackclient-10.1.0.dist-info}/METADATA +3 -4
- {python_openstackclient-10.0.0.dist-info → python_openstackclient-10.1.0.dist-info}/RECORD +202 -188
- {python_openstackclient-10.0.0.dist-info → python_openstackclient-10.1.0.dist-info}/entry_points.txt +24 -24
- {python_openstackclient-10.0.0.dist-info → python_openstackclient-10.1.0.dist-info}/licenses/AUTHORS +5 -0
- python_openstackclient-10.1.0.dist-info/pbr.json +1 -0
- python_openstackclient-10.0.0.dist-info/pbr.json +0 -1
- {python_openstackclient-10.0.0.dist-info → python_openstackclient-10.1.0.dist-info}/WHEEL +0 -0
- {python_openstackclient-10.0.0.dist-info → python_openstackclient-10.1.0.dist-info}/licenses/LICENSE +0 -0
- {python_openstackclient-10.0.0.dist-info → python_openstackclient-10.1.0.dist-info}/top_level.txt +0 -0
|
@@ -343,6 +343,7 @@ class TestVolumeSnapshotList(volume_fakes.TestVolume):
|
|
|
343
343
|
self.volume_sdk_client.snapshots.assert_called_once_with(
|
|
344
344
|
limit=None,
|
|
345
345
|
marker=None,
|
|
346
|
+
max_items=None,
|
|
346
347
|
all_projects=False,
|
|
347
348
|
name=None,
|
|
348
349
|
status=None,
|
|
@@ -376,6 +377,7 @@ class TestVolumeSnapshotList(volume_fakes.TestVolume):
|
|
|
376
377
|
self.volume_sdk_client.snapshots.assert_called_once_with(
|
|
377
378
|
limit=2,
|
|
378
379
|
marker=self.snapshots[0].id,
|
|
380
|
+
max_items=None,
|
|
379
381
|
all_projects=True,
|
|
380
382
|
project_id=self.project.id,
|
|
381
383
|
name=None,
|
|
@@ -397,6 +399,7 @@ class TestVolumeSnapshotList(volume_fakes.TestVolume):
|
|
|
397
399
|
self.volume_sdk_client.snapshots.assert_called_once_with(
|
|
398
400
|
limit=None,
|
|
399
401
|
marker=None,
|
|
402
|
+
max_items=None,
|
|
400
403
|
all_projects=True,
|
|
401
404
|
name=None,
|
|
402
405
|
status=None,
|
|
@@ -423,6 +426,7 @@ class TestVolumeSnapshotList(volume_fakes.TestVolume):
|
|
|
423
426
|
self.volume_sdk_client.snapshots.assert_called_once_with(
|
|
424
427
|
limit=None,
|
|
425
428
|
marker=None,
|
|
429
|
+
max_items=None,
|
|
426
430
|
all_projects=False,
|
|
427
431
|
name=self.snapshots[0].name,
|
|
428
432
|
status=None,
|
|
@@ -449,6 +453,7 @@ class TestVolumeSnapshotList(volume_fakes.TestVolume):
|
|
|
449
453
|
self.volume_sdk_client.snapshots.assert_called_once_with(
|
|
450
454
|
limit=None,
|
|
451
455
|
marker=None,
|
|
456
|
+
max_items=None,
|
|
452
457
|
all_projects=False,
|
|
453
458
|
name=None,
|
|
454
459
|
status='available',
|
|
@@ -475,6 +480,7 @@ class TestVolumeSnapshotList(volume_fakes.TestVolume):
|
|
|
475
480
|
self.volume_sdk_client.snapshots.assert_called_once_with(
|
|
476
481
|
limit=None,
|
|
477
482
|
marker=None,
|
|
483
|
+
max_items=None,
|
|
478
484
|
all_projects=False,
|
|
479
485
|
name=None,
|
|
480
486
|
status=None,
|
|
@@ -40,12 +40,10 @@ class FakeVolumeClient:
|
|
|
40
40
|
self.management_url = kwargs['endpoint']
|
|
41
41
|
self.api_version = api_versions.APIVersion('3.0')
|
|
42
42
|
|
|
43
|
-
self.attachments = mock.Mock()
|
|
44
|
-
self.attachments.resource_class = fakes.FakeResource(None, {})
|
|
45
|
-
self.availability_zones = mock.Mock()
|
|
46
|
-
self.availability_zones.resource_class = fakes.FakeResource(None, {})
|
|
47
43
|
self.backups = mock.Mock()
|
|
48
44
|
self.backups.resource_class = fakes.FakeResource(None, {})
|
|
45
|
+
self.cgsnapshots = mock.Mock()
|
|
46
|
+
self.cgsnapshots.resource_class = fakes.FakeResource(None, {})
|
|
49
47
|
self.consistencygroups = mock.Mock()
|
|
50
48
|
self.consistencygroups.resource_class = fakes.FakeResource(None, {})
|
|
51
49
|
self.clusters = mock.Mock()
|
|
@@ -58,10 +56,10 @@ class FakeVolumeClient:
|
|
|
58
56
|
self.group_types.resource_class = fakes.FakeResource(None, {})
|
|
59
57
|
self.messages = mock.Mock()
|
|
60
58
|
self.messages.resource_class = fakes.FakeResource(None, {})
|
|
61
|
-
self.
|
|
62
|
-
self.
|
|
63
|
-
self.
|
|
64
|
-
self.
|
|
59
|
+
self.qos_specs = mock.Mock()
|
|
60
|
+
self.qos_specs.resource_class = fakes.FakeResource(None, {})
|
|
61
|
+
self.services = mock.Mock()
|
|
62
|
+
self.services.resource_class = fakes.FakeResource(None, {})
|
|
65
63
|
self.transfers = mock.Mock()
|
|
66
64
|
self.transfers.resource_class = fakes.FakeResource(None, {})
|
|
67
65
|
self.volume_encryption_types = mock.Mock()
|
|
@@ -76,8 +74,6 @@ class FakeVolumeClient:
|
|
|
76
74
|
self.volume_types.resource_class = fakes.FakeResource(None, {})
|
|
77
75
|
self.volumes = mock.Mock()
|
|
78
76
|
self.volumes.resource_class = fakes.FakeResource(None, {})
|
|
79
|
-
self.services = mock.Mock()
|
|
80
|
-
self.services.resource_class = fakes.FakeResource(None, {})
|
|
81
77
|
self.workers = mock.Mock()
|
|
82
78
|
self.workers.resource_class = fakes.FakeResource(None, {})
|
|
83
79
|
|
|
@@ -140,6 +136,8 @@ class TestVolume(
|
|
|
140
136
|
|
|
141
137
|
|
|
142
138
|
# TODO(stephenfin): Check if the responses are actually the same
|
|
139
|
+
create_one_capability = volume_v2_fakes.create_one_capability
|
|
140
|
+
create_one_pool = volume_v2_fakes.create_one_pool
|
|
143
141
|
create_one_snapshot = volume_v2_fakes.create_one_snapshot
|
|
144
142
|
create_one_service = volume_v2_fakes.create_one_service
|
|
145
143
|
|
|
@@ -232,6 +230,99 @@ def create_consistency_groups(attrs=None, count=2):
|
|
|
232
230
|
return consistency_groups
|
|
233
231
|
|
|
234
232
|
|
|
233
|
+
def get_consistency_groups(consistency_groups=None, count=2):
|
|
234
|
+
"""Note:
|
|
235
|
+
|
|
236
|
+
Get an iterable MagicMock object with a list of faked
|
|
237
|
+
consistency_groups.
|
|
238
|
+
|
|
239
|
+
If consistency_groups list is provided, then initialize
|
|
240
|
+
the Mock object with the list. Otherwise create one.
|
|
241
|
+
|
|
242
|
+
:param List consistency_groups:
|
|
243
|
+
A list of FakeResource objects faking consistency_groups
|
|
244
|
+
:param Integer count:
|
|
245
|
+
The number of consistency_groups to be faked
|
|
246
|
+
:return
|
|
247
|
+
An iterable Mock object with side_effect set to a list of faked
|
|
248
|
+
consistency_groups
|
|
249
|
+
"""
|
|
250
|
+
if consistency_groups is None:
|
|
251
|
+
consistency_groups = create_consistency_groups(count)
|
|
252
|
+
|
|
253
|
+
return mock.Mock(side_effect=consistency_groups)
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
def create_one_consistency_group_snapshot(attrs=None):
|
|
257
|
+
"""Create a fake consistency group snapshot.
|
|
258
|
+
|
|
259
|
+
:param dict attrs:
|
|
260
|
+
A dictionary with all attributes
|
|
261
|
+
:return:
|
|
262
|
+
A FakeResource object with id, name, description, etc.
|
|
263
|
+
"""
|
|
264
|
+
attrs = attrs or {}
|
|
265
|
+
|
|
266
|
+
# Set default attributes.
|
|
267
|
+
consistency_group_snapshot_info = {
|
|
268
|
+
"id": 'id-' + uuid.uuid4().hex,
|
|
269
|
+
"name": 'backup-name-' + uuid.uuid4().hex,
|
|
270
|
+
"description": 'description-' + uuid.uuid4().hex,
|
|
271
|
+
"status": "error",
|
|
272
|
+
"consistencygroup_id": 'consistency-group-id' + uuid.uuid4().hex,
|
|
273
|
+
"created_at": 'time-' + uuid.uuid4().hex,
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
# Overwrite default attributes.
|
|
277
|
+
consistency_group_snapshot_info.update(attrs)
|
|
278
|
+
|
|
279
|
+
consistency_group_snapshot = fakes.FakeResource(
|
|
280
|
+
info=copy.deepcopy(consistency_group_snapshot_info), loaded=True
|
|
281
|
+
)
|
|
282
|
+
return consistency_group_snapshot
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
def create_consistency_group_snapshots(attrs=None, count=2):
|
|
286
|
+
"""Create multiple fake consistency group snapshots.
|
|
287
|
+
|
|
288
|
+
:param dict attrs:
|
|
289
|
+
A dictionary with all attributes
|
|
290
|
+
:param int count:
|
|
291
|
+
The number of consistency group snapshots to fake
|
|
292
|
+
:return:
|
|
293
|
+
A list of FakeResource objects faking the
|
|
294
|
+
consistency group snapshots
|
|
295
|
+
"""
|
|
296
|
+
consistency_group_snapshots = []
|
|
297
|
+
for i in range(0, count):
|
|
298
|
+
consistency_group_snapshot = create_one_consistency_group_snapshot(
|
|
299
|
+
attrs,
|
|
300
|
+
)
|
|
301
|
+
consistency_group_snapshots.append(consistency_group_snapshot)
|
|
302
|
+
|
|
303
|
+
return consistency_group_snapshots
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
def get_consistency_group_snapshots(snapshots=None, count=2):
|
|
307
|
+
"""Get an iterable MagicMock object with a list of faked cgsnapshots.
|
|
308
|
+
|
|
309
|
+
If consistenct group snapshots list is provided, then initialize
|
|
310
|
+
the Mock object with the list. Otherwise create one.
|
|
311
|
+
|
|
312
|
+
:param List snapshots:
|
|
313
|
+
A list of FakeResource objects faking consistency group snapshots
|
|
314
|
+
:param Integer count:
|
|
315
|
+
The number of consistency group snapshots to be faked
|
|
316
|
+
:return
|
|
317
|
+
An iterable Mock object with side_effect set to a list of faked
|
|
318
|
+
consistency groups
|
|
319
|
+
"""
|
|
320
|
+
if snapshots is None:
|
|
321
|
+
snapshots = create_consistency_group_snapshots(count)
|
|
322
|
+
|
|
323
|
+
return mock.Mock(side_effect=snapshots)
|
|
324
|
+
|
|
325
|
+
|
|
235
326
|
def create_one_extension(attrs=None):
|
|
236
327
|
"""Create a fake extension.
|
|
237
328
|
|
|
@@ -304,42 +395,33 @@ def create_one_backup(attrs=None):
|
|
|
304
395
|
return backup
|
|
305
396
|
|
|
306
397
|
|
|
307
|
-
def
|
|
308
|
-
"""
|
|
398
|
+
def create_backup_record():
|
|
399
|
+
"""Gets a fake backup record for a given backup.
|
|
309
400
|
|
|
310
|
-
:
|
|
311
|
-
A dictionary with all attributes
|
|
312
|
-
:param int count:
|
|
313
|
-
The number of backups to fake
|
|
314
|
-
:return: A list of fake
|
|
315
|
-
openstack.block_storage.v3.backup.Backup objects
|
|
401
|
+
:return: An "exported" backup record.
|
|
316
402
|
"""
|
|
317
|
-
backups = []
|
|
318
|
-
for i in range(0, count):
|
|
319
|
-
backup = create_one_backup(attrs)
|
|
320
|
-
backups.append(backup)
|
|
321
403
|
|
|
322
|
-
return
|
|
404
|
+
return {
|
|
405
|
+
'backup_service': 'cinder.backup.drivers.swift.SwiftBackupDriver',
|
|
406
|
+
'backup_url': 'eyJzdGF0dXMiOiAiYXZh',
|
|
407
|
+
}
|
|
323
408
|
|
|
324
409
|
|
|
325
|
-
def
|
|
326
|
-
"""
|
|
410
|
+
def import_backup_record():
|
|
411
|
+
"""Creates a fake backup record import response from a backup.
|
|
327
412
|
|
|
328
|
-
|
|
329
|
-
list. Otherwise create one.
|
|
330
|
-
|
|
331
|
-
:param List backups:
|
|
332
|
-
A list of FakeResource objects faking backups
|
|
333
|
-
:param Integer count:
|
|
334
|
-
The number of backups to be faked
|
|
335
|
-
:return
|
|
336
|
-
An iterable Mock object with side_effect set to a list of faked
|
|
337
|
-
backups
|
|
413
|
+
:return: The fake backup object that was encoded.
|
|
338
414
|
"""
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
415
|
+
return {
|
|
416
|
+
'backup': {
|
|
417
|
+
'id': 'backup.id',
|
|
418
|
+
'name': 'backup.name',
|
|
419
|
+
'links': [
|
|
420
|
+
{'href': 'link1', 'rel': 'self'},
|
|
421
|
+
{'href': 'link2', 'rel': 'bookmark'},
|
|
422
|
+
],
|
|
423
|
+
},
|
|
424
|
+
}
|
|
343
425
|
|
|
344
426
|
|
|
345
427
|
def create_one_cluster(attrs=None):
|
|
@@ -713,23 +795,6 @@ def create_one_sdk_volume(attrs=None):
|
|
|
713
795
|
return _volume.Volume(**volume_info)
|
|
714
796
|
|
|
715
797
|
|
|
716
|
-
def create_sdk_volumes(attrs=None, count=2):
|
|
717
|
-
"""Create multiple fake volumes.
|
|
718
|
-
|
|
719
|
-
:param dict attrs:
|
|
720
|
-
A dictionary with all attributes of volume
|
|
721
|
-
:param Integer count:
|
|
722
|
-
The number of volumes to be faked
|
|
723
|
-
:return:
|
|
724
|
-
A list of FakeResource objects
|
|
725
|
-
"""
|
|
726
|
-
volumes = []
|
|
727
|
-
for n in range(0, count):
|
|
728
|
-
volumes.append(create_one_sdk_volume(attrs))
|
|
729
|
-
|
|
730
|
-
return volumes
|
|
731
|
-
|
|
732
|
-
|
|
733
798
|
def create_one_volume_group(attrs=None):
|
|
734
799
|
"""Create a fake group.
|
|
735
800
|
|
|
@@ -811,20 +876,6 @@ def create_one_volume_group_snapshot(attrs=None, methods=None):
|
|
|
811
876
|
return group_snapshot
|
|
812
877
|
|
|
813
878
|
|
|
814
|
-
def create_volume_group_snapshots(attrs=None, count=2):
|
|
815
|
-
"""Create multiple fake group snapshots.
|
|
816
|
-
|
|
817
|
-
:param attrs: A dictionary with all attributes of group snapshot
|
|
818
|
-
:param count: The number of group snapshots to be faked
|
|
819
|
-
:return: A list of FakeResource objects
|
|
820
|
-
"""
|
|
821
|
-
group_snapshots = []
|
|
822
|
-
for n in range(0, count):
|
|
823
|
-
group_snapshots.append(create_one_volume_group_snapshot(attrs))
|
|
824
|
-
|
|
825
|
-
return group_snapshots
|
|
826
|
-
|
|
827
|
-
|
|
828
879
|
def create_one_volume_group_type(attrs=None, methods=None):
|
|
829
880
|
"""Create a fake group type.
|
|
830
881
|
|
|
@@ -994,22 +1045,93 @@ def create_volume_attachments(attrs=None, count=2):
|
|
|
994
1045
|
return attachments
|
|
995
1046
|
|
|
996
1047
|
|
|
997
|
-
def
|
|
998
|
-
"""
|
|
1048
|
+
def create_one_qos(attrs=None):
|
|
1049
|
+
"""Create a fake Qos specification.
|
|
999
1050
|
|
|
1000
|
-
|
|
1001
|
-
|
|
1051
|
+
:param dict attrs:
|
|
1052
|
+
A dictionary with all attributes
|
|
1053
|
+
:return:
|
|
1054
|
+
A FakeResource object with id, name, consumer, etc.
|
|
1055
|
+
"""
|
|
1056
|
+
attrs = attrs or {}
|
|
1002
1057
|
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1058
|
+
# Set default attributes.
|
|
1059
|
+
qos_info = {
|
|
1060
|
+
"id": 'qos-id-' + uuid.uuid4().hex,
|
|
1061
|
+
"name": 'qos-name-' + uuid.uuid4().hex,
|
|
1062
|
+
"consumer": 'front-end',
|
|
1063
|
+
"specs": {"foo": "bar", "iops": "9001"},
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
# Overwrite default attributes.
|
|
1067
|
+
qos_info.update(attrs)
|
|
1068
|
+
|
|
1069
|
+
qos = fakes.FakeResource(info=copy.deepcopy(qos_info), loaded=True)
|
|
1070
|
+
return qos
|
|
1071
|
+
|
|
1072
|
+
|
|
1073
|
+
def create_one_qos_association(attrs=None):
|
|
1074
|
+
"""Create a fake Qos specification association.
|
|
1075
|
+
|
|
1076
|
+
:param dict attrs:
|
|
1077
|
+
A dictionary with all attributes
|
|
1078
|
+
:return:
|
|
1079
|
+
A FakeResource object with id, name, association_type, etc.
|
|
1008
1080
|
"""
|
|
1009
|
-
|
|
1010
|
-
attachments = create_volume_attachments(count)
|
|
1081
|
+
attrs = attrs or {}
|
|
1011
1082
|
|
|
1012
|
-
|
|
1083
|
+
# Set default attributes.
|
|
1084
|
+
qos_association_info = {
|
|
1085
|
+
"id": 'type-id-' + uuid.uuid4().hex,
|
|
1086
|
+
"name": 'type-name-' + uuid.uuid4().hex,
|
|
1087
|
+
"association_type": 'volume_type',
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
# Overwrite default attributes.
|
|
1091
|
+
qos_association_info.update(attrs)
|
|
1092
|
+
|
|
1093
|
+
qos_association = fakes.FakeResource(
|
|
1094
|
+
info=copy.deepcopy(qos_association_info), loaded=True
|
|
1095
|
+
)
|
|
1096
|
+
return qos_association
|
|
1097
|
+
|
|
1098
|
+
|
|
1099
|
+
def create_qoses(attrs=None, count=2):
|
|
1100
|
+
"""Create multiple fake Qos specifications.
|
|
1101
|
+
|
|
1102
|
+
:param dict attrs:
|
|
1103
|
+
A dictionary with all attributes
|
|
1104
|
+
:param int count:
|
|
1105
|
+
The number of Qos specifications to fake
|
|
1106
|
+
:return:
|
|
1107
|
+
A list of FakeResource objects faking the Qos specifications
|
|
1108
|
+
"""
|
|
1109
|
+
qoses = []
|
|
1110
|
+
for i in range(0, count):
|
|
1111
|
+
qos = create_one_qos(attrs)
|
|
1112
|
+
qoses.append(qos)
|
|
1113
|
+
|
|
1114
|
+
return qoses
|
|
1115
|
+
|
|
1116
|
+
|
|
1117
|
+
def get_qoses(qoses=None, count=2):
|
|
1118
|
+
"""Get an iterable MagicMock object with a list of faked qoses.
|
|
1119
|
+
|
|
1120
|
+
If qoses list is provided, then initialize the Mock object with the
|
|
1121
|
+
list. Otherwise create one.
|
|
1122
|
+
|
|
1123
|
+
:param List qoses:
|
|
1124
|
+
A list of FakeResource objects faking qoses
|
|
1125
|
+
:param Integer count:
|
|
1126
|
+
The number of qoses to be faked
|
|
1127
|
+
:return
|
|
1128
|
+
An iterable Mock object with side_effect set to a list of faked
|
|
1129
|
+
qoses
|
|
1130
|
+
"""
|
|
1131
|
+
if qoses is None:
|
|
1132
|
+
qoses = create_qoses(count)
|
|
1133
|
+
|
|
1134
|
+
return mock.Mock(side_effect=qoses)
|
|
1013
1135
|
|
|
1014
1136
|
|
|
1015
1137
|
def create_one_volume_type(attrs=None, methods=None):
|
|
@@ -1081,24 +1203,6 @@ def get_volume_types(volume_types=None, count=2):
|
|
|
1081
1203
|
return mock.Mock(side_effect=volume_types)
|
|
1082
1204
|
|
|
1083
1205
|
|
|
1084
|
-
def create_service_log_level_entry(attrs=None):
|
|
1085
|
-
service_log_level_info = {
|
|
1086
|
-
'host': 'host_test',
|
|
1087
|
-
'binary': 'cinder-api',
|
|
1088
|
-
'prefix': 'cinder.api.common',
|
|
1089
|
-
'level': 'DEBUG',
|
|
1090
|
-
}
|
|
1091
|
-
# Overwrite default attributes if there are some attributes set
|
|
1092
|
-
attrs = attrs or {}
|
|
1093
|
-
|
|
1094
|
-
service_log_level_info.update(attrs)
|
|
1095
|
-
|
|
1096
|
-
service_log_level = fakes.FakeResource(
|
|
1097
|
-
None, service_log_level_info, loaded=True
|
|
1098
|
-
)
|
|
1099
|
-
return service_log_level
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
1206
|
def create_cleanup_records():
|
|
1103
1207
|
"""Create fake service cleanup records.
|
|
1104
1208
|
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
3
|
+
# not use this file except in compliance with the License. You may obtain
|
|
4
|
+
# a copy of the License at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
10
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
11
|
+
# License for the specific language governing permissions and limitations
|
|
12
|
+
# under the License.
|
|
13
|
+
|
|
14
|
+
from openstackclient.tests.unit.volume.v3 import fakes as volume_fakes
|
|
15
|
+
from openstackclient.volume.v3 import backup_record
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class TestBackupRecord(volume_fakes.TestVolume):
|
|
19
|
+
def setUp(self):
|
|
20
|
+
super().setUp()
|
|
21
|
+
|
|
22
|
+
self.backups_mock = self.volume_client.backups
|
|
23
|
+
self.backups_mock.reset_mock()
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class TestBackupRecordExport(TestBackupRecord):
|
|
27
|
+
new_backup = volume_fakes.create_one_backup(
|
|
28
|
+
attrs={'volume_id': 'a54708a2-0388-4476-a909-09579f885c25'},
|
|
29
|
+
)
|
|
30
|
+
new_record = volume_fakes.create_backup_record()
|
|
31
|
+
|
|
32
|
+
def setUp(self):
|
|
33
|
+
super().setUp()
|
|
34
|
+
|
|
35
|
+
self.backups_mock.export_record.return_value = self.new_record
|
|
36
|
+
self.backups_mock.get.return_value = self.new_backup
|
|
37
|
+
|
|
38
|
+
# Get the command object to mock
|
|
39
|
+
self.cmd = backup_record.ExportBackupRecord(self.app, None)
|
|
40
|
+
|
|
41
|
+
def test_backup_export_table(self):
|
|
42
|
+
arglist = [
|
|
43
|
+
self.new_backup.name,
|
|
44
|
+
]
|
|
45
|
+
verifylist = [
|
|
46
|
+
("backup", self.new_backup.name),
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
50
|
+
parsed_args.formatter = 'table'
|
|
51
|
+
columns, __ = self.cmd.take_action(parsed_args)
|
|
52
|
+
|
|
53
|
+
self.backups_mock.export_record.assert_called_with(
|
|
54
|
+
self.new_backup.id,
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
expected_columns = ('Backup Service', 'Metadata')
|
|
58
|
+
self.assertEqual(columns, expected_columns)
|
|
59
|
+
|
|
60
|
+
def test_backup_export_json(self):
|
|
61
|
+
arglist = [
|
|
62
|
+
self.new_backup.name,
|
|
63
|
+
]
|
|
64
|
+
verifylist = [
|
|
65
|
+
("backup", self.new_backup.name),
|
|
66
|
+
]
|
|
67
|
+
|
|
68
|
+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
69
|
+
parsed_args.formatter = 'json'
|
|
70
|
+
columns, __ = self.cmd.take_action(parsed_args)
|
|
71
|
+
|
|
72
|
+
self.backups_mock.export_record.assert_called_with(
|
|
73
|
+
self.new_backup.id,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
expected_columns = ('backup_service', 'backup_url')
|
|
77
|
+
self.assertEqual(columns, expected_columns)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class TestBackupRecordImport(TestBackupRecord):
|
|
81
|
+
new_backup = volume_fakes.create_one_backup(
|
|
82
|
+
attrs={'volume_id': 'a54708a2-0388-4476-a909-09579f885c25'},
|
|
83
|
+
)
|
|
84
|
+
new_import = volume_fakes.import_backup_record()
|
|
85
|
+
|
|
86
|
+
def setUp(self):
|
|
87
|
+
super().setUp()
|
|
88
|
+
|
|
89
|
+
self.backups_mock.import_record.return_value = self.new_import
|
|
90
|
+
|
|
91
|
+
# Get the command object to mock
|
|
92
|
+
self.cmd = backup_record.ImportBackupRecord(self.app, None)
|
|
93
|
+
|
|
94
|
+
def test_backup_import(self):
|
|
95
|
+
arglist = [
|
|
96
|
+
"cinder.backup.drivers.swift.SwiftBackupDriver",
|
|
97
|
+
"fake_backup_record_data",
|
|
98
|
+
]
|
|
99
|
+
verifylist = [
|
|
100
|
+
(
|
|
101
|
+
"backup_service",
|
|
102
|
+
"cinder.backup.drivers.swift.SwiftBackupDriver",
|
|
103
|
+
),
|
|
104
|
+
("backup_metadata", "fake_backup_record_data"),
|
|
105
|
+
]
|
|
106
|
+
|
|
107
|
+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
108
|
+
columns, __ = self.cmd.take_action(parsed_args)
|
|
109
|
+
|
|
110
|
+
self.backups_mock.import_record.assert_called_with(
|
|
111
|
+
"cinder.backup.drivers.swift.SwiftBackupDriver",
|
|
112
|
+
"fake_backup_record_data",
|
|
113
|
+
)
|
|
114
|
+
self.assertEqual(columns, ('backup',))
|