python-openstackclient 7.4.0__py3-none-any.whl → 8.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openstackclient/common/availability_zone.py +3 -6
- openstackclient/common/clientmanager.py +2 -1
- openstackclient/common/envvars.py +57 -0
- openstackclient/common/extension.py +3 -11
- openstackclient/common/limits.py +1 -1
- openstackclient/common/project_cleanup.py +3 -2
- openstackclient/common/quota.py +54 -28
- openstackclient/compute/client.py +2 -5
- openstackclient/compute/v2/agent.py +5 -5
- openstackclient/compute/v2/aggregate.py +17 -15
- openstackclient/compute/v2/console.py +3 -4
- openstackclient/compute/v2/flavor.py +14 -18
- openstackclient/compute/v2/host.py +3 -3
- openstackclient/compute/v2/hypervisor.py +10 -4
- openstackclient/compute/v2/hypervisor_stats.py +1 -1
- openstackclient/compute/v2/keypair.py +8 -10
- openstackclient/compute/v2/server.py +70 -112
- openstackclient/compute/v2/server_backup.py +1 -1
- openstackclient/compute/v2/server_event.py +7 -16
- openstackclient/compute/v2/server_group.py +6 -6
- openstackclient/compute/v2/server_image.py +1 -1
- openstackclient/compute/v2/server_migration.py +6 -6
- openstackclient/compute/v2/server_volume.py +4 -4
- openstackclient/compute/v2/service.py +9 -13
- openstackclient/compute/v2/usage.py +4 -6
- openstackclient/identity/client.py +2 -4
- openstackclient/identity/common.py +16 -17
- openstackclient/identity/v2_0/ec2creds.py +4 -3
- openstackclient/identity/v2_0/endpoint.py +12 -10
- openstackclient/identity/v2_0/project.py +6 -6
- openstackclient/identity/v2_0/role.py +1 -1
- openstackclient/identity/v2_0/service.py +7 -7
- openstackclient/identity/v2_0/user.py +6 -21
- openstackclient/identity/v3/access_rule.py +2 -5
- openstackclient/identity/v3/consumer.py +4 -3
- openstackclient/identity/v3/credential.py +6 -7
- openstackclient/identity/v3/domain.py +1 -1
- openstackclient/identity/v3/ec2creds.py +4 -3
- openstackclient/identity/v3/endpoint.py +104 -88
- openstackclient/identity/v3/endpoint_group.py +1 -1
- openstackclient/identity/v3/group.py +3 -4
- openstackclient/identity/v3/identity_provider.py +1 -2
- openstackclient/identity/v3/limit.py +4 -9
- openstackclient/identity/v3/mapping.py +4 -3
- openstackclient/identity/v3/policy.py +5 -8
- openstackclient/identity/v3/project.py +6 -6
- openstackclient/identity/v3/region.py +2 -5
- openstackclient/identity/v3/registered_limit.py +4 -8
- openstackclient/identity/v3/role.py +15 -16
- openstackclient/identity/v3/service.py +8 -8
- openstackclient/identity/v3/service_provider.py +3 -6
- openstackclient/identity/v3/tag.py +2 -2
- openstackclient/identity/v3/token.py +1 -2
- openstackclient/identity/v3/trust.py +74 -25
- openstackclient/identity/v3/user.py +9 -6
- openstackclient/image/client.py +2 -5
- openstackclient/image/v1/image.py +11 -15
- openstackclient/image/v2/cache.py +2 -4
- openstackclient/image/v2/image.py +30 -37
- openstackclient/image/v2/metadef_namespaces.py +4 -3
- openstackclient/image/v2/metadef_resource_type_association.py +1 -2
- openstackclient/image/v2/metadef_resource_types.py +1 -2
- openstackclient/locale/tr_TR/LC_MESSAGES/openstackclient.po +9 -1370
- openstackclient/network/client.py +4 -10
- openstackclient/network/common.py +16 -12
- openstackclient/network/utils.py +3 -3
- openstackclient/network/v2/address_group.py +5 -9
- openstackclient/network/v2/address_scope.py +2 -3
- openstackclient/network/v2/default_security_group_rule.py +1 -2
- openstackclient/network/v2/floating_ip.py +14 -21
- openstackclient/network/v2/floating_ip_port_forwarding.py +7 -7
- openstackclient/network/v2/ip_availability.py +1 -2
- openstackclient/network/v2/l3_conntrack_helper.py +8 -12
- openstackclient/network/v2/local_ip.py +24 -26
- openstackclient/network/v2/local_ip_association.py +4 -5
- openstackclient/network/v2/ndp_proxy.py +9 -10
- openstackclient/network/v2/network.py +12 -16
- openstackclient/network/v2/network_agent.py +29 -37
- openstackclient/network/v2/network_auto_allocated_topology.py +4 -5
- openstackclient/network/v2/network_flavor.py +1 -1
- openstackclient/network/v2/network_flavor_profile.py +5 -5
- openstackclient/network/v2/network_meter.py +3 -3
- openstackclient/network/v2/network_meter_rule.py +5 -8
- openstackclient/network/v2/network_qos_policy.py +4 -4
- openstackclient/network/v2/network_qos_rule.py +4 -5
- openstackclient/network/v2/network_rbac.py +4 -4
- openstackclient/network/v2/network_segment.py +6 -7
- openstackclient/network/v2/network_segment_range.py +16 -20
- openstackclient/network/v2/network_trunk.py +24 -16
- openstackclient/network/v2/port.py +28 -29
- openstackclient/network/v2/router.py +52 -41
- openstackclient/network/v2/security_group.py +8 -15
- openstackclient/network/v2/security_group_rule.py +9 -10
- openstackclient/network/v2/subnet.py +31 -30
- openstackclient/network/v2/subnet_pool.py +4 -4
- openstackclient/object/client.py +2 -3
- openstackclient/object/v1/container.py +2 -3
- openstackclient/object/v1/object.py +2 -9
- openstackclient/shell.py +22 -5
- openstackclient/tests/functional/base.py +2 -2
- openstackclient/tests/functional/common/test_quota.py +3 -1
- openstackclient/tests/functional/compute/v2/common.py +12 -6
- openstackclient/tests/functional/compute/v2/test_server.py +2 -3
- openstackclient/tests/functional/compute/v2/test_server_event.py +1 -1
- openstackclient/tests/functional/identity/v2/test_user.py +1 -1
- openstackclient/tests/functional/identity/v3/common.py +3 -8
- openstackclient/tests/functional/identity/v3/test_application_credential.py +10 -10
- openstackclient/tests/functional/identity/v3/test_endpoint.py +3 -3
- openstackclient/tests/functional/identity/v3/test_group.py +3 -3
- openstackclient/tests/functional/identity/v3/test_idp.py +3 -7
- openstackclient/tests/functional/identity/v3/test_limit.py +4 -4
- openstackclient/tests/functional/identity/v3/test_project.py +5 -14
- openstackclient/tests/functional/identity/v3/test_region.py +1 -3
- openstackclient/tests/functional/identity/v3/test_registered_limit.py +3 -3
- openstackclient/tests/functional/identity/v3/test_role.py +1 -1
- openstackclient/tests/functional/identity/v3/test_role_assignment.py +13 -31
- openstackclient/tests/functional/identity/v3/test_service_provider.py +3 -7
- openstackclient/tests/functional/identity/v3/test_user.py +8 -8
- openstackclient/tests/functional/network/v2/common.py +7 -3
- openstackclient/tests/functional/network/v2/test_address_group.py +4 -0
- openstackclient/tests/functional/network/v2/test_l3_conntrack_helper.py +15 -11
- openstackclient/tests/functional/network/v2/test_local_ip.py +4 -0
- openstackclient/tests/functional/network/v2/test_network_meter_rule.py +2 -2
- openstackclient/tests/functional/network/v2/test_network_ndp_proxy.py +2 -3
- openstackclient/tests/functional/network/v2/test_network_rbac.py +2 -2
- openstackclient/tests/functional/network/v2/test_network_trunk.py +1 -1
- openstackclient/tests/functional/network/v2/test_port.py +17 -7
- openstackclient/tests/functional/network/v2/test_router.py +42 -0
- openstackclient/tests/functional/network/v2/test_subnet_pool.py +4 -0
- openstackclient/tests/unit/api/test_compute_v2.py +67 -87
- openstackclient/tests/unit/common/test_availability_zone.py +6 -14
- openstackclient/tests/unit/common/test_command.py +1 -1
- openstackclient/tests/unit/common/test_extension.py +5 -7
- openstackclient/tests/unit/common/test_limits.py +1 -1
- openstackclient/tests/unit/common/test_project_cleanup.py +5 -6
- openstackclient/tests/unit/common/test_quota.py +51 -28
- openstackclient/tests/unit/compute/v2/fakes.py +4 -10
- openstackclient/tests/unit/compute/v2/test_agent.py +16 -16
- openstackclient/tests/unit/compute/v2/test_aggregate.py +56 -60
- openstackclient/tests/unit/compute/v2/test_console.py +16 -16
- openstackclient/tests/unit/compute/v2/test_flavor.py +71 -71
- openstackclient/tests/unit/compute/v2/test_host.py +8 -8
- openstackclient/tests/unit/compute/v2/test_hypervisor.py +22 -30
- openstackclient/tests/unit/compute/v2/test_hypervisor_stats.py +2 -2
- openstackclient/tests/unit/compute/v2/test_keypair.py +24 -24
- openstackclient/tests/unit/compute/v2/test_server.py +524 -560
- openstackclient/tests/unit/compute/v2/test_server_backup.py +5 -7
- openstackclient/tests/unit/compute/v2/test_server_event.py +16 -18
- openstackclient/tests/unit/compute/v2/test_server_group.py +25 -31
- openstackclient/tests/unit/compute/v2/test_server_image.py +6 -8
- openstackclient/tests/unit/compute/v2/test_server_migration.py +37 -37
- openstackclient/tests/unit/compute/v2/test_server_volume.py +12 -12
- openstackclient/tests/unit/compute/v2/test_service.py +39 -45
- openstackclient/tests/unit/compute/v2/test_usage.py +5 -5
- openstackclient/tests/unit/identity/v2_0/fakes.py +1 -1
- openstackclient/tests/unit/identity/v3/test_access_rule.py +1 -3
- openstackclient/tests/unit/identity/v3/test_application_credential.py +1 -1
- openstackclient/tests/unit/identity/v3/test_endpoint.py +167 -172
- openstackclient/tests/unit/identity/v3/test_mappings.py +2 -2
- openstackclient/tests/unit/identity/v3/test_trust.py +5 -2
- openstackclient/tests/unit/identity/v3/test_user.py +16 -0
- openstackclient/tests/unit/image/v1/fakes.py +2 -2
- openstackclient/tests/unit/image/v2/test_image.py +39 -1
- openstackclient/tests/unit/integ/cli/test_shell.py +1 -2
- openstackclient/tests/unit/network/test_common.py +2 -2
- openstackclient/tests/unit/network/v2/test_floating_ip_compute.py +8 -14
- openstackclient/tests/unit/network/v2/test_floating_ip_network.py +49 -35
- openstackclient/tests/unit/network/v2/test_floating_ip_pool_compute.py +1 -1
- openstackclient/tests/unit/network/v2/test_network_compute.py +11 -11
- openstackclient/tests/unit/network/v2/test_network_trunk.py +2 -2
- openstackclient/tests/unit/network/v2/test_port.py +4 -5
- openstackclient/tests/unit/network/v2/test_router.py +63 -0
- openstackclient/tests/unit/network/v2/test_security_group_compute.py +11 -19
- openstackclient/tests/unit/network/v2/test_security_group_rule_compute.py +14 -14
- openstackclient/tests/unit/object/v1/test_object_all.py +4 -3
- openstackclient/tests/unit/test_shell.py +16 -13
- openstackclient/tests/unit/volume/v2/test_volume.py +1 -1
- openstackclient/tests/unit/volume/v2/test_volume_transfer_request.py +1 -1
- openstackclient/tests/unit/volume/v3/fakes.py +2 -8
- openstackclient/tests/unit/volume/v3/test_volume.py +1 -1
- openstackclient/tests/unit/volume/v3/test_volume_attachment.py +3 -3
- openstackclient/tests/unit/volume/v3/test_volume_snapshot.py +1 -2
- openstackclient/tests/unit/volume/v3/test_volume_transfer_request.py +1 -1
- openstackclient/volume/client.py +1 -3
- openstackclient/volume/v2/consistency_group.py +4 -8
- openstackclient/volume/v2/consistency_group_snapshot.py +1 -2
- openstackclient/volume/v2/qos_specs.py +1 -2
- openstackclient/volume/v2/volume.py +8 -16
- openstackclient/volume/v2/volume_backup.py +6 -7
- openstackclient/volume/v2/volume_snapshot.py +8 -9
- openstackclient/volume/v2/volume_transfer_request.py +0 -3
- openstackclient/volume/v2/volume_type.py +10 -21
- openstackclient/volume/v3/block_storage_cluster.py +3 -3
- openstackclient/volume/v3/block_storage_manage.py +1 -3
- openstackclient/volume/v3/volume.py +18 -19
- openstackclient/volume/v3/volume_attachment.py +3 -2
- openstackclient/volume/v3/volume_backup.py +7 -8
- openstackclient/volume/v3/volume_group.py +2 -1
- openstackclient/volume/v3/volume_group_snapshot.py +2 -1
- openstackclient/volume/v3/volume_snapshot.py +4 -3
- openstackclient/volume/v3/volume_type.py +10 -21
- {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/AUTHORS +3 -0
- {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/METADATA +7 -13
- {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/RECORD +209 -232
- {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/WHEEL +1 -1
- {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/entry_points.txt +0 -41
- python_openstackclient-8.0.0.dist-info/pbr.json +1 -0
- openstackclient/tests/functional/volume/v1/__init__.py +0 -0
- openstackclient/tests/functional/volume/v1/common.py +0 -35
- openstackclient/tests/functional/volume/v1/test_qos.py +0 -100
- openstackclient/tests/functional/volume/v1/test_service.py +0 -76
- openstackclient/tests/functional/volume/v1/test_snapshot.py +0 -232
- openstackclient/tests/functional/volume/v1/test_transfer_request.py +0 -111
- openstackclient/tests/functional/volume/v1/test_volume.py +0 -228
- openstackclient/tests/functional/volume/v1/test_volume_type.py +0 -213
- openstackclient/tests/unit/volume/v1/__init__.py +0 -0
- openstackclient/tests/unit/volume/v1/fakes.py +0 -615
- openstackclient/tests/unit/volume/v1/test_qos_specs.py +0 -471
- openstackclient/tests/unit/volume/v1/test_service.py +0 -295
- openstackclient/tests/unit/volume/v1/test_transfer_request.py +0 -380
- openstackclient/tests/unit/volume/v1/test_type.py +0 -633
- openstackclient/tests/unit/volume/v1/test_volume.py +0 -1447
- openstackclient/tests/unit/volume/v1/test_volume_backup.py +0 -435
- openstackclient/volume/v1/__init__.py +0 -0
- openstackclient/volume/v1/qos_specs.py +0 -377
- openstackclient/volume/v1/service.py +0 -136
- openstackclient/volume/v1/volume.py +0 -734
- openstackclient/volume/v1/volume_backup.py +0 -302
- openstackclient/volume/v1/volume_snapshot.py +0 -433
- openstackclient/volume/v1/volume_transfer_request.py +0 -200
- openstackclient/volume/v1/volume_type.py +0 -520
- python_openstackclient-7.4.0.dist-info/pbr.json +0 -1
- {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/LICENSE +0 -0
- {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/top_level.txt +0 -0
|
@@ -1,615 +0,0 @@
|
|
|
1
|
-
# Copyright 2013 Nebula Inc.
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
4
|
-
# not use this file except in compliance with the License. You may obtain
|
|
5
|
-
# a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
11
|
-
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
12
|
-
# License for the specific language governing permissions and limitations
|
|
13
|
-
# under the License.
|
|
14
|
-
#
|
|
15
|
-
|
|
16
|
-
import copy
|
|
17
|
-
import random
|
|
18
|
-
from unittest import mock
|
|
19
|
-
import uuid
|
|
20
|
-
|
|
21
|
-
from openstack.image.v1 import _proxy as image_v1_proxy
|
|
22
|
-
|
|
23
|
-
from openstackclient.tests.unit import fakes
|
|
24
|
-
from openstackclient.tests.unit.identity.v2_0 import fakes as identity_fakes
|
|
25
|
-
from openstackclient.tests.unit import utils
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
class FakeVolumev1Client:
|
|
29
|
-
def __init__(self, **kwargs):
|
|
30
|
-
self.volumes = mock.Mock()
|
|
31
|
-
self.volumes.resource_class = fakes.FakeResource(None, {})
|
|
32
|
-
self.services = mock.Mock()
|
|
33
|
-
self.services.resource_class = fakes.FakeResource(None, {})
|
|
34
|
-
self.extensions = mock.Mock()
|
|
35
|
-
self.extensions.resource_class = fakes.FakeResource(None, {})
|
|
36
|
-
self.qos_specs = mock.Mock()
|
|
37
|
-
self.qos_specs.resource_class = fakes.FakeResource(None, {})
|
|
38
|
-
self.volume_types = mock.Mock()
|
|
39
|
-
self.volume_types.resource_class = fakes.FakeResource(None, {})
|
|
40
|
-
self.volume_encryption_types = mock.Mock()
|
|
41
|
-
self.volume_encryption_types.resource_class = fakes.FakeResource(
|
|
42
|
-
None, {}
|
|
43
|
-
)
|
|
44
|
-
self.transfers = mock.Mock()
|
|
45
|
-
self.transfers.resource_class = fakes.FakeResource(None, {})
|
|
46
|
-
self.volume_snapshots = mock.Mock()
|
|
47
|
-
self.volume_snapshots.resource_class = fakes.FakeResource(None, {})
|
|
48
|
-
self.backups = mock.Mock()
|
|
49
|
-
self.backups.resource_class = fakes.FakeResource(None, {})
|
|
50
|
-
self.restores = mock.Mock()
|
|
51
|
-
self.restores.resource_class = fakes.FakeResource(None, {})
|
|
52
|
-
self.auth_token = kwargs['token']
|
|
53
|
-
self.management_url = kwargs['endpoint']
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
class FakeClientMixin:
|
|
57
|
-
def setUp(self):
|
|
58
|
-
super().setUp()
|
|
59
|
-
|
|
60
|
-
self.app.client_manager.volume = FakeVolumev1Client(
|
|
61
|
-
endpoint=fakes.AUTH_URL,
|
|
62
|
-
token=fakes.AUTH_TOKEN,
|
|
63
|
-
)
|
|
64
|
-
self.volume_client = self.app.client_manager.volume
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
class TestVolumev1(
|
|
68
|
-
identity_fakes.FakeClientMixin,
|
|
69
|
-
FakeClientMixin,
|
|
70
|
-
utils.TestCommand,
|
|
71
|
-
):
|
|
72
|
-
def setUp(self):
|
|
73
|
-
super().setUp()
|
|
74
|
-
|
|
75
|
-
# avoid circular imports by defining this manually rather than using
|
|
76
|
-
# openstackclient.tests.unit.image.v1.fakes.FakeClientMixin
|
|
77
|
-
self.app.client_manager.image = mock.Mock(spec=image_v1_proxy.Proxy)
|
|
78
|
-
self.image_client = self.app.client_manager.image
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
def create_one_transfer(attrs=None):
|
|
82
|
-
"""Create a fake transfer.
|
|
83
|
-
|
|
84
|
-
:param Dictionary attrs:
|
|
85
|
-
A dictionary with all attributes of Transfer Request
|
|
86
|
-
:return:
|
|
87
|
-
A FakeResource object with volume_id, name, id.
|
|
88
|
-
"""
|
|
89
|
-
# Set default attribute
|
|
90
|
-
transfer_info = {
|
|
91
|
-
'volume_id': 'volume-id-' + uuid.uuid4().hex,
|
|
92
|
-
'name': 'fake_transfer_name',
|
|
93
|
-
'id': 'id-' + uuid.uuid4().hex,
|
|
94
|
-
'links': 'links-' + uuid.uuid4().hex,
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
# Overwrite default attributes if there are some attributes set
|
|
98
|
-
attrs = attrs or {}
|
|
99
|
-
|
|
100
|
-
transfer_info.update(attrs)
|
|
101
|
-
|
|
102
|
-
transfer = fakes.FakeResource(None, transfer_info, loaded=True)
|
|
103
|
-
|
|
104
|
-
return transfer
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
def create_transfers(attrs=None, count=2):
|
|
108
|
-
"""Create multiple fake transfers.
|
|
109
|
-
|
|
110
|
-
:param Dictionary attrs:
|
|
111
|
-
A dictionary with all attributes of transfer
|
|
112
|
-
:param Integer count:
|
|
113
|
-
The number of transfers to be faked
|
|
114
|
-
:return:
|
|
115
|
-
A list of FakeResource objects
|
|
116
|
-
"""
|
|
117
|
-
transfers = []
|
|
118
|
-
for n in range(0, count):
|
|
119
|
-
transfers.append(create_one_transfer(attrs))
|
|
120
|
-
|
|
121
|
-
return transfers
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
def get_transfers(transfers=None, count=2):
|
|
125
|
-
"""Get an iterable MagicMock object with a list of faked transfers.
|
|
126
|
-
|
|
127
|
-
If transfers list is provided, then initialize the Mock object with the
|
|
128
|
-
list. Otherwise create one.
|
|
129
|
-
|
|
130
|
-
:param List transfers:
|
|
131
|
-
A list of FakeResource objects faking transfers
|
|
132
|
-
:param Integer count:
|
|
133
|
-
The number of transfers to be faked
|
|
134
|
-
:return
|
|
135
|
-
An iterable Mock object with side_effect set to a list of faked
|
|
136
|
-
transfers
|
|
137
|
-
"""
|
|
138
|
-
if transfers is None:
|
|
139
|
-
transfers = create_transfers(count)
|
|
140
|
-
|
|
141
|
-
return mock.Mock(side_effect=transfers)
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
def create_one_service(attrs=None):
|
|
145
|
-
"""Create a fake service.
|
|
146
|
-
|
|
147
|
-
:param Dictionary attrs:
|
|
148
|
-
A dictionary with all attributes of service
|
|
149
|
-
:return:
|
|
150
|
-
A FakeResource object with host, status, etc.
|
|
151
|
-
"""
|
|
152
|
-
# Set default attribute
|
|
153
|
-
service_info = {
|
|
154
|
-
'host': 'host_test',
|
|
155
|
-
'binary': 'cinder_test',
|
|
156
|
-
'status': 'enabled',
|
|
157
|
-
'disabled_reason': 'LongHoliday-GoldenWeek',
|
|
158
|
-
'zone': 'fake_zone',
|
|
159
|
-
'updated_at': 'fake_date',
|
|
160
|
-
'state': 'fake_state',
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
# Overwrite default attributes if there are some attributes set
|
|
164
|
-
attrs = attrs or {}
|
|
165
|
-
|
|
166
|
-
service_info.update(attrs)
|
|
167
|
-
|
|
168
|
-
service = fakes.FakeResource(None, service_info, loaded=True)
|
|
169
|
-
|
|
170
|
-
return service
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
def create_services(attrs=None, count=2):
|
|
174
|
-
"""Create multiple fake services.
|
|
175
|
-
|
|
176
|
-
:param Dictionary attrs:
|
|
177
|
-
A dictionary with all attributes of service
|
|
178
|
-
:param Integer count:
|
|
179
|
-
The number of services to be faked
|
|
180
|
-
:return:
|
|
181
|
-
A list of FakeResource objects
|
|
182
|
-
"""
|
|
183
|
-
services = []
|
|
184
|
-
for n in range(0, count):
|
|
185
|
-
services.append(create_one_service(attrs))
|
|
186
|
-
|
|
187
|
-
return services
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
def get_services(services=None, count=2):
|
|
191
|
-
"""Get an iterable MagicMock object with a list of faked services.
|
|
192
|
-
|
|
193
|
-
If services list is provided, then initialize the Mock object with the
|
|
194
|
-
list. Otherwise create one.
|
|
195
|
-
|
|
196
|
-
:param List services:
|
|
197
|
-
A list of FakeResource objects faking services
|
|
198
|
-
:param Integer count:
|
|
199
|
-
The number of services to be faked
|
|
200
|
-
:return
|
|
201
|
-
An iterable Mock object with side_effect set to a list of faked
|
|
202
|
-
services
|
|
203
|
-
"""
|
|
204
|
-
if services is None:
|
|
205
|
-
services = create_services(count)
|
|
206
|
-
|
|
207
|
-
return mock.Mock(side_effect=services)
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
def create_one_qos(attrs=None):
|
|
211
|
-
"""Create a fake Qos specification.
|
|
212
|
-
|
|
213
|
-
:param Dictionary attrs:
|
|
214
|
-
A dictionary with all attributes
|
|
215
|
-
:return:
|
|
216
|
-
A FakeResource object with id, name, consumer, etc.
|
|
217
|
-
"""
|
|
218
|
-
attrs = attrs or {}
|
|
219
|
-
|
|
220
|
-
# Set default attributes.
|
|
221
|
-
qos_info = {
|
|
222
|
-
"id": 'qos-id-' + uuid.uuid4().hex,
|
|
223
|
-
"name": 'qos-name-' + uuid.uuid4().hex,
|
|
224
|
-
"consumer": 'front-end',
|
|
225
|
-
"specs": {"foo": "bar", "iops": "9001"},
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
# Overwrite default attributes.
|
|
229
|
-
qos_info.update(attrs)
|
|
230
|
-
|
|
231
|
-
qos = fakes.FakeResource(info=copy.deepcopy(qos_info), loaded=True)
|
|
232
|
-
return qos
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
def create_one_qos_association(attrs=None):
|
|
236
|
-
"""Create a fake Qos specification association.
|
|
237
|
-
|
|
238
|
-
:param Dictionary attrs:
|
|
239
|
-
A dictionary with all attributes
|
|
240
|
-
:return:
|
|
241
|
-
A FakeResource object with id, name, association_type, etc.
|
|
242
|
-
"""
|
|
243
|
-
attrs = attrs or {}
|
|
244
|
-
|
|
245
|
-
# Set default attributes.
|
|
246
|
-
qos_association_info = {
|
|
247
|
-
"id": 'type-id-' + uuid.uuid4().hex,
|
|
248
|
-
"name": 'type-name-' + uuid.uuid4().hex,
|
|
249
|
-
"association_type": 'volume_type',
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
# Overwrite default attributes.
|
|
253
|
-
qos_association_info.update(attrs)
|
|
254
|
-
|
|
255
|
-
qos_association = fakes.FakeResource(
|
|
256
|
-
info=copy.deepcopy(qos_association_info), loaded=True
|
|
257
|
-
)
|
|
258
|
-
return qos_association
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
def create_qoses(attrs=None, count=2):
|
|
262
|
-
"""Create multiple fake Qos specifications.
|
|
263
|
-
|
|
264
|
-
:param Dictionary attrs:
|
|
265
|
-
A dictionary with all attributes
|
|
266
|
-
:param int count:
|
|
267
|
-
The number of Qos specifications to fake
|
|
268
|
-
:return:
|
|
269
|
-
A list of FakeResource objects faking the Qos specifications
|
|
270
|
-
"""
|
|
271
|
-
qoses = []
|
|
272
|
-
for i in range(0, count):
|
|
273
|
-
qos = create_one_qos(attrs)
|
|
274
|
-
qoses.append(qos)
|
|
275
|
-
|
|
276
|
-
return qoses
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
def get_qoses(qoses=None, count=2):
|
|
280
|
-
"""Get an iterable MagicMock object with a list of faked qoses.
|
|
281
|
-
|
|
282
|
-
If qoses list is provided, then initialize the Mock object with the
|
|
283
|
-
list. Otherwise create one.
|
|
284
|
-
|
|
285
|
-
:param List volumes:
|
|
286
|
-
A list of FakeResource objects faking qoses
|
|
287
|
-
:param Integer count:
|
|
288
|
-
The number of qoses to be faked
|
|
289
|
-
:return
|
|
290
|
-
An iterable Mock object with side_effect set to a list of faked
|
|
291
|
-
qoses
|
|
292
|
-
"""
|
|
293
|
-
if qoses is None:
|
|
294
|
-
qoses = create_qoses(count)
|
|
295
|
-
|
|
296
|
-
return mock.Mock(side_effect=qoses)
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
def create_one_volume(attrs=None):
|
|
300
|
-
"""Create a fake volume.
|
|
301
|
-
|
|
302
|
-
:param Dictionary attrs:
|
|
303
|
-
A dictionary with all attributes of volume
|
|
304
|
-
:return:
|
|
305
|
-
A FakeResource object with id, name, status, etc.
|
|
306
|
-
"""
|
|
307
|
-
attrs = attrs or {}
|
|
308
|
-
|
|
309
|
-
# Set default attribute
|
|
310
|
-
volume_info = {
|
|
311
|
-
'id': 'volume-id' + uuid.uuid4().hex,
|
|
312
|
-
'display_name': 'volume-name' + uuid.uuid4().hex,
|
|
313
|
-
'display_description': 'description' + uuid.uuid4().hex,
|
|
314
|
-
'status': 'available',
|
|
315
|
-
'size': 10,
|
|
316
|
-
'volume_type': random.choice(['fake_lvmdriver-1', 'fake_lvmdriver-2']),
|
|
317
|
-
'bootable': 'true',
|
|
318
|
-
'metadata': {
|
|
319
|
-
'key' + uuid.uuid4().hex: 'val' + uuid.uuid4().hex,
|
|
320
|
-
'key' + uuid.uuid4().hex: 'val' + uuid.uuid4().hex,
|
|
321
|
-
'key' + uuid.uuid4().hex: 'val' + uuid.uuid4().hex,
|
|
322
|
-
},
|
|
323
|
-
'snapshot_id': 'snapshot-id-' + uuid.uuid4().hex,
|
|
324
|
-
'availability_zone': 'zone' + uuid.uuid4().hex,
|
|
325
|
-
'attachments': [
|
|
326
|
-
{
|
|
327
|
-
'device': '/dev/' + uuid.uuid4().hex,
|
|
328
|
-
'server_id': uuid.uuid4().hex,
|
|
329
|
-
},
|
|
330
|
-
],
|
|
331
|
-
'created_at': 'time-' + uuid.uuid4().hex,
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
# Overwrite default attributes if there are some attributes set
|
|
335
|
-
volume_info.update(attrs)
|
|
336
|
-
|
|
337
|
-
volume = fakes.FakeResource(None, volume_info, loaded=True)
|
|
338
|
-
return volume
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
def create_volumes(attrs=None, count=2):
|
|
342
|
-
"""Create multiple fake volumes.
|
|
343
|
-
|
|
344
|
-
:param Dictionary attrs:
|
|
345
|
-
A dictionary with all attributes of volume
|
|
346
|
-
:param Integer count:
|
|
347
|
-
The number of volumes to be faked
|
|
348
|
-
:return:
|
|
349
|
-
A list of FakeResource objects
|
|
350
|
-
"""
|
|
351
|
-
volumes = []
|
|
352
|
-
for n in range(0, count):
|
|
353
|
-
volumes.append(create_one_volume(attrs))
|
|
354
|
-
|
|
355
|
-
return volumes
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
def get_volumes(volumes=None, count=2):
|
|
359
|
-
"""Get an iterable MagicMock object with a list of faked volumes.
|
|
360
|
-
|
|
361
|
-
If volumes list is provided, then initialize the Mock object with the
|
|
362
|
-
list. Otherwise create one.
|
|
363
|
-
|
|
364
|
-
:param List volumes:
|
|
365
|
-
A list of FakeResource objects faking volumes
|
|
366
|
-
:param Integer count:
|
|
367
|
-
The number of volumes to be faked
|
|
368
|
-
:return
|
|
369
|
-
An iterable Mock object with side_effect set to a list of faked
|
|
370
|
-
volumes
|
|
371
|
-
"""
|
|
372
|
-
if volumes is None:
|
|
373
|
-
volumes = create_volumes(count)
|
|
374
|
-
|
|
375
|
-
return mock.Mock(side_effect=volumes)
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
def create_one_volume_type(attrs=None, methods=None):
|
|
379
|
-
"""Create a fake volume type.
|
|
380
|
-
|
|
381
|
-
:param Dictionary attrs:
|
|
382
|
-
A dictionary with all attributes
|
|
383
|
-
:param Dictionary methods:
|
|
384
|
-
A dictionary with all methods
|
|
385
|
-
:return:
|
|
386
|
-
A FakeResource object with id, name, description, etc.
|
|
387
|
-
"""
|
|
388
|
-
attrs = attrs or {}
|
|
389
|
-
methods = methods or {}
|
|
390
|
-
|
|
391
|
-
# Set default attributes.
|
|
392
|
-
volume_type_info = {
|
|
393
|
-
"id": 'type-id-' + uuid.uuid4().hex,
|
|
394
|
-
"name": 'type-name-' + uuid.uuid4().hex,
|
|
395
|
-
"description": 'type-description-' + uuid.uuid4().hex,
|
|
396
|
-
"extra_specs": {"foo": "bar"},
|
|
397
|
-
"is_public": True,
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
# Overwrite default attributes.
|
|
401
|
-
volume_type_info.update(attrs)
|
|
402
|
-
|
|
403
|
-
volume_type = fakes.FakeResource(
|
|
404
|
-
info=copy.deepcopy(volume_type_info), methods=methods, loaded=True
|
|
405
|
-
)
|
|
406
|
-
return volume_type
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
def create_volume_types(attrs=None, count=2):
|
|
410
|
-
"""Create multiple fake types.
|
|
411
|
-
|
|
412
|
-
:param Dictionary attrs:
|
|
413
|
-
A dictionary with all attributes
|
|
414
|
-
:param int count:
|
|
415
|
-
The number of types to fake
|
|
416
|
-
:return:
|
|
417
|
-
A list of FakeResource objects faking the types
|
|
418
|
-
"""
|
|
419
|
-
volume_types = []
|
|
420
|
-
for i in range(0, count):
|
|
421
|
-
volume_type = create_one_volume_type(attrs)
|
|
422
|
-
volume_types.append(volume_type)
|
|
423
|
-
|
|
424
|
-
return volume_types
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
def get_volume_types(volume_types=None, count=2):
|
|
428
|
-
"""Get an iterable MagicMock object with a list of faked types.
|
|
429
|
-
|
|
430
|
-
If types list is provided, then initialize the Mock object with the
|
|
431
|
-
list. Otherwise create one.
|
|
432
|
-
|
|
433
|
-
:param List volume_types:
|
|
434
|
-
A list of FakeResource objects faking types
|
|
435
|
-
:param Integer count:
|
|
436
|
-
The number of types to be faked
|
|
437
|
-
:return
|
|
438
|
-
An iterable Mock object with side_effect set to a list of faked
|
|
439
|
-
types
|
|
440
|
-
"""
|
|
441
|
-
if volume_types is None:
|
|
442
|
-
volume_types = create_volume_types(count)
|
|
443
|
-
|
|
444
|
-
return mock.Mock(side_effect=volume_types)
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
def create_one_encryption_volume_type(attrs=None):
|
|
448
|
-
"""Create a fake encryption volume type.
|
|
449
|
-
|
|
450
|
-
:param Dictionary attrs:
|
|
451
|
-
A dictionary with all attributes
|
|
452
|
-
:return:
|
|
453
|
-
A FakeResource object with volume_type_id etc.
|
|
454
|
-
"""
|
|
455
|
-
attrs = attrs or {}
|
|
456
|
-
|
|
457
|
-
# Set default attributes.
|
|
458
|
-
encryption_info = {
|
|
459
|
-
"volume_type_id": 'type-id-' + uuid.uuid4().hex,
|
|
460
|
-
'provider': 'LuksEncryptor',
|
|
461
|
-
'cipher': None,
|
|
462
|
-
'key_size': None,
|
|
463
|
-
'control_location': 'front-end',
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
# Overwrite default attributes.
|
|
467
|
-
encryption_info.update(attrs)
|
|
468
|
-
|
|
469
|
-
encryption_type = fakes.FakeResource(
|
|
470
|
-
info=copy.deepcopy(encryption_info), loaded=True
|
|
471
|
-
)
|
|
472
|
-
return encryption_type
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
def create_one_snapshot(attrs=None):
|
|
476
|
-
"""Create a fake snapshot.
|
|
477
|
-
|
|
478
|
-
:param Dictionary attrs:
|
|
479
|
-
A dictionary with all attributes
|
|
480
|
-
:return:
|
|
481
|
-
A FakeResource object with id, name, description, etc.
|
|
482
|
-
"""
|
|
483
|
-
attrs = attrs or {}
|
|
484
|
-
|
|
485
|
-
# Set default attributes.
|
|
486
|
-
snapshot_info = {
|
|
487
|
-
"id": 'snapshot-id-' + uuid.uuid4().hex,
|
|
488
|
-
"display_name": 'snapshot-name-' + uuid.uuid4().hex,
|
|
489
|
-
"display_description": 'snapshot-description-' + uuid.uuid4().hex,
|
|
490
|
-
"size": 10,
|
|
491
|
-
"status": "available",
|
|
492
|
-
"metadata": {"foo": "bar"},
|
|
493
|
-
"created_at": "2015-06-03T18:49:19.000000",
|
|
494
|
-
"volume_id": 'vloume-id-' + uuid.uuid4().hex,
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
# Overwrite default attributes.
|
|
498
|
-
snapshot_info.update(attrs)
|
|
499
|
-
|
|
500
|
-
snapshot_method = {'update': None}
|
|
501
|
-
|
|
502
|
-
snapshot = fakes.FakeResource(
|
|
503
|
-
info=copy.deepcopy(snapshot_info),
|
|
504
|
-
methods=copy.deepcopy(snapshot_method),
|
|
505
|
-
loaded=True,
|
|
506
|
-
)
|
|
507
|
-
return snapshot
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
def create_snapshots(attrs=None, count=2):
|
|
511
|
-
"""Create multiple fake snapshots.
|
|
512
|
-
|
|
513
|
-
:param Dictionary attrs:
|
|
514
|
-
A dictionary with all attributes
|
|
515
|
-
:param int count:
|
|
516
|
-
The number of snapshots to fake
|
|
517
|
-
:return:
|
|
518
|
-
A list of FakeResource objects faking the snapshots
|
|
519
|
-
"""
|
|
520
|
-
snapshots = []
|
|
521
|
-
for i in range(0, count):
|
|
522
|
-
snapshot = create_one_snapshot(attrs)
|
|
523
|
-
snapshots.append(snapshot)
|
|
524
|
-
|
|
525
|
-
return snapshots
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
def get_snapshots(snapshots=None, count=2):
|
|
529
|
-
"""Get an iterable MagicMock object with a list of faked snapshots.
|
|
530
|
-
|
|
531
|
-
If snapshots list is provided, then initialize the Mock object with the
|
|
532
|
-
list. Otherwise create one.
|
|
533
|
-
|
|
534
|
-
:param List volumes:
|
|
535
|
-
A list of FakeResource objects faking snapshots
|
|
536
|
-
:param Integer count:
|
|
537
|
-
The number of snapshots to be faked
|
|
538
|
-
:return
|
|
539
|
-
An iterable Mock object with side_effect set to a list of faked
|
|
540
|
-
snapshots
|
|
541
|
-
"""
|
|
542
|
-
if snapshots is None:
|
|
543
|
-
snapshots = create_snapshots(count)
|
|
544
|
-
|
|
545
|
-
return mock.Mock(side_effect=snapshots)
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
def create_one_backup(attrs=None):
|
|
549
|
-
"""Create a fake backup.
|
|
550
|
-
|
|
551
|
-
:param Dictionary attrs:
|
|
552
|
-
A dictionary with all attributes
|
|
553
|
-
:return:
|
|
554
|
-
A FakeResource object with id, name, volume_id, etc.
|
|
555
|
-
"""
|
|
556
|
-
attrs = attrs or {}
|
|
557
|
-
|
|
558
|
-
# Set default attributes.
|
|
559
|
-
backup_info = {
|
|
560
|
-
"id": 'backup-id-' + uuid.uuid4().hex,
|
|
561
|
-
"name": 'backup-name-' + uuid.uuid4().hex,
|
|
562
|
-
"volume_id": 'volume-id-' + uuid.uuid4().hex,
|
|
563
|
-
"snapshot_id": 'snapshot-id' + uuid.uuid4().hex,
|
|
564
|
-
"description": 'description-' + uuid.uuid4().hex,
|
|
565
|
-
"object_count": None,
|
|
566
|
-
"container": 'container-' + uuid.uuid4().hex,
|
|
567
|
-
"size": random.randint(1, 20),
|
|
568
|
-
"status": "error",
|
|
569
|
-
"availability_zone": 'zone' + uuid.uuid4().hex,
|
|
570
|
-
"links": 'links-' + uuid.uuid4().hex,
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
# Overwrite default attributes.
|
|
574
|
-
backup_info.update(attrs)
|
|
575
|
-
|
|
576
|
-
backup = fakes.FakeResource(info=copy.deepcopy(backup_info), loaded=True)
|
|
577
|
-
return backup
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
def create_backups(attrs=None, count=2):
|
|
581
|
-
"""Create multiple fake backups.
|
|
582
|
-
|
|
583
|
-
:param Dictionary attrs:
|
|
584
|
-
A dictionary with all attributes
|
|
585
|
-
:param int count:
|
|
586
|
-
The number of backups to fake
|
|
587
|
-
:return:
|
|
588
|
-
A list of FakeResource objects faking the backups
|
|
589
|
-
"""
|
|
590
|
-
backups = []
|
|
591
|
-
for i in range(0, count):
|
|
592
|
-
backup = create_one_backup(attrs)
|
|
593
|
-
backups.append(backup)
|
|
594
|
-
|
|
595
|
-
return backups
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
def get_backups(backups=None, count=2):
|
|
599
|
-
"""Get an iterable MagicMock object with a list of faked backups.
|
|
600
|
-
|
|
601
|
-
If backups list is provided, then initialize the Mock object with the
|
|
602
|
-
list. Otherwise create one.
|
|
603
|
-
|
|
604
|
-
:param List volumes:
|
|
605
|
-
A list of FakeResource objects faking backups
|
|
606
|
-
:param Integer count:
|
|
607
|
-
The number of backups to be faked
|
|
608
|
-
:return
|
|
609
|
-
An iterable Mock object with side_effect set to a list of faked
|
|
610
|
-
backups
|
|
611
|
-
"""
|
|
612
|
-
if backups is None:
|
|
613
|
-
backups = create_backups(count)
|
|
614
|
-
|
|
615
|
-
return mock.Mock(side_effect=backups)
|