python-openstackclient 6.6.0__py3-none-any.whl → 7.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/api/api.py +7 -8
- openstackclient/api/compute_v2.py +352 -638
- openstackclient/api/image_v1.py +1 -1
- openstackclient/api/object_store_v1.py +3 -4
- openstackclient/common/availability_zone.py +1 -1
- openstackclient/common/clientmanager.py +16 -4
- openstackclient/common/configuration.py +1 -1
- openstackclient/common/extension.py +1 -1
- openstackclient/common/limits.py +66 -32
- openstackclient/common/module.py +3 -3
- openstackclient/common/progressbar.py +2 -2
- openstackclient/common/project_cleanup.py +5 -2
- openstackclient/common/quota.py +281 -410
- openstackclient/common/versions.py +1 -1
- openstackclient/compute/client.py +7 -116
- openstackclient/compute/v2/agent.py +75 -49
- openstackclient/compute/v2/aggregate.py +9 -9
- openstackclient/compute/v2/console.py +2 -2
- openstackclient/compute/v2/flavor.py +6 -6
- openstackclient/compute/v2/host.py +38 -33
- openstackclient/compute/v2/hypervisor.py +4 -3
- openstackclient/compute/v2/keypair.py +7 -8
- openstackclient/compute/v2/server.py +478 -396
- openstackclient/compute/v2/server_backup.py +1 -1
- openstackclient/compute/v2/server_group.py +4 -4
- openstackclient/compute/v2/server_image.py +1 -1
- openstackclient/compute/v2/server_migration.py +3 -4
- openstackclient/compute/v2/service.py +4 -4
- openstackclient/compute/v2/usage.py +3 -3
- openstackclient/identity/common.py +34 -0
- openstackclient/identity/v2_0/catalog.py +2 -2
- openstackclient/identity/v2_0/ec2creds.py +4 -4
- openstackclient/identity/v2_0/endpoint.py +4 -4
- openstackclient/identity/v2_0/project.py +6 -6
- openstackclient/identity/v2_0/role.py +5 -5
- openstackclient/identity/v2_0/role_assignment.py +1 -1
- openstackclient/identity/v2_0/service.py +4 -4
- openstackclient/identity/v2_0/token.py +2 -2
- openstackclient/identity/v2_0/user.py +7 -7
- openstackclient/identity/v3/access_rule.py +3 -3
- openstackclient/identity/v3/application_credential.py +127 -45
- openstackclient/identity/v3/catalog.py +2 -2
- openstackclient/identity/v3/consumer.py +4 -4
- openstackclient/identity/v3/credential.py +5 -5
- openstackclient/identity/v3/domain.py +5 -5
- openstackclient/identity/v3/ec2creds.py +4 -4
- openstackclient/identity/v3/endpoint.py +7 -7
- openstackclient/identity/v3/endpoint_group.py +8 -10
- openstackclient/identity/v3/federation_protocol.py +5 -5
- openstackclient/identity/v3/group.py +8 -8
- openstackclient/identity/v3/identity_provider.py +5 -5
- openstackclient/identity/v3/implied_role.py +3 -3
- openstackclient/identity/v3/limit.py +5 -5
- openstackclient/identity/v3/mapping.py +5 -5
- openstackclient/identity/v3/policy.py +5 -5
- openstackclient/identity/v3/project.py +5 -5
- openstackclient/identity/v3/region.py +5 -5
- openstackclient/identity/v3/registered_limit.py +5 -5
- openstackclient/identity/v3/role.py +7 -7
- openstackclient/identity/v3/role_assignment.py +92 -140
- openstackclient/identity/v3/service.py +64 -34
- openstackclient/identity/v3/service_provider.py +4 -4
- openstackclient/identity/v3/tag.py +2 -2
- openstackclient/identity/v3/token.py +5 -5
- openstackclient/identity/v3/trust.py +3 -3
- openstackclient/identity/v3/user.py +144 -80
- openstackclient/image/client.py +4 -4
- openstackclient/image/v1/image.py +8 -9
- openstackclient/image/v2/cache.py +12 -10
- openstackclient/image/v2/metadef_objects.py +44 -0
- openstackclient/image/v2/metadef_resource_type_association.py +189 -0
- openstackclient/image/v2/task.py +1 -1
- openstackclient/network/common.py +6 -5
- openstackclient/network/utils.py +2 -2
- openstackclient/network/v2/address_group.py +6 -6
- openstackclient/network/v2/address_scope.py +5 -5
- openstackclient/network/v2/default_security_group_rule.py +1 -1
- openstackclient/network/v2/floating_ip.py +8 -10
- openstackclient/network/v2/floating_ip_pool.py +6 -15
- openstackclient/network/v2/floating_ip_port_forwarding.py +5 -13
- openstackclient/network/v2/ip_availability.py +2 -2
- openstackclient/network/v2/l3_conntrack_helper.py +5 -5
- openstackclient/network/v2/network.py +8 -8
- openstackclient/network/v2/network_agent.py +8 -8
- openstackclient/network/v2/network_auto_allocated_topology.py +2 -2
- openstackclient/network/v2/network_flavor.py +6 -8
- openstackclient/network/v2/network_flavor_profile.py +4 -4
- openstackclient/network/v2/network_meter.py +3 -3
- openstackclient/network/v2/network_meter_rule.py +3 -3
- openstackclient/network/v2/network_qos_policy.py +5 -5
- openstackclient/network/v2/network_qos_rule.py +9 -9
- openstackclient/network/v2/network_qos_rule_type.py +1 -1
- openstackclient/network/v2/network_rbac.py +5 -5
- openstackclient/network/v2/network_segment.py +5 -5
- openstackclient/network/v2/network_segment_range.py +7 -7
- openstackclient/network/v2/network_trunk.py +7 -7
- openstackclient/network/v2/port.py +26 -12
- openstackclient/network/v2/router.py +403 -54
- openstackclient/network/v2/security_group.py +18 -14
- openstackclient/network/v2/security_group_rule.py +18 -15
- openstackclient/network/v2/subnet.py +15 -8
- openstackclient/network/v2/subnet_pool.py +6 -6
- openstackclient/object/v1/account.py +2 -2
- openstackclient/object/v1/container.py +7 -7
- openstackclient/object/v1/object.py +7 -7
- openstackclient/shell.py +4 -6
- openstackclient/tests/functional/base.py +1 -1
- openstackclient/tests/functional/common/test_extension.py +1 -1
- openstackclient/tests/functional/common/test_help.py +2 -2
- openstackclient/tests/functional/common/test_module.py +1 -1
- openstackclient/tests/functional/common/test_quota.py +43 -61
- openstackclient/tests/functional/compute/v2/common.py +2 -2
- openstackclient/tests/functional/compute/v2/test_flavor.py +2 -2
- openstackclient/tests/functional/compute/v2/test_keypair.py +1 -1
- openstackclient/tests/functional/compute/v2/test_server.py +5 -5
- openstackclient/tests/functional/compute/v2/test_server_event.py +1 -1
- openstackclient/tests/functional/identity/v2/common.py +3 -3
- openstackclient/tests/functional/identity/v3/common.py +14 -6
- openstackclient/tests/functional/identity/v3/test_application_credential.py +13 -19
- openstackclient/tests/functional/identity/v3/test_domain.py +1 -3
- openstackclient/tests/functional/identity/v3/test_endpoint.py +1 -1
- openstackclient/tests/functional/identity/v3/test_idp.py +1 -1
- openstackclient/tests/functional/identity/v3/test_limit.py +2 -2
- openstackclient/tests/functional/identity/v3/test_region.py +1 -3
- openstackclient/tests/functional/identity/v3/test_registered_limit.py +1 -1
- openstackclient/tests/functional/identity/v3/test_role.py +2 -2
- openstackclient/tests/functional/identity/v3/test_role_assignment.py +210 -0
- openstackclient/tests/functional/identity/v3/test_service.py +4 -6
- openstackclient/tests/functional/identity/v3/test_service_provider.py +1 -3
- openstackclient/tests/functional/image/base.py +1 -1
- openstackclient/tests/functional/image/v2/test_image.py +1 -1
- openstackclient/tests/functional/image/v2/test_info.py +1 -1
- openstackclient/tests/functional/network/v2/common.py +4 -6
- openstackclient/tests/functional/network/v2/test_network.py +5 -3
- openstackclient/tests/functional/network/v2/test_network_agent.py +7 -5
- openstackclient/tests/functional/network/v2/test_network_qos_rule.py +4 -4
- openstackclient/tests/functional/network/v2/test_port.py +11 -7
- openstackclient/tests/functional/network/v2/test_router.py +2 -2
- openstackclient/tests/functional/object/v1/common.py +1 -1
- openstackclient/tests/functional/object/v1/test_container.py +3 -3
- openstackclient/tests/functional/object/v1/test_object.py +9 -13
- openstackclient/tests/functional/volume/base.py +1 -1
- openstackclient/tests/functional/volume/v1/test_service.py +1 -1
- openstackclient/tests/functional/volume/v1/test_snapshot.py +2 -2
- openstackclient/tests/functional/volume/v1/test_transfer_request.py +2 -2
- openstackclient/tests/functional/volume/v1/test_volume_type.py +1 -1
- openstackclient/tests/functional/volume/v2/test_service.py +2 -2
- openstackclient/tests/functional/volume/v2/test_volume_backup.py +2 -2
- openstackclient/tests/functional/volume/v2/test_volume_snapshot.py +2 -2
- openstackclient/tests/functional/volume/v2/test_volume_type.py +1 -1
- openstackclient/tests/functional/volume/v3/test_volume_snapshot.py +2 -2
- openstackclient/tests/functional/volume/v3/test_volume_type.py +1 -1
- openstackclient/tests/unit/api/fakes.py +1 -1
- openstackclient/tests/unit/api/test_api.py +2 -2
- openstackclient/tests/unit/api/test_compute_v2.py +522 -707
- openstackclient/tests/unit/api/test_image_v1.py +1 -1
- openstackclient/tests/unit/api/test_image_v2.py +1 -1
- openstackclient/tests/unit/api/test_object_store_v1.py +4 -4
- openstackclient/tests/unit/common/test_limits.py +73 -35
- openstackclient/tests/unit/common/test_logs.py +2 -2
- openstackclient/tests/unit/common/test_module.py +4 -2
- openstackclient/tests/unit/common/test_project_cleanup.py +31 -6
- openstackclient/tests/unit/common/test_quota.py +490 -630
- openstackclient/tests/unit/compute/v2/fakes.py +37 -286
- openstackclient/tests/unit/compute/v2/test_agent.py +189 -147
- openstackclient/tests/unit/compute/v2/test_aggregate.py +18 -16
- openstackclient/tests/unit/compute/v2/test_console.py +4 -5
- openstackclient/tests/unit/compute/v2/test_flavor.py +59 -68
- openstackclient/tests/unit/compute/v2/test_host.py +83 -54
- openstackclient/tests/unit/compute/v2/test_hypervisor.py +28 -31
- openstackclient/tests/unit/compute/v2/test_hypervisor_stats.py +2 -2
- openstackclient/tests/unit/compute/v2/test_keypair.py +65 -50
- openstackclient/tests/unit/compute/v2/test_server.py +2895 -2459
- openstackclient/tests/unit/compute/v2/test_server_backup.py +1 -1
- openstackclient/tests/unit/compute/v2/test_server_event.py +14 -39
- openstackclient/tests/unit/compute/v2/test_server_group.py +28 -29
- openstackclient/tests/unit/compute/v2/test_server_migration.py +43 -68
- openstackclient/tests/unit/compute/v2/test_server_volume.py +17 -34
- openstackclient/tests/unit/compute/v2/test_service.py +34 -52
- openstackclient/tests/unit/compute/v2/test_usage.py +4 -4
- openstackclient/tests/unit/fakes.py +11 -11
- openstackclient/tests/unit/identity/v2_0/fakes.py +27 -10
- openstackclient/tests/unit/identity/v2_0/test_catalog.py +3 -3
- openstackclient/tests/unit/identity/v2_0/test_endpoint.py +7 -7
- openstackclient/tests/unit/identity/v2_0/test_project.py +8 -8
- openstackclient/tests/unit/identity/v2_0/test_role.py +10 -10
- openstackclient/tests/unit/identity/v2_0/test_role_assignment.py +4 -4
- openstackclient/tests/unit/identity/v2_0/test_service.py +6 -6
- openstackclient/tests/unit/identity/v2_0/test_token.py +4 -4
- openstackclient/tests/unit/identity/v2_0/test_user.py +8 -8
- openstackclient/tests/unit/identity/v3/fakes.py +59 -20
- openstackclient/tests/unit/identity/v3/test_access_rule.py +5 -5
- openstackclient/tests/unit/identity/v3/test_application_credential.py +212 -235
- openstackclient/tests/unit/identity/v3/test_catalog.py +3 -3
- openstackclient/tests/unit/identity/v3/test_consumer.py +7 -8
- openstackclient/tests/unit/identity/v3/test_credential.py +9 -9
- openstackclient/tests/unit/identity/v3/test_domain.py +8 -8
- openstackclient/tests/unit/identity/v3/test_endpoint.py +13 -13
- openstackclient/tests/unit/identity/v3/test_endpoint_group.py +12 -14
- openstackclient/tests/unit/identity/v3/test_group.py +12 -12
- openstackclient/tests/unit/identity/v3/test_identity_provider.py +8 -8
- openstackclient/tests/unit/identity/v3/test_implied_role.py +5 -5
- openstackclient/tests/unit/identity/v3/test_limit.py +7 -7
- openstackclient/tests/unit/identity/v3/test_mappings.py +7 -7
- openstackclient/tests/unit/identity/v3/test_oauth.py +5 -5
- openstackclient/tests/unit/identity/v3/test_project.py +16 -16
- openstackclient/tests/unit/identity/v3/test_protocol.py +7 -7
- openstackclient/tests/unit/identity/v3/test_region.py +7 -7
- openstackclient/tests/unit/identity/v3/test_registered_limit.py +12 -13
- openstackclient/tests/unit/identity/v3/test_role.py +13 -13
- openstackclient/tests/unit/identity/v3/test_role_assignment.py +410 -331
- openstackclient/tests/unit/identity/v3/test_service.py +93 -97
- openstackclient/tests/unit/identity/v3/test_service_provider.py +7 -7
- openstackclient/tests/unit/identity/v3/test_token.py +4 -4
- openstackclient/tests/unit/identity/v3/test_trust.py +9 -9
- openstackclient/tests/unit/identity/v3/test_unscoped_saml.py +4 -4
- openstackclient/tests/unit/identity/v3/test_user.py +299 -327
- openstackclient/tests/unit/image/v1/test_image.py +6 -6
- openstackclient/tests/unit/image/v2/fakes.py +46 -9
- openstackclient/tests/unit/image/v2/test_cache.py +2 -2
- openstackclient/tests/unit/image/v2/test_image.py +3 -3
- openstackclient/tests/unit/image/v2/test_metadef_objects.py +62 -0
- openstackclient/tests/unit/image/v2/test_metadef_resource_type_association.py +131 -0
- openstackclient/tests/unit/integ/base.py +1 -1
- openstackclient/tests/unit/integ/cli/test_project.py +4 -4
- openstackclient/tests/unit/integ/cli/test_shell.py +7 -7
- openstackclient/tests/unit/network/test_common.py +12 -21
- openstackclient/tests/unit/network/v2/fakes.py +64 -130
- openstackclient/tests/unit/network/v2/test_address_group.py +15 -15
- openstackclient/tests/unit/network/v2/test_address_scope.py +13 -13
- openstackclient/tests/unit/network/v2/test_default_security_group_rule.py +49 -27
- openstackclient/tests/unit/network/v2/test_floating_ip_compute.py +40 -38
- openstackclient/tests/unit/network/v2/test_floating_ip_network.py +15 -15
- openstackclient/tests/unit/network/v2/test_floating_ip_pool_compute.py +4 -7
- openstackclient/tests/unit/network/v2/test_floating_ip_pool_network.py +3 -5
- openstackclient/tests/unit/network/v2/test_floating_ip_port_forwarding.py +11 -11
- openstackclient/tests/unit/network/v2/test_ip_availability.py +6 -6
- openstackclient/tests/unit/network/v2/test_l3_conntrack_helper.py +11 -21
- openstackclient/tests/unit/network/v2/test_local_ip.py +7 -7
- openstackclient/tests/unit/network/v2/test_local_ip_association.py +3 -5
- openstackclient/tests/unit/network/v2/test_ndp_proxy.py +13 -13
- openstackclient/tests/unit/network/v2/test_network.py +23 -28
- openstackclient/tests/unit/network/v2/test_network_agent.py +17 -21
- openstackclient/tests/unit/network/v2/test_network_auto_allocated_topology.py +8 -8
- openstackclient/tests/unit/network/v2/test_network_compute.py +66 -65
- openstackclient/tests/unit/network/v2/test_network_flavor.py +17 -19
- openstackclient/tests/unit/network/v2/test_network_flavor_profile.py +13 -13
- openstackclient/tests/unit/network/v2/test_network_meter.py +11 -11
- openstackclient/tests/unit/network/v2/test_network_meter_rule.py +11 -11
- openstackclient/tests/unit/network/v2/test_network_qos_policy.py +11 -21
- openstackclient/tests/unit/network/v2/test_network_qos_rule.py +51 -77
- openstackclient/tests/unit/network/v2/test_network_qos_rule_type.py +5 -9
- openstackclient/tests/unit/network/v2/test_network_rbac.py +12 -12
- openstackclient/tests/unit/network/v2/test_network_segment.py +11 -15
- openstackclient/tests/unit/network/v2/test_network_segment_range.py +11 -13
- openstackclient/tests/unit/network/v2/test_network_service_provider.py +3 -5
- openstackclient/tests/unit/network/v2/test_network_trunk.py +11 -11
- openstackclient/tests/unit/network/v2/test_port.py +22 -25
- openstackclient/tests/unit/network/v2/test_router.py +721 -51
- openstackclient/tests/unit/network/v2/test_security_group_compute.py +65 -49
- openstackclient/tests/unit/network/v2/test_security_group_network.py +15 -15
- openstackclient/tests/unit/network/v2/test_security_group_rule_compute.py +57 -45
- openstackclient/tests/unit/network/v2/test_security_group_rule_network.py +11 -19
- openstackclient/tests/unit/network/v2/test_subnet.py +29 -25
- openstackclient/tests/unit/network/v2/test_subnet_pool.py +15 -15
- openstackclient/tests/unit/object/v1/fakes.py +1 -1
- openstackclient/tests/unit/object/v1/test_container.py +5 -5
- openstackclient/tests/unit/object/v1/test_container_all.py +6 -6
- openstackclient/tests/unit/object/v1/test_object.py +3 -3
- openstackclient/tests/unit/object/v1/test_object_all.py +5 -5
- openstackclient/tests/unit/test_shell.py +5 -5
- openstackclient/tests/unit/utils.py +4 -1
- openstackclient/tests/unit/volume/test_find_resource.py +2 -2
- openstackclient/tests/unit/volume/v1/fakes.py +5 -6
- openstackclient/tests/unit/volume/v1/test_volume.py +5 -4
- openstackclient/tests/unit/volume/v2/fakes.py +39 -259
- openstackclient/tests/unit/volume/v2/test_consistency_group_snapshot.py +5 -5
- openstackclient/tests/unit/volume/v2/test_qos_specs.py +9 -9
- openstackclient/tests/unit/volume/v2/test_volume.py +21 -87
- openstackclient/tests/unit/volume/v2/test_volume_backup.py +7 -368
- openstackclient/tests/unit/volume/v2/test_volume_snapshot.py +1 -1
- openstackclient/tests/unit/volume/v2/test_volume_transfer_request.py +0 -44
- openstackclient/tests/unit/volume/v2/test_volume_type.py +6 -87
- openstackclient/tests/unit/volume/v3/fakes.py +505 -22
- openstackclient/tests/unit/volume/v3/test_block_storage_cleanup.py +2 -3
- openstackclient/tests/unit/volume/v3/test_block_storage_cluster.py +10 -11
- openstackclient/tests/unit/volume/v3/test_block_storage_log_level.py +10 -6
- openstackclient/tests/unit/volume/v3/test_block_storage_manage.py +25 -17
- openstackclient/tests/unit/volume/v3/test_block_storage_resource_filter.py +6 -32
- openstackclient/tests/unit/volume/v3/test_service.py +271 -0
- openstackclient/tests/unit/volume/v3/test_volume.py +2177 -33
- openstackclient/tests/unit/volume/v3/test_volume_attachment.py +48 -52
- openstackclient/tests/unit/volume/v3/test_volume_backup.py +892 -0
- openstackclient/tests/unit/volume/v3/test_volume_group.py +19 -20
- openstackclient/tests/unit/volume/v3/test_volume_group_snapshot.py +14 -34
- openstackclient/tests/unit/volume/v3/test_volume_group_type.py +13 -16
- openstackclient/tests/unit/volume/v3/test_volume_message.py +10 -11
- openstackclient/tests/unit/volume/v3/test_volume_snapshot.py +161 -0
- openstackclient/tests/unit/volume/v3/test_volume_transfer_request.py +425 -0
- openstackclient/tests/unit/volume/v3/test_volume_type.py +1109 -0
- openstackclient/volume/v1/qos_specs.py +7 -7
- openstackclient/volume/v1/service.py +2 -2
- openstackclient/volume/v1/volume.py +12 -12
- openstackclient/volume/v1/volume_backup.py +7 -7
- openstackclient/volume/v1/volume_snapshot.py +8 -8
- openstackclient/volume/v1/volume_transfer_request.py +5 -5
- openstackclient/volume/v1/volume_type.py +7 -7
- openstackclient/volume/v2/backup_record.py +2 -2
- openstackclient/volume/v2/consistency_group.py +7 -9
- openstackclient/volume/v2/consistency_group_snapshot.py +4 -12
- openstackclient/volume/v2/qos_specs.py +7 -7
- openstackclient/volume/v2/service.py +2 -2
- openstackclient/volume/v2/volume.py +80 -80
- openstackclient/volume/v2/volume_backend.py +2 -2
- openstackclient/volume/v2/volume_backup.py +7 -217
- openstackclient/volume/v2/volume_host.py +2 -2
- openstackclient/volume/v2/volume_snapshot.py +8 -8
- openstackclient/volume/v2/volume_transfer_request.py +5 -37
- openstackclient/volume/v2/volume_type.py +7 -89
- openstackclient/volume/v3/service.py +56 -0
- openstackclient/volume/v3/volume.py +971 -0
- openstackclient/volume/v3/volume_attachment.py +31 -29
- openstackclient/volume/v3/volume_backup.py +670 -0
- openstackclient/volume/v3/volume_message.py +1 -1
- openstackclient/volume/v3/volume_snapshot.py +97 -0
- openstackclient/volume/v3/volume_transfer_request.py +233 -0
- openstackclient/volume/v3/volume_type.py +967 -0
- {python_openstackclient-6.6.0.dist-info → python_openstackclient-7.0.0.dist-info}/AUTHORS +4 -0
- {python_openstackclient-6.6.0.dist-info → python_openstackclient-7.0.0.dist-info}/METADATA +3 -3
- python_openstackclient-7.0.0.dist-info/RECORD +502 -0
- {python_openstackclient-6.6.0.dist-info → python_openstackclient-7.0.0.dist-info}/entry_points.txt +33 -27
- python_openstackclient-7.0.0.dist-info/pbr.json +1 -0
- python_openstackclient-6.6.0.dist-info/RECORD +0 -489
- python_openstackclient-6.6.0.dist-info/pbr.json +0 -1
- {python_openstackclient-6.6.0.dist-info → python_openstackclient-7.0.0.dist-info}/LICENSE +0 -0
- {python_openstackclient-6.6.0.dist-info → python_openstackclient-7.0.0.dist-info}/WHEEL +0 -0
- {python_openstackclient-6.6.0.dist-info → python_openstackclient-7.0.0.dist-info}/top_level.txt +0 -0
|
@@ -12,17 +12,17 @@
|
|
|
12
12
|
#
|
|
13
13
|
|
|
14
14
|
from unittest import mock
|
|
15
|
-
from unittest.mock import call
|
|
16
15
|
|
|
17
16
|
from osc_lib import exceptions
|
|
18
17
|
|
|
18
|
+
from openstackclient.api import compute_v2
|
|
19
19
|
from openstackclient.network.v2 import security_group
|
|
20
20
|
from openstackclient.tests.unit.compute.v2 import fakes as compute_fakes
|
|
21
21
|
from openstackclient.tests.unit.identity.v3 import fakes as identity_fakes
|
|
22
22
|
from openstackclient.tests.unit import utils as tests_utils
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
@mock.patch(
|
|
25
|
+
@mock.patch.object(compute_v2, 'create_security_group')
|
|
26
26
|
class TestCreateSecurityGroupCompute(compute_fakes.TestComputev2):
|
|
27
27
|
project = identity_fakes.FakeProject.create_one_project()
|
|
28
28
|
domain = identity_fakes.FakeDomain.create_one_domain()
|
|
@@ -47,7 +47,7 @@ class TestCreateSecurityGroupCompute(compute_fakes.TestComputev2):
|
|
|
47
47
|
)
|
|
48
48
|
|
|
49
49
|
def setUp(self):
|
|
50
|
-
super(
|
|
50
|
+
super().setUp()
|
|
51
51
|
|
|
52
52
|
self.app.client_manager.network_endpoint_enabled = False
|
|
53
53
|
|
|
@@ -72,6 +72,7 @@ class TestCreateSecurityGroupCompute(compute_fakes.TestComputev2):
|
|
|
72
72
|
columns, data = self.cmd.take_action(parsed_args)
|
|
73
73
|
|
|
74
74
|
sg_mock.assert_called_once_with(
|
|
75
|
+
self.compute_sdk_client,
|
|
75
76
|
self._security_group['name'],
|
|
76
77
|
self._security_group['name'],
|
|
77
78
|
)
|
|
@@ -94,6 +95,7 @@ class TestCreateSecurityGroupCompute(compute_fakes.TestComputev2):
|
|
|
94
95
|
columns, data = self.cmd.take_action(parsed_args)
|
|
95
96
|
|
|
96
97
|
sg_mock.assert_called_once_with(
|
|
98
|
+
self.compute_sdk_client,
|
|
97
99
|
self._security_group['name'],
|
|
98
100
|
self._security_group['description'],
|
|
99
101
|
)
|
|
@@ -101,18 +103,18 @@ class TestCreateSecurityGroupCompute(compute_fakes.TestComputev2):
|
|
|
101
103
|
self.assertCountEqual(self.data, data)
|
|
102
104
|
|
|
103
105
|
|
|
104
|
-
@mock.patch(
|
|
106
|
+
@mock.patch.object(compute_v2, 'delete_security_group')
|
|
105
107
|
class TestDeleteSecurityGroupCompute(compute_fakes.TestComputev2):
|
|
106
108
|
# The security groups to be deleted.
|
|
107
109
|
_security_groups = compute_fakes.create_security_groups()
|
|
108
110
|
|
|
109
111
|
def setUp(self):
|
|
110
|
-
super(
|
|
112
|
+
super().setUp()
|
|
111
113
|
|
|
112
114
|
self.app.client_manager.network_endpoint_enabled = False
|
|
113
115
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
+
compute_v2.find_security_group = mock.Mock(
|
|
117
|
+
side_effect=self._security_groups
|
|
116
118
|
)
|
|
117
119
|
|
|
118
120
|
# Get the command object to test
|
|
@@ -131,59 +133,68 @@ class TestDeleteSecurityGroupCompute(compute_fakes.TestComputev2):
|
|
|
131
133
|
result = self.cmd.take_action(parsed_args)
|
|
132
134
|
|
|
133
135
|
sg_mock.assert_called_once_with(
|
|
136
|
+
self.compute_sdk_client,
|
|
134
137
|
self._security_groups[0]['id'],
|
|
135
138
|
)
|
|
136
139
|
self.assertIsNone(result)
|
|
137
140
|
|
|
138
141
|
def test_security_group_multi_delete(self, sg_mock):
|
|
139
142
|
sg_mock.return_value = mock.Mock(return_value=None)
|
|
140
|
-
arglist = [
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
arglist.append(s['id'])
|
|
143
|
+
arglist = [
|
|
144
|
+
self._security_groups[0]['id'],
|
|
145
|
+
self._security_groups[1]['id'],
|
|
146
|
+
]
|
|
145
147
|
verifylist = [
|
|
146
148
|
('group', arglist),
|
|
147
149
|
]
|
|
148
|
-
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
149
150
|
|
|
151
|
+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
150
152
|
result = self.cmd.take_action(parsed_args)
|
|
151
153
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
sg_mock.assert_has_calls(
|
|
155
|
+
[
|
|
156
|
+
mock.call(
|
|
157
|
+
self.compute_sdk_client, self._security_groups[0]['id']
|
|
158
|
+
),
|
|
159
|
+
mock.call(
|
|
160
|
+
self.compute_sdk_client, self._security_groups[1]['id']
|
|
161
|
+
),
|
|
162
|
+
]
|
|
163
|
+
)
|
|
156
164
|
self.assertIsNone(result)
|
|
157
165
|
|
|
158
166
|
def test_security_group_multi_delete_with_exception(self, sg_mock):
|
|
159
167
|
sg_mock.return_value = mock.Mock(return_value=None)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
exceptions.
|
|
168
|
+
compute_v2.find_security_group.side_effect = [
|
|
169
|
+
self._security_groups[0],
|
|
170
|
+
exceptions.NotFound('foo'),
|
|
163
171
|
]
|
|
164
172
|
arglist = [
|
|
165
173
|
self._security_groups[0]['id'],
|
|
166
174
|
'unexist_security_group',
|
|
167
175
|
]
|
|
168
176
|
verifylist = [
|
|
169
|
-
(
|
|
170
|
-
'group',
|
|
171
|
-
[self._security_groups[0]['id'], 'unexist_security_group'],
|
|
172
|
-
),
|
|
177
|
+
('group', arglist),
|
|
173
178
|
]
|
|
174
|
-
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
175
|
-
|
|
176
|
-
try:
|
|
177
|
-
self.cmd.take_action(parsed_args)
|
|
178
|
-
self.fail('CommandError should be raised.')
|
|
179
|
-
except exceptions.CommandError as e:
|
|
180
|
-
self.assertEqual('1 of 2 groups failed to delete.', str(e))
|
|
181
179
|
|
|
182
|
-
|
|
183
|
-
|
|
180
|
+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
181
|
+
exc = self.assertRaises(
|
|
182
|
+
exceptions.CommandError,
|
|
183
|
+
self.cmd.take_action,
|
|
184
|
+
parsed_args,
|
|
185
|
+
)
|
|
186
|
+
self.assertEqual('1 of 2 groups failed to delete.', str(exc))
|
|
187
|
+
|
|
188
|
+
sg_mock.assert_has_calls(
|
|
189
|
+
[
|
|
190
|
+
mock.call(
|
|
191
|
+
self.compute_sdk_client, self._security_groups[0]['id']
|
|
192
|
+
),
|
|
193
|
+
]
|
|
194
|
+
)
|
|
184
195
|
|
|
185
196
|
|
|
186
|
-
@mock.patch(
|
|
197
|
+
@mock.patch.object(compute_v2, 'list_security_groups')
|
|
187
198
|
class TestListSecurityGroupCompute(compute_fakes.TestComputev2):
|
|
188
199
|
# The security group to be listed.
|
|
189
200
|
_security_groups = compute_fakes.create_security_groups(count=3)
|
|
@@ -221,7 +232,7 @@ class TestListSecurityGroupCompute(compute_fakes.TestComputev2):
|
|
|
221
232
|
)
|
|
222
233
|
|
|
223
234
|
def setUp(self):
|
|
224
|
-
super(
|
|
235
|
+
super().setUp()
|
|
225
236
|
|
|
226
237
|
self.app.client_manager.network_endpoint_enabled = False
|
|
227
238
|
|
|
@@ -238,8 +249,9 @@ class TestListSecurityGroupCompute(compute_fakes.TestComputev2):
|
|
|
238
249
|
|
|
239
250
|
columns, data = self.cmd.take_action(parsed_args)
|
|
240
251
|
|
|
241
|
-
|
|
242
|
-
|
|
252
|
+
sg_mock.assert_called_once_with(
|
|
253
|
+
self.compute_sdk_client, all_projects=False
|
|
254
|
+
)
|
|
243
255
|
self.assertEqual(self.columns, columns)
|
|
244
256
|
self.assertCountEqual(self.data, list(data))
|
|
245
257
|
|
|
@@ -255,23 +267,24 @@ class TestListSecurityGroupCompute(compute_fakes.TestComputev2):
|
|
|
255
267
|
|
|
256
268
|
columns, data = self.cmd.take_action(parsed_args)
|
|
257
269
|
|
|
258
|
-
|
|
259
|
-
|
|
270
|
+
sg_mock.assert_called_once_with(
|
|
271
|
+
self.compute_sdk_client, all_projects=True
|
|
272
|
+
)
|
|
260
273
|
self.assertEqual(self.columns_all_projects, columns)
|
|
261
274
|
self.assertCountEqual(self.data_all_projects, list(data))
|
|
262
275
|
|
|
263
276
|
|
|
264
|
-
@mock.patch(
|
|
277
|
+
@mock.patch.object(compute_v2, 'update_security_group')
|
|
265
278
|
class TestSetSecurityGroupCompute(compute_fakes.TestComputev2):
|
|
266
279
|
# The security group to be set.
|
|
267
280
|
_security_group = compute_fakes.create_one_security_group()
|
|
268
281
|
|
|
269
282
|
def setUp(self):
|
|
270
|
-
super(
|
|
283
|
+
super().setUp()
|
|
271
284
|
|
|
272
285
|
self.app.client_manager.network_endpoint_enabled = False
|
|
273
286
|
|
|
274
|
-
|
|
287
|
+
compute_v2.find_security_group = mock.Mock(
|
|
275
288
|
return_value=self._security_group
|
|
276
289
|
)
|
|
277
290
|
|
|
@@ -296,9 +309,7 @@ class TestSetSecurityGroupCompute(compute_fakes.TestComputev2):
|
|
|
296
309
|
result = self.cmd.take_action(parsed_args)
|
|
297
310
|
|
|
298
311
|
sg_mock.assert_called_once_with(
|
|
299
|
-
self._security_group
|
|
300
|
-
self._security_group['name'],
|
|
301
|
-
self._security_group['description'],
|
|
312
|
+
self.compute_sdk_client, self._security_group['id']
|
|
302
313
|
)
|
|
303
314
|
self.assertIsNone(result)
|
|
304
315
|
|
|
@@ -323,12 +334,15 @@ class TestSetSecurityGroupCompute(compute_fakes.TestComputev2):
|
|
|
323
334
|
result = self.cmd.take_action(parsed_args)
|
|
324
335
|
|
|
325
336
|
sg_mock.assert_called_once_with(
|
|
326
|
-
self.
|
|
337
|
+
self.compute_sdk_client,
|
|
338
|
+
self._security_group['id'],
|
|
339
|
+
name=new_name,
|
|
340
|
+
description=new_description,
|
|
327
341
|
)
|
|
328
342
|
self.assertIsNone(result)
|
|
329
343
|
|
|
330
344
|
|
|
331
|
-
@mock.patch(
|
|
345
|
+
@mock.patch.object(compute_v2, 'find_security_group')
|
|
332
346
|
class TestShowSecurityGroupCompute(compute_fakes.TestComputev2):
|
|
333
347
|
# The security group rule to be shown with the group.
|
|
334
348
|
_security_group_rule = compute_fakes.create_one_security_group_rule()
|
|
@@ -355,7 +369,7 @@ class TestShowSecurityGroupCompute(compute_fakes.TestComputev2):
|
|
|
355
369
|
)
|
|
356
370
|
|
|
357
371
|
def setUp(self):
|
|
358
|
-
super(
|
|
372
|
+
super().setUp()
|
|
359
373
|
|
|
360
374
|
self.app.client_manager.network_endpoint_enabled = False
|
|
361
375
|
|
|
@@ -379,6 +393,8 @@ class TestShowSecurityGroupCompute(compute_fakes.TestComputev2):
|
|
|
379
393
|
|
|
380
394
|
columns, data = self.cmd.take_action(parsed_args)
|
|
381
395
|
|
|
382
|
-
sg_mock.assert_called_once_with(
|
|
396
|
+
sg_mock.assert_called_once_with(
|
|
397
|
+
self.compute_sdk_client, self._security_group['id']
|
|
398
|
+
)
|
|
383
399
|
self.assertEqual(self.columns, columns)
|
|
384
400
|
self.assertCountEqual(self.data, data)
|
|
@@ -24,12 +24,12 @@ from openstackclient.tests.unit import utils as tests_utils
|
|
|
24
24
|
|
|
25
25
|
class TestSecurityGroupNetwork(network_fakes.TestNetworkV2):
|
|
26
26
|
def setUp(self):
|
|
27
|
-
super(
|
|
27
|
+
super().setUp()
|
|
28
28
|
|
|
29
29
|
# Get a shortcut to the ProjectManager Mock
|
|
30
|
-
self.projects_mock = self.
|
|
30
|
+
self.projects_mock = self.identity_client.projects
|
|
31
31
|
# Get a shortcut to the DomainManager Mock
|
|
32
|
-
self.domains_mock = self.
|
|
32
|
+
self.domains_mock = self.identity_client.domains
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
class TestCreateSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|
@@ -61,7 +61,7 @@ class TestCreateSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|
|
61
61
|
)
|
|
62
62
|
|
|
63
63
|
def setUp(self):
|
|
64
|
-
super(
|
|
64
|
+
super().setUp()
|
|
65
65
|
|
|
66
66
|
self.network_client.create_security_group = mock.Mock(
|
|
67
67
|
return_value=self._security_group
|
|
@@ -72,7 +72,7 @@ class TestCreateSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|
|
72
72
|
self.network_client.set_tags = mock.Mock(return_value=None)
|
|
73
73
|
|
|
74
74
|
# Get the command object to test
|
|
75
|
-
self.cmd = security_group.CreateSecurityGroup(self.app,
|
|
75
|
+
self.cmd = security_group.CreateSecurityGroup(self.app, None)
|
|
76
76
|
|
|
77
77
|
def test_create_no_options(self):
|
|
78
78
|
self.assertRaises(
|
|
@@ -177,7 +177,7 @@ class TestDeleteSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|
|
177
177
|
_security_groups = network_fakes.FakeSecurityGroup.create_security_groups()
|
|
178
178
|
|
|
179
179
|
def setUp(self):
|
|
180
|
-
super(
|
|
180
|
+
super().setUp()
|
|
181
181
|
|
|
182
182
|
self.network_client.delete_security_group = mock.Mock(
|
|
183
183
|
return_value=None
|
|
@@ -190,7 +190,7 @@ class TestDeleteSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|
|
190
190
|
)
|
|
191
191
|
|
|
192
192
|
# Get the command object to test
|
|
193
|
-
self.cmd = security_group.DeleteSecurityGroup(self.app,
|
|
193
|
+
self.cmd = security_group.DeleteSecurityGroup(self.app, None)
|
|
194
194
|
|
|
195
195
|
def test_security_group_delete(self):
|
|
196
196
|
arglist = [
|
|
@@ -289,14 +289,14 @@ class TestListSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|
|
289
289
|
)
|
|
290
290
|
|
|
291
291
|
def setUp(self):
|
|
292
|
-
super(
|
|
292
|
+
super().setUp()
|
|
293
293
|
|
|
294
294
|
self.network_client.security_groups = mock.Mock(
|
|
295
295
|
return_value=self._security_groups
|
|
296
296
|
)
|
|
297
297
|
|
|
298
298
|
# Get the command object to test
|
|
299
|
-
self.cmd = security_group.ListSecurityGroup(self.app,
|
|
299
|
+
self.cmd = security_group.ListSecurityGroup(self.app, None)
|
|
300
300
|
|
|
301
301
|
def test_security_group_list_no_options(self):
|
|
302
302
|
arglist = []
|
|
@@ -419,7 +419,7 @@ class TestSetSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|
|
419
419
|
)
|
|
420
420
|
|
|
421
421
|
def setUp(self):
|
|
422
|
-
super(
|
|
422
|
+
super().setUp()
|
|
423
423
|
|
|
424
424
|
self.network_client.update_security_group = mock.Mock(
|
|
425
425
|
return_value=None
|
|
@@ -431,7 +431,7 @@ class TestSetSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|
|
431
431
|
self.network_client.set_tags = mock.Mock(return_value=None)
|
|
432
432
|
|
|
433
433
|
# Get the command object to test
|
|
434
|
-
self.cmd = security_group.SetSecurityGroup(self.app,
|
|
434
|
+
self.cmd = security_group.SetSecurityGroup(self.app, None)
|
|
435
435
|
|
|
436
436
|
def test_set_no_options(self):
|
|
437
437
|
self.assertRaises(
|
|
@@ -549,14 +549,14 @@ class TestShowSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|
|
549
549
|
)
|
|
550
550
|
|
|
551
551
|
def setUp(self):
|
|
552
|
-
super(
|
|
552
|
+
super().setUp()
|
|
553
553
|
|
|
554
554
|
self.network_client.find_security_group = mock.Mock(
|
|
555
555
|
return_value=self._security_group
|
|
556
556
|
)
|
|
557
557
|
|
|
558
558
|
# Get the command object to test
|
|
559
|
-
self.cmd = security_group.ShowSecurityGroup(self.app,
|
|
559
|
+
self.cmd = security_group.ShowSecurityGroup(self.app, None)
|
|
560
560
|
|
|
561
561
|
def test_show_no_options(self):
|
|
562
562
|
self.assertRaises(
|
|
@@ -590,7 +590,7 @@ class TestUnsetSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|
|
590
590
|
)
|
|
591
591
|
|
|
592
592
|
def setUp(self):
|
|
593
|
-
super(
|
|
593
|
+
super().setUp()
|
|
594
594
|
|
|
595
595
|
self.network_client.update_security_group = mock.Mock(
|
|
596
596
|
return_value=None
|
|
@@ -602,7 +602,7 @@ class TestUnsetSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|
|
602
602
|
self.network_client.set_tags = mock.Mock(return_value=None)
|
|
603
603
|
|
|
604
604
|
# Get the command object to test
|
|
605
|
-
self.cmd = security_group.UnsetSecurityGroup(self.app,
|
|
605
|
+
self.cmd = security_group.UnsetSecurityGroup(self.app, None)
|
|
606
606
|
|
|
607
607
|
def test_set_no_options(self):
|
|
608
608
|
self.assertRaises(
|
|
@@ -9,13 +9,12 @@
|
|
|
9
9
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
10
10
|
# License for the specific language governing permissions and limitations
|
|
11
11
|
# under the License.
|
|
12
|
-
#
|
|
13
12
|
|
|
14
13
|
from unittest import mock
|
|
15
|
-
from unittest.mock import call
|
|
16
14
|
|
|
17
15
|
from osc_lib import exceptions
|
|
18
16
|
|
|
17
|
+
from openstackclient.api import compute_v2
|
|
19
18
|
from openstackclient.network import utils as network_utils
|
|
20
19
|
from openstackclient.network.v2 import security_group_rule
|
|
21
20
|
from openstackclient.tests.unit.compute.v2 import fakes as compute_fakes
|
|
@@ -23,7 +22,7 @@ from openstackclient.tests.unit.identity.v3 import fakes as identity_fakes
|
|
|
23
22
|
from openstackclient.tests.unit import utils as tests_utils
|
|
24
23
|
|
|
25
24
|
|
|
26
|
-
@mock.patch(
|
|
25
|
+
@mock.patch.object(compute_v2, 'create_security_group_rule')
|
|
27
26
|
class TestCreateSecurityGroupRuleCompute(compute_fakes.TestComputev2):
|
|
28
27
|
project = identity_fakes.FakeProject.create_one_project()
|
|
29
28
|
domain = identity_fakes.FakeDomain.create_one_domain()
|
|
@@ -47,11 +46,11 @@ class TestCreateSecurityGroupRuleCompute(compute_fakes.TestComputev2):
|
|
|
47
46
|
return expected_columns, expected_data
|
|
48
47
|
|
|
49
48
|
def setUp(self):
|
|
50
|
-
super(
|
|
49
|
+
super().setUp()
|
|
51
50
|
|
|
52
51
|
self.app.client_manager.network_endpoint_enabled = False
|
|
53
52
|
|
|
54
|
-
|
|
53
|
+
compute_v2.find_security_group = mock.Mock(
|
|
55
54
|
return_value=self._security_group,
|
|
56
55
|
)
|
|
57
56
|
|
|
@@ -159,9 +158,8 @@ class TestCreateSecurityGroupRuleCompute(compute_fakes.TestComputev2):
|
|
|
159
158
|
|
|
160
159
|
columns, data = self.cmd.take_action(parsed_args)
|
|
161
160
|
|
|
162
|
-
# TODO(dtroyer): save this for the security group rule changes
|
|
163
|
-
# self.compute_client.api.security_group_rule_create.assert_called_once_with(
|
|
164
161
|
sgr_mock.assert_called_once_with(
|
|
162
|
+
self.compute_sdk_client,
|
|
165
163
|
security_group_id=self._security_group['id'],
|
|
166
164
|
ip_protocol=self._security_group_rule['ip_protocol'],
|
|
167
165
|
from_port=self._security_group_rule['from_port'],
|
|
@@ -203,9 +201,8 @@ class TestCreateSecurityGroupRuleCompute(compute_fakes.TestComputev2):
|
|
|
203
201
|
|
|
204
202
|
columns, data = self.cmd.take_action(parsed_args)
|
|
205
203
|
|
|
206
|
-
# TODO(dtroyer): save this for the security group rule changes
|
|
207
|
-
# self.compute_client.api.security_group_rule_create.assert_called_once_with(
|
|
208
204
|
sgr_mock.assert_called_once_with(
|
|
205
|
+
self.compute_sdk_client,
|
|
209
206
|
security_group_id=self._security_group['id'],
|
|
210
207
|
ip_protocol=self._security_group_rule['ip_protocol'],
|
|
211
208
|
from_port=self._security_group_rule['from_port'],
|
|
@@ -242,9 +239,8 @@ class TestCreateSecurityGroupRuleCompute(compute_fakes.TestComputev2):
|
|
|
242
239
|
|
|
243
240
|
columns, data = self.cmd.take_action(parsed_args)
|
|
244
241
|
|
|
245
|
-
# TODO(dtroyer): save this for the security group rule changes
|
|
246
|
-
# self.compute_client.api.security_group_rule_create.assert_called_once_with(
|
|
247
242
|
sgr_mock.assert_called_once_with(
|
|
243
|
+
self.compute_sdk_client,
|
|
248
244
|
security_group_id=self._security_group['id'],
|
|
249
245
|
ip_protocol=self._security_group_rule['ip_protocol'],
|
|
250
246
|
from_port=self._security_group_rule['from_port'],
|
|
@@ -282,9 +278,8 @@ class TestCreateSecurityGroupRuleCompute(compute_fakes.TestComputev2):
|
|
|
282
278
|
|
|
283
279
|
columns, data = self.cmd.take_action(parsed_args)
|
|
284
280
|
|
|
285
|
-
# TODO(dtroyer): save this for the security group rule changes
|
|
286
|
-
# self.compute_client.api.security_group_rule_create.assert_called_once_with(
|
|
287
281
|
sgr_mock.assert_called_once_with(
|
|
282
|
+
self.compute_sdk_client,
|
|
288
283
|
security_group_id=self._security_group['id'],
|
|
289
284
|
ip_protocol=self._security_group_rule['ip_protocol'],
|
|
290
285
|
from_port=self._security_group_rule['from_port'],
|
|
@@ -296,13 +291,13 @@ class TestCreateSecurityGroupRuleCompute(compute_fakes.TestComputev2):
|
|
|
296
291
|
self.assertEqual(expected_data, data)
|
|
297
292
|
|
|
298
293
|
|
|
299
|
-
@mock.patch(
|
|
294
|
+
@mock.patch.object(compute_v2, 'delete_security_group_rule')
|
|
300
295
|
class TestDeleteSecurityGroupRuleCompute(compute_fakes.TestComputev2):
|
|
301
296
|
# The security group rule to be deleted.
|
|
302
297
|
_security_group_rules = compute_fakes.create_security_group_rules(count=2)
|
|
303
298
|
|
|
304
299
|
def setUp(self):
|
|
305
|
-
super(
|
|
300
|
+
super().setUp()
|
|
306
301
|
|
|
307
302
|
self.app.client_manager.network_endpoint_enabled = False
|
|
308
303
|
|
|
@@ -320,26 +315,35 @@ class TestDeleteSecurityGroupRuleCompute(compute_fakes.TestComputev2):
|
|
|
320
315
|
|
|
321
316
|
result = self.cmd.take_action(parsed_args)
|
|
322
317
|
|
|
323
|
-
sgr_mock.assert_called_once_with(
|
|
318
|
+
sgr_mock.assert_called_once_with(
|
|
319
|
+
self.compute_sdk_client, self._security_group_rules[0]['id']
|
|
320
|
+
)
|
|
324
321
|
self.assertIsNone(result)
|
|
325
322
|
|
|
326
323
|
def test_security_group_rule_delete_multi(self, sgr_mock):
|
|
327
|
-
arglist = [
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
arglist.append(s['id'])
|
|
324
|
+
arglist = [
|
|
325
|
+
self._security_group_rules[0]['id'],
|
|
326
|
+
self._security_group_rules[1]['id'],
|
|
327
|
+
]
|
|
332
328
|
verifylist = [
|
|
333
329
|
('rule', arglist),
|
|
334
330
|
]
|
|
335
|
-
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
336
331
|
|
|
332
|
+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
337
333
|
result = self.cmd.take_action(parsed_args)
|
|
338
334
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
335
|
+
sgr_mock.assert_has_calls(
|
|
336
|
+
[
|
|
337
|
+
mock.call(
|
|
338
|
+
self.compute_sdk_client,
|
|
339
|
+
self._security_group_rules[0]['id'],
|
|
340
|
+
),
|
|
341
|
+
mock.call(
|
|
342
|
+
self.compute_sdk_client,
|
|
343
|
+
self._security_group_rules[1]['id'],
|
|
344
|
+
),
|
|
345
|
+
]
|
|
346
|
+
)
|
|
343
347
|
self.assertIsNone(result)
|
|
344
348
|
|
|
345
349
|
def test_security_group_rule_delete_multi_with_exception(self, sgr_mock):
|
|
@@ -348,12 +352,11 @@ class TestDeleteSecurityGroupRuleCompute(compute_fakes.TestComputev2):
|
|
|
348
352
|
'unexist_rule',
|
|
349
353
|
]
|
|
350
354
|
verifylist = [
|
|
351
|
-
('rule',
|
|
355
|
+
('rule', arglist),
|
|
352
356
|
]
|
|
353
357
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
354
358
|
|
|
355
|
-
|
|
356
|
-
sgr_mock.side_effect = find_mock_result
|
|
359
|
+
sgr_mock.side_effect = [None, exceptions.NotFound('foo')]
|
|
357
360
|
|
|
358
361
|
try:
|
|
359
362
|
self.cmd.take_action(parsed_args)
|
|
@@ -361,8 +364,15 @@ class TestDeleteSecurityGroupRuleCompute(compute_fakes.TestComputev2):
|
|
|
361
364
|
except exceptions.CommandError as e:
|
|
362
365
|
self.assertEqual('1 of 2 rules failed to delete.', str(e))
|
|
363
366
|
|
|
364
|
-
sgr_mock.
|
|
365
|
-
|
|
367
|
+
sgr_mock.assert_has_calls(
|
|
368
|
+
[
|
|
369
|
+
mock.call(
|
|
370
|
+
self.compute_sdk_client,
|
|
371
|
+
self._security_group_rules[0]['id'],
|
|
372
|
+
),
|
|
373
|
+
mock.call(self.compute_sdk_client, 'unexist_rule'),
|
|
374
|
+
]
|
|
375
|
+
)
|
|
366
376
|
|
|
367
377
|
|
|
368
378
|
class TestListSecurityGroupRuleCompute(compute_fakes.TestComputev2):
|
|
@@ -428,14 +438,14 @@ class TestListSecurityGroupRuleCompute(compute_fakes.TestComputev2):
|
|
|
428
438
|
expected_data_no_group.append(expected_rule_no_group)
|
|
429
439
|
|
|
430
440
|
def setUp(self):
|
|
431
|
-
super(
|
|
441
|
+
super().setUp()
|
|
432
442
|
|
|
433
443
|
self.app.client_manager.network_endpoint_enabled = False
|
|
434
444
|
|
|
435
|
-
|
|
445
|
+
compute_v2.find_security_group = mock.Mock(
|
|
436
446
|
return_value=self._security_group,
|
|
437
447
|
)
|
|
438
|
-
|
|
448
|
+
compute_v2.list_security_groups = mock.Mock(
|
|
439
449
|
return_value=[self._security_group],
|
|
440
450
|
)
|
|
441
451
|
|
|
@@ -446,8 +456,8 @@ class TestListSecurityGroupRuleCompute(compute_fakes.TestComputev2):
|
|
|
446
456
|
parsed_args = self.check_parser(self.cmd, [], [])
|
|
447
457
|
|
|
448
458
|
columns, data = self.cmd.take_action(parsed_args)
|
|
449
|
-
|
|
450
|
-
|
|
459
|
+
compute_v2.list_security_groups.assert_called_once_with(
|
|
460
|
+
self.compute_sdk_client, all_projects=False
|
|
451
461
|
)
|
|
452
462
|
self.assertEqual(self.expected_columns_no_group, columns)
|
|
453
463
|
self.assertEqual(self.expected_data_no_group, list(data))
|
|
@@ -462,8 +472,8 @@ class TestListSecurityGroupRuleCompute(compute_fakes.TestComputev2):
|
|
|
462
472
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
463
473
|
|
|
464
474
|
columns, data = self.cmd.take_action(parsed_args)
|
|
465
|
-
|
|
466
|
-
self._security_group['id']
|
|
475
|
+
compute_v2.find_security_group.assert_called_once_with(
|
|
476
|
+
self.compute_sdk_client, self._security_group['id']
|
|
467
477
|
)
|
|
468
478
|
self.assertEqual(self.expected_columns_with_group, columns)
|
|
469
479
|
self.assertEqual(self.expected_data_with_group, list(data))
|
|
@@ -478,8 +488,8 @@ class TestListSecurityGroupRuleCompute(compute_fakes.TestComputev2):
|
|
|
478
488
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
479
489
|
|
|
480
490
|
columns, data = self.cmd.take_action(parsed_args)
|
|
481
|
-
|
|
482
|
-
|
|
491
|
+
compute_v2.list_security_groups.assert_called_once_with(
|
|
492
|
+
self.compute_sdk_client, all_projects=True
|
|
483
493
|
)
|
|
484
494
|
self.assertEqual(self.expected_columns_no_group, columns)
|
|
485
495
|
self.assertEqual(self.expected_data_no_group, list(data))
|
|
@@ -494,8 +504,8 @@ class TestListSecurityGroupRuleCompute(compute_fakes.TestComputev2):
|
|
|
494
504
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
495
505
|
|
|
496
506
|
columns, data = self.cmd.take_action(parsed_args)
|
|
497
|
-
|
|
498
|
-
|
|
507
|
+
compute_v2.list_security_groups.assert_called_once_with(
|
|
508
|
+
self.compute_sdk_client, all_projects=False
|
|
499
509
|
)
|
|
500
510
|
self.assertEqual(self.expected_columns_no_group, columns)
|
|
501
511
|
self.assertEqual(self.expected_data_no_group, list(data))
|
|
@@ -510,14 +520,14 @@ class TestShowSecurityGroupRuleCompute(compute_fakes.TestComputev2):
|
|
|
510
520
|
)
|
|
511
521
|
|
|
512
522
|
def setUp(self):
|
|
513
|
-
super(
|
|
523
|
+
super().setUp()
|
|
514
524
|
|
|
515
525
|
self.app.client_manager.network_endpoint_enabled = False
|
|
516
526
|
|
|
517
527
|
# Build a security group fake customized for this test.
|
|
518
528
|
security_group_rules = [self._security_group_rule]
|
|
519
529
|
security_group = {'rules': security_group_rules}
|
|
520
|
-
|
|
530
|
+
compute_v2.list_security_groups = mock.Mock(
|
|
521
531
|
return_value=[security_group],
|
|
522
532
|
)
|
|
523
533
|
|
|
@@ -540,6 +550,8 @@ class TestShowSecurityGroupRuleCompute(compute_fakes.TestComputev2):
|
|
|
540
550
|
|
|
541
551
|
columns, data = self.cmd.take_action(parsed_args)
|
|
542
552
|
|
|
543
|
-
|
|
553
|
+
compute_v2.list_security_groups.assert_called_once_with(
|
|
554
|
+
self.compute_sdk_client
|
|
555
|
+
)
|
|
544
556
|
self.assertEqual(self.columns, columns)
|
|
545
557
|
self.assertEqual(self.data, data)
|