python-openstackclient 7.4.0__py3-none-any.whl → 8.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openstackclient/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 +7 -5
- openstackclient/compute/v2/agent.py +5 -5
- openstackclient/compute/v2/aggregate.py +17 -15
- openstackclient/compute/v2/console.py +10 -4
- openstackclient/compute/v2/console_connection.py +48 -0
- 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 +18 -13
- openstackclient/compute/v2/server.py +144 -121
- openstackclient/compute/v2/server_backup.py +1 -1
- openstackclient/compute/v2/server_event.py +8 -17
- 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 +95 -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/application_credential.py +2 -2
- openstackclient/identity/v3/consumer.py +4 -3
- openstackclient/identity/v3/credential.py +6 -7
- openstackclient/identity/v3/domain.py +63 -44
- 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 +116 -72
- 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 +23 -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 +47 -11
- openstackclient/image/client.py +7 -5
- openstackclient/image/v1/image.py +11 -15
- openstackclient/image/v2/cache.py +2 -4
- openstackclient/image/v2/image.py +41 -48
- 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 -16
- 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 +69 -47
- 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 +7 -16
- 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 +53 -42
- openstackclient/network/v2/security_group.py +13 -19
- openstackclient/network/v2/security_group_rule.py +10 -11
- 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 +7 -3
- openstackclient/tests/functional/common/test_quota.py +3 -1
- openstackclient/tests/functional/compute/v2/common.py +12 -6
- openstackclient/tests/functional/compute/v2/test_keypair.py +41 -5
- 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 +85 -315
- 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 +34 -17
- openstackclient/tests/unit/compute/v2/test_console_connection.py +72 -0
- openstackclient/tests/unit/compute/v2/test_flavor.py +72 -72
- 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 +36 -29
- openstackclient/tests/unit/compute/v2/test_server.py +693 -606
- openstackclient/tests/unit/compute/v2/test_server_backup.py +36 -77
- openstackclient/tests/unit/compute/v2/test_server_event.py +18 -20
- openstackclient/tests/unit/compute/v2/test_server_group.py +25 -31
- openstackclient/tests/unit/compute/v2/test_server_image.py +37 -78
- openstackclient/tests/unit/compute/v2/test_server_migration.py +41 -41
- 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 +48 -26
- openstackclient/tests/unit/identity/v3/test_domain.py +115 -105
- openstackclient/tests/unit/identity/v3/test_endpoint.py +167 -172
- openstackclient/tests/unit/identity/v3/test_group.py +353 -202
- openstackclient/tests/unit/identity/v3/test_mappings.py +2 -2
- openstackclient/tests/unit/identity/v3/test_project.py +16 -0
- openstackclient/tests/unit/identity/v3/test_trust.py +5 -2
- openstackclient/tests/unit/identity/v3/test_user.py +102 -6
- openstackclient/tests/unit/image/v1/fakes.py +2 -2
- openstackclient/tests/unit/image/v1/test_image.py +8 -9
- openstackclient/tests/unit/image/v2/test_image.py +84 -46
- openstackclient/tests/unit/integ/cli/test_shell.py +1 -2
- openstackclient/tests/unit/network/test_common.py +2 -2
- openstackclient/tests/unit/network/v2/fakes.py +405 -485
- openstackclient/tests/unit/network/v2/test_floating_ip_compute.py +8 -14
- openstackclient/tests/unit/network/v2/test_floating_ip_network.py +62 -54
- openstackclient/tests/unit/network/v2/test_floating_ip_pool_compute.py +1 -1
- openstackclient/tests/unit/network/v2/test_l3_conntrack_helper.py +2 -2
- openstackclient/tests/unit/network/v2/test_ndp_proxy.py +1 -3
- openstackclient/tests/unit/network/v2/test_network.py +4 -4
- openstackclient/tests/unit/network/v2/test_network_agent.py +15 -29
- openstackclient/tests/unit/network/v2/test_network_compute.py +11 -11
- openstackclient/tests/unit/network/v2/test_network_qos_policy.py +16 -19
- openstackclient/tests/unit/network/v2/test_network_qos_rule.py +79 -152
- openstackclient/tests/unit/network/v2/test_network_qos_rule_type.py +4 -6
- openstackclient/tests/unit/network/v2/test_network_rbac.py +2 -2
- openstackclient/tests/unit/network/v2/test_network_trunk.py +2 -2
- openstackclient/tests/unit/network/v2/test_port.py +21 -22
- openstackclient/tests/unit/network/v2/test_router.py +130 -51
- openstackclient/tests/unit/network/v2/test_security_group_compute.py +11 -19
- openstackclient/tests/unit/network/v2/test_security_group_network.py +25 -27
- openstackclient/tests/unit/network/v2/test_security_group_rule_compute.py +15 -17
- openstackclient/tests/unit/network/v2/test_security_group_rule_network.py +33 -39
- openstackclient/tests/unit/object/v1/test_object_all.py +4 -3
- openstackclient/tests/unit/test_shell.py +16 -13
- openstackclient/tests/unit/volume/v2/fakes.py +1 -2
- openstackclient/tests/unit/volume/v2/test_service.py +57 -91
- openstackclient/tests/unit/volume/v2/test_volume.py +109 -106
- openstackclient/tests/unit/volume/v2/test_volume_backup.py +141 -148
- openstackclient/tests/unit/volume/v2/test_volume_snapshot.py +293 -283
- openstackclient/tests/unit/volume/v2/test_volume_transfer_request.py +1 -1
- openstackclient/tests/unit/volume/v3/fakes.py +2 -8
- openstackclient/tests/unit/volume/v3/test_block_storage_log_level.py +61 -71
- openstackclient/tests/unit/volume/v3/test_service.py +221 -141
- openstackclient/tests/unit/volume/v3/test_volume.py +131 -120
- openstackclient/tests/unit/volume/v3/test_volume_attachment.py +4 -4
- openstackclient/tests/unit/volume/v3/test_volume_backup.py +198 -203
- openstackclient/tests/unit/volume/v3/test_volume_snapshot.py +683 -49
- 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/service.py +41 -38
- openstackclient/volume/v2/volume.py +71 -53
- openstackclient/volume/v2/volume_backup.py +15 -10
- openstackclient/volume/v2/volume_snapshot.py +129 -93
- 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_log_level.py +22 -28
- openstackclient/volume/v3/block_storage_manage.py +1 -3
- openstackclient/volume/v3/service.py +105 -14
- openstackclient/volume/v3/volume.py +218 -58
- openstackclient/volume/v3/volume_attachment.py +3 -2
- openstackclient/volume/v3/volume_backup.py +31 -27
- openstackclient/volume/v3/volume_group.py +2 -1
- openstackclient/volume/v3/volume_group_snapshot.py +2 -1
- openstackclient/volume/v3/volume_snapshot.py +489 -13
- openstackclient/volume/v3/volume_type.py +10 -21
- {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.1.0.dist-info}/AUTHORS +11 -0
- python_openstackclient-8.1.0.dist-info/METADATA +264 -0
- {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.1.0.dist-info}/RECORD +238 -259
- {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.1.0.dist-info}/WHEEL +1 -1
- {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.1.0.dist-info}/entry_points.txt +7 -47
- python_openstackclient-8.1.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/METADATA +0 -172
- python_openstackclient-7.4.0.dist-info/pbr.json +0 -1
- {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.1.0.dist-info}/LICENSE +0 -0
- {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.1.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,32 @@ 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
|
-
'
|
|
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',
|
|
1868
1415
|
}
|
|
1869
1416
|
|
|
1417
|
+
# Overwrite default attributes.
|
|
1870
1418
|
security_group_attrs.update(attrs)
|
|
1871
1419
|
|
|
1872
1420
|
security_group = _security_group.SecurityGroup(**security_group_attrs)
|
|
1421
|
+
security_group.tenant_id = None # unset deprecated opts
|
|
1873
1422
|
|
|
1874
1423
|
return security_group
|
|
1875
1424
|
|
|
@@ -1877,9 +1426,12 @@ def create_one_security_group(attrs=None):
|
|
|
1877
1426
|
def create_security_groups(attrs=None, count=2):
|
|
1878
1427
|
"""Create multiple fake security groups.
|
|
1879
1428
|
|
|
1880
|
-
:param
|
|
1881
|
-
|
|
1882
|
-
:
|
|
1429
|
+
:param Dictionary attrs:
|
|
1430
|
+
A dictionary with all attributes
|
|
1431
|
+
:param int count:
|
|
1432
|
+
The number of security groups to fake
|
|
1433
|
+
:return:
|
|
1434
|
+
A list of SecurityGroup objects faking the security groups
|
|
1883
1435
|
"""
|
|
1884
1436
|
security_groups = []
|
|
1885
1437
|
for i in range(0, count):
|
|
@@ -1888,6 +1440,99 @@ def create_security_groups(attrs=None, count=2):
|
|
|
1888
1440
|
return security_groups
|
|
1889
1441
|
|
|
1890
1442
|
|
|
1443
|
+
def get_security_groups(security_groups=None, count=2):
|
|
1444
|
+
"""Get an iterable Mock object with a list of faked security groups.
|
|
1445
|
+
|
|
1446
|
+
If security groups list is provided, then initialize the Mock object
|
|
1447
|
+
with the list. Otherwise create one.
|
|
1448
|
+
|
|
1449
|
+
:param List security_groups:
|
|
1450
|
+
A list of SecurityGroup objects faking security groups
|
|
1451
|
+
:param int count:
|
|
1452
|
+
The number of security groups to fake
|
|
1453
|
+
:return:
|
|
1454
|
+
An iterable Mock object with side_effect set to a list of faked
|
|
1455
|
+
security groups
|
|
1456
|
+
"""
|
|
1457
|
+
if security_groups is None:
|
|
1458
|
+
security_groups = create_security_groups(count)
|
|
1459
|
+
return mock.Mock(side_effect=security_groups)
|
|
1460
|
+
|
|
1461
|
+
|
|
1462
|
+
def create_one_security_group_rule(attrs=None):
|
|
1463
|
+
"""Create a fake security group rule.
|
|
1464
|
+
|
|
1465
|
+
:param Dictionary attrs:
|
|
1466
|
+
A dictionary with all attributes
|
|
1467
|
+
:return:
|
|
1468
|
+
A FakeResource object, with id, etc.
|
|
1469
|
+
"""
|
|
1470
|
+
attrs = attrs or {}
|
|
1471
|
+
|
|
1472
|
+
# Set default attributes.
|
|
1473
|
+
security_group_rule_attrs = {
|
|
1474
|
+
'description': 'security-group-rule-description-' + uuid.uuid4().hex,
|
|
1475
|
+
'direction': 'ingress',
|
|
1476
|
+
'ether_type': 'IPv4',
|
|
1477
|
+
'id': 'security-group-rule-id-' + uuid.uuid4().hex,
|
|
1478
|
+
'port_range_max': None,
|
|
1479
|
+
'port_range_min': None,
|
|
1480
|
+
'protocol': None,
|
|
1481
|
+
'remote_group_id': None,
|
|
1482
|
+
'remote_address_group_id': None,
|
|
1483
|
+
'remote_ip_prefix': '0.0.0.0/0',
|
|
1484
|
+
'security_group_id': 'security-group-id-' + uuid.uuid4().hex,
|
|
1485
|
+
'project_id': 'project-id-' + uuid.uuid4().hex,
|
|
1486
|
+
'location': 'MUNCHMUNCHMUNCH',
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
# Overwrite default attributes.
|
|
1490
|
+
security_group_rule_attrs.update(attrs)
|
|
1491
|
+
|
|
1492
|
+
security_group_rule = _security_group_rule.SecurityGroupRule(
|
|
1493
|
+
**security_group_rule_attrs
|
|
1494
|
+
)
|
|
1495
|
+
security_group_rule.tenant_id = None # unset deprecated opts
|
|
1496
|
+
|
|
1497
|
+
return security_group_rule
|
|
1498
|
+
|
|
1499
|
+
|
|
1500
|
+
def create_security_group_rules(attrs=None, count=2):
|
|
1501
|
+
"""Create multiple fake security group rules.
|
|
1502
|
+
|
|
1503
|
+
:param Dictionary attrs:
|
|
1504
|
+
A dictionary with all attributes
|
|
1505
|
+
:param int count:
|
|
1506
|
+
The number of security group rules to fake
|
|
1507
|
+
:return:
|
|
1508
|
+
A list of SecurityGroupRule objects faking the security group rules
|
|
1509
|
+
"""
|
|
1510
|
+
security_group_rules = []
|
|
1511
|
+
for i in range(0, count):
|
|
1512
|
+
security_group_rules.append(create_one_security_group_rule(attrs))
|
|
1513
|
+
|
|
1514
|
+
return security_group_rules
|
|
1515
|
+
|
|
1516
|
+
|
|
1517
|
+
def get_security_group_rules(security_group_rules=None, count=2):
|
|
1518
|
+
"""Get an iterable Mock with a list of faked security group rules.
|
|
1519
|
+
|
|
1520
|
+
If security group rules list is provided, then initialize the Mock
|
|
1521
|
+
object with the list. Otherwise create one.
|
|
1522
|
+
|
|
1523
|
+
:param List security_group_rules:
|
|
1524
|
+
A list of SecurityGroupRule objects faking security group rules
|
|
1525
|
+
:param int count:
|
|
1526
|
+
The number of security group rules to fake
|
|
1527
|
+
:return:
|
|
1528
|
+
An iterable Mock object with side_effect set to a list of faked
|
|
1529
|
+
security group rules
|
|
1530
|
+
"""
|
|
1531
|
+
if security_group_rules is None:
|
|
1532
|
+
security_group_rules = create_security_group_rules(count)
|
|
1533
|
+
return mock.Mock(side_effect=security_group_rules)
|
|
1534
|
+
|
|
1535
|
+
|
|
1891
1536
|
def create_one_service_profile(attrs=None):
|
|
1892
1537
|
"""Create service profile."""
|
|
1893
1538
|
attrs = attrs or {}
|
|
@@ -1926,6 +1571,281 @@ def get_service_profile(flavor_profile=None, count=2):
|
|
|
1926
1571
|
return mock.Mock(side_effect=flavor_profile)
|
|
1927
1572
|
|
|
1928
1573
|
|
|
1574
|
+
def create_one_qos_policy(attrs=None):
|
|
1575
|
+
"""Create a fake QoS policy.
|
|
1576
|
+
|
|
1577
|
+
:param Dictionary attrs:
|
|
1578
|
+
A dictionary with all attributes
|
|
1579
|
+
:return:
|
|
1580
|
+
A QoSPolicy object with name, id, etc.
|
|
1581
|
+
"""
|
|
1582
|
+
attrs = attrs or {}
|
|
1583
|
+
qos_id = attrs.get('id') or 'qos-policy-id-' + uuid.uuid4().hex
|
|
1584
|
+
rules = []
|
|
1585
|
+
|
|
1586
|
+
# Set default attributes.
|
|
1587
|
+
qos_policy_attrs = {
|
|
1588
|
+
'name': 'qos-policy-name-' + uuid.uuid4().hex,
|
|
1589
|
+
'id': qos_id,
|
|
1590
|
+
'is_default': False,
|
|
1591
|
+
'project_id': 'project-id-' + uuid.uuid4().hex,
|
|
1592
|
+
'shared': False,
|
|
1593
|
+
'description': 'qos-policy-description-' + uuid.uuid4().hex,
|
|
1594
|
+
'rules': rules,
|
|
1595
|
+
'location': 'MUNCHMUNCHMUNCH',
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
# Overwrite default attributes.
|
|
1599
|
+
qos_policy_attrs.update(attrs)
|
|
1600
|
+
|
|
1601
|
+
qos_policy = _qos_policy.QoSPolicy(**qos_policy_attrs)
|
|
1602
|
+
|
|
1603
|
+
return qos_policy
|
|
1604
|
+
|
|
1605
|
+
|
|
1606
|
+
def create_qos_policies(attrs=None, count=2):
|
|
1607
|
+
"""Create multiple fake QoS policies.
|
|
1608
|
+
|
|
1609
|
+
:param Dictionary attrs:
|
|
1610
|
+
A dictionary with all attributes
|
|
1611
|
+
:param int count:
|
|
1612
|
+
The number of QoS policies to fake
|
|
1613
|
+
:return:
|
|
1614
|
+
A list of QoSPolicy objects faking the QoS policies
|
|
1615
|
+
"""
|
|
1616
|
+
qos_policies = []
|
|
1617
|
+
for i in range(0, count):
|
|
1618
|
+
qos_policies.append(create_one_qos_policy(attrs))
|
|
1619
|
+
|
|
1620
|
+
return qos_policies
|
|
1621
|
+
|
|
1622
|
+
|
|
1623
|
+
def get_qos_policies(qos_policies=None, count=2):
|
|
1624
|
+
"""Get an iterable MagicMock object with a list of faked QoS policies.
|
|
1625
|
+
|
|
1626
|
+
If qos policies list is provided, then initialize the Mock object
|
|
1627
|
+
with the list. Otherwise create one.
|
|
1628
|
+
|
|
1629
|
+
:param List qos_policies:
|
|
1630
|
+
A list of QoSPolicy objects faking qos policies
|
|
1631
|
+
:param int count:
|
|
1632
|
+
The number of QoS policies to fake
|
|
1633
|
+
:return:
|
|
1634
|
+
An iterable Mock object with side_effect set to a list of faked
|
|
1635
|
+
QoS policies
|
|
1636
|
+
"""
|
|
1637
|
+
if qos_policies is None:
|
|
1638
|
+
qos_policies = create_qos_policies(count)
|
|
1639
|
+
return mock.Mock(side_effect=qos_policies)
|
|
1640
|
+
|
|
1641
|
+
|
|
1642
|
+
def create_one_qos_rule(attrs=None):
|
|
1643
|
+
"""Create a fake Network QoS rule.
|
|
1644
|
+
|
|
1645
|
+
:param Dictionary attrs:
|
|
1646
|
+
A dictionary with all attributes
|
|
1647
|
+
:return:
|
|
1648
|
+
A QoSRule object with id, type, etc.
|
|
1649
|
+
"""
|
|
1650
|
+
attrs = attrs or {}
|
|
1651
|
+
|
|
1652
|
+
# Set default attributes.
|
|
1653
|
+
type = attrs.get('type') or choice(VALID_QOS_RULES)
|
|
1654
|
+
qos_rule_attrs = {
|
|
1655
|
+
'id': 'qos-rule-id-' + uuid.uuid4().hex,
|
|
1656
|
+
'qos_policy_id': 'qos-policy-id-' + uuid.uuid4().hex,
|
|
1657
|
+
'project_id': 'project-id-' + uuid.uuid4().hex,
|
|
1658
|
+
'type': type,
|
|
1659
|
+
'location': 'MUNCHMUNCHMUNCH',
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
if type == RULE_TYPE_BANDWIDTH_LIMIT:
|
|
1663
|
+
qos_rule_attrs['max_kbps'] = randint(1, 10000)
|
|
1664
|
+
qos_rule_attrs['max_burst_kbps'] = randint(1, 10000)
|
|
1665
|
+
qos_rule_attrs['direction'] = 'egress'
|
|
1666
|
+
|
|
1667
|
+
qos_rule_attrs.update(attrs)
|
|
1668
|
+
qos_rule = _qos_bandwidth_limit_rule.QoSBandwidthLimitRule(
|
|
1669
|
+
**qos_rule_attrs
|
|
1670
|
+
)
|
|
1671
|
+
|
|
1672
|
+
elif type == RULE_TYPE_DSCP_MARKING:
|
|
1673
|
+
qos_rule_attrs['dscp_mark'] = choice(VALID_DSCP_MARKS)
|
|
1674
|
+
|
|
1675
|
+
qos_rule_attrs.update(attrs)
|
|
1676
|
+
qos_rule = _qos_dscp_marking_rule.QoSDSCPMarkingRule(**qos_rule_attrs)
|
|
1677
|
+
|
|
1678
|
+
elif type == RULE_TYPE_MINIMUM_BANDWIDTH:
|
|
1679
|
+
qos_rule_attrs['min_kbps'] = randint(1, 10000)
|
|
1680
|
+
qos_rule_attrs['direction'] = 'egress'
|
|
1681
|
+
|
|
1682
|
+
qos_rule_attrs.update(attrs)
|
|
1683
|
+
|
|
1684
|
+
qos_rule = _qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule(
|
|
1685
|
+
**qos_rule_attrs
|
|
1686
|
+
)
|
|
1687
|
+
else: # type == RULE_TYPE_MINIMUM_PACKET_RATE:
|
|
1688
|
+
qos_rule_attrs['min_kpps'] = randint(1, 10000)
|
|
1689
|
+
qos_rule_attrs['direction'] = 'egress'
|
|
1690
|
+
|
|
1691
|
+
qos_rule_attrs.update(attrs)
|
|
1692
|
+
|
|
1693
|
+
qos_rule = _qos_minimum_packet_rate_rule.QoSMinimumPacketRateRule(
|
|
1694
|
+
**qos_rule_attrs
|
|
1695
|
+
)
|
|
1696
|
+
|
|
1697
|
+
return qos_rule
|
|
1698
|
+
|
|
1699
|
+
|
|
1700
|
+
def create_qos_rules(attrs=None, count=2):
|
|
1701
|
+
"""Create multiple fake Network QoS rules.
|
|
1702
|
+
|
|
1703
|
+
:param Dictionary attrs:
|
|
1704
|
+
A dictionary with all attributes
|
|
1705
|
+
:param int count:
|
|
1706
|
+
The number of Network QoS rule to fake
|
|
1707
|
+
:return:
|
|
1708
|
+
A list of QoS Rules objects faking the Network QoS rules
|
|
1709
|
+
"""
|
|
1710
|
+
qos_rules = []
|
|
1711
|
+
for i in range(0, count):
|
|
1712
|
+
qos_rules.append(create_one_qos_rule(attrs))
|
|
1713
|
+
return qos_rules
|
|
1714
|
+
|
|
1715
|
+
|
|
1716
|
+
def get_qos_rules(qos_rules=None, count=2):
|
|
1717
|
+
"""Get a list of faked Network QoS rules.
|
|
1718
|
+
|
|
1719
|
+
If Network QoS rules list is provided, then initialize the Mock
|
|
1720
|
+
object with the list. Otherwise create one.
|
|
1721
|
+
|
|
1722
|
+
:param List qos_rules:
|
|
1723
|
+
A list of FakeResource objects faking Network QoS rules
|
|
1724
|
+
:param int count:
|
|
1725
|
+
The number of QoS minimum bandwidth rules to fake
|
|
1726
|
+
:return:
|
|
1727
|
+
An iterable Mock object with side_effect set to a list of faked
|
|
1728
|
+
qos minimum bandwidth rules
|
|
1729
|
+
"""
|
|
1730
|
+
if qos_rules is None:
|
|
1731
|
+
qos_rules = create_qos_rules(count)
|
|
1732
|
+
return mock.Mock(side_effect=qos_rules)
|
|
1733
|
+
|
|
1734
|
+
|
|
1735
|
+
def create_one_qos_rule_type(attrs=None):
|
|
1736
|
+
"""Create a fake Network QoS rule type.
|
|
1737
|
+
|
|
1738
|
+
:param Dictionary attrs:
|
|
1739
|
+
A dictionary with all attributes
|
|
1740
|
+
:return:
|
|
1741
|
+
A QoSRuleType object with name, id, etc.
|
|
1742
|
+
"""
|
|
1743
|
+
attrs = attrs or {}
|
|
1744
|
+
|
|
1745
|
+
# Set default attributes.
|
|
1746
|
+
qos_rule_type_attrs = {
|
|
1747
|
+
'type': 'rule-type-' + uuid.uuid4().hex,
|
|
1748
|
+
'location': 'MUNCHMUNCHMUNCH',
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
# Overwrite default attributes.
|
|
1752
|
+
qos_rule_type_attrs.update(attrs)
|
|
1753
|
+
qos_rule_type = _qos_rule_type.QoSRuleType(**qos_rule_type_attrs)
|
|
1754
|
+
|
|
1755
|
+
return qos_rule_type
|
|
1756
|
+
|
|
1757
|
+
|
|
1758
|
+
def create_qos_rule_types(attrs=None, count=2):
|
|
1759
|
+
"""Create multiple fake Network QoS rule types.
|
|
1760
|
+
|
|
1761
|
+
:param Dictionary attrs:
|
|
1762
|
+
A dictionary with all attributes
|
|
1763
|
+
:param int count:
|
|
1764
|
+
The number of QoS rule types to fake
|
|
1765
|
+
:return:
|
|
1766
|
+
A list of QoSRuleType objects faking the QoS rule types
|
|
1767
|
+
"""
|
|
1768
|
+
qos_rule_types = []
|
|
1769
|
+
for i in range(0, count):
|
|
1770
|
+
qos_rule_types.append(create_one_qos_rule_type(attrs))
|
|
1771
|
+
|
|
1772
|
+
return qos_rule_types
|
|
1773
|
+
|
|
1774
|
+
|
|
1775
|
+
def create_one_router(attrs=None):
|
|
1776
|
+
"""Create a fake router.
|
|
1777
|
+
|
|
1778
|
+
:param Dictionary attrs:
|
|
1779
|
+
A dictionary with all attributes
|
|
1780
|
+
:return:
|
|
1781
|
+
A Router object, with id, name, admin_state_up,
|
|
1782
|
+
status, project_id
|
|
1783
|
+
"""
|
|
1784
|
+
attrs = attrs or {}
|
|
1785
|
+
|
|
1786
|
+
# Set default attributes.
|
|
1787
|
+
router_attrs = {
|
|
1788
|
+
'id': 'router-id-' + uuid.uuid4().hex,
|
|
1789
|
+
'name': 'router-name-' + uuid.uuid4().hex,
|
|
1790
|
+
'status': 'ACTIVE',
|
|
1791
|
+
'is_admin_state_up': True,
|
|
1792
|
+
'description': 'router-description-' + uuid.uuid4().hex,
|
|
1793
|
+
'distributed': False,
|
|
1794
|
+
'ha': False,
|
|
1795
|
+
'project_id': 'project-id-' + uuid.uuid4().hex,
|
|
1796
|
+
'routes': [],
|
|
1797
|
+
'external_gateway_info': {},
|
|
1798
|
+
'availability_zone_hints': [],
|
|
1799
|
+
'availability_zones': [],
|
|
1800
|
+
'tags': [],
|
|
1801
|
+
'location': 'MUNCHMUNCHMUNCH',
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
# Overwrite default attributes.
|
|
1805
|
+
router_attrs.update(attrs)
|
|
1806
|
+
|
|
1807
|
+
router = _router.Router(**router_attrs)
|
|
1808
|
+
router.tenant_id = None # unset deprecated opts
|
|
1809
|
+
|
|
1810
|
+
return router
|
|
1811
|
+
|
|
1812
|
+
|
|
1813
|
+
def create_routers(attrs=None, count=2):
|
|
1814
|
+
"""Create multiple fake routers.
|
|
1815
|
+
|
|
1816
|
+
:param Dictionary attrs:
|
|
1817
|
+
A dictionary with all attributes
|
|
1818
|
+
:param int count:
|
|
1819
|
+
The number of routers to fake
|
|
1820
|
+
:return:
|
|
1821
|
+
A list of Router objects faking the routers
|
|
1822
|
+
"""
|
|
1823
|
+
routers = []
|
|
1824
|
+
for i in range(0, count):
|
|
1825
|
+
routers.append(create_one_router(attrs))
|
|
1826
|
+
|
|
1827
|
+
return routers
|
|
1828
|
+
|
|
1829
|
+
|
|
1830
|
+
def get_routers(routers=None, count=2):
|
|
1831
|
+
"""Get an iterable Mock object with a list of faked routers.
|
|
1832
|
+
|
|
1833
|
+
If routers list is provided, then initialize the Mock object with the
|
|
1834
|
+
list. Otherwise create one.
|
|
1835
|
+
|
|
1836
|
+
:param List routers:
|
|
1837
|
+
A list of Router objects faking routers
|
|
1838
|
+
:param int count:
|
|
1839
|
+
The number of routers to fake
|
|
1840
|
+
:return:
|
|
1841
|
+
An iterable Mock object with side_effect set to a list of faked
|
|
1842
|
+
routers
|
|
1843
|
+
"""
|
|
1844
|
+
if routers is None:
|
|
1845
|
+
routers = create_routers(count)
|
|
1846
|
+
return mock.Mock(side_effect=routers)
|
|
1847
|
+
|
|
1848
|
+
|
|
1929
1849
|
def create_one_local_ip(attrs=None):
|
|
1930
1850
|
"""Create a fake local ip.
|
|
1931
1851
|
|