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
|
@@ -23,7 +23,7 @@ class ShowVersions(command.Lister):
|
|
|
23
23
|
_description = _("Show available versions of services")
|
|
24
24
|
|
|
25
25
|
def get_parser(self, prog_name):
|
|
26
|
-
parser = super(
|
|
26
|
+
parser = super().get_parser(prog_name)
|
|
27
27
|
interface_group = parser.add_mutually_exclusive_group()
|
|
28
28
|
interface_group.add_argument(
|
|
29
29
|
"--all-interfaces",
|
|
@@ -15,96 +15,28 @@
|
|
|
15
15
|
|
|
16
16
|
import logging
|
|
17
17
|
|
|
18
|
-
from osc_lib import exceptions
|
|
19
18
|
from osc_lib import utils
|
|
20
19
|
|
|
21
20
|
from openstackclient.i18n import _
|
|
22
21
|
|
|
23
|
-
|
|
24
22
|
LOG = logging.getLogger(__name__)
|
|
25
23
|
|
|
26
24
|
DEFAULT_API_VERSION = '2.1'
|
|
27
25
|
API_VERSION_OPTION = 'os_compute_api_version'
|
|
28
26
|
API_NAME = 'compute'
|
|
29
27
|
API_VERSIONS = {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
COMPUTE_API_TYPE = 'compute'
|
|
35
|
-
COMPUTE_API_VERSIONS = {
|
|
36
|
-
'2': 'openstackclient.api.compute_v2.APIv2',
|
|
28
|
+
'2': 'openstack.connection.Connection',
|
|
29
|
+
'2.1': 'openstack.connection.Connection',
|
|
37
30
|
}
|
|
38
31
|
|
|
39
|
-
# Save the microversion if in use
|
|
40
|
-
_compute_api_version = None
|
|
41
|
-
|
|
42
32
|
|
|
43
33
|
def make_client(instance):
|
|
44
34
|
"""Returns a compute service client."""
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if _compute_api_version is not None:
|
|
50
|
-
version = _compute_api_version
|
|
51
|
-
else:
|
|
52
|
-
version = instance._api_version[API_NAME]
|
|
53
|
-
from novaclient import api_versions
|
|
54
|
-
|
|
55
|
-
# convert to APIVersion object
|
|
56
|
-
version = api_versions.get_api_version(version)
|
|
57
|
-
|
|
58
|
-
if version.is_latest():
|
|
59
|
-
import novaclient
|
|
60
|
-
|
|
61
|
-
# NOTE(RuiChen): executing version discovery make sense, but that need
|
|
62
|
-
# an initialized REST client, it's not available now,
|
|
63
|
-
# fallback to use the max version of novaclient side.
|
|
64
|
-
version = novaclient.API_MAX_VERSION
|
|
65
|
-
|
|
66
|
-
LOG.debug('Instantiating compute client for %s', version)
|
|
67
|
-
|
|
68
|
-
compute_api = utils.get_client_class(
|
|
69
|
-
API_NAME,
|
|
70
|
-
version.ver_major,
|
|
71
|
-
COMPUTE_API_VERSIONS,
|
|
72
|
-
)
|
|
73
|
-
LOG.debug('Instantiating compute api: %s', compute_api)
|
|
74
|
-
|
|
75
|
-
# Set client http_log_debug to True if verbosity level is high enough
|
|
76
|
-
http_log_debug = utils.get_effective_log_level() <= logging.DEBUG
|
|
77
|
-
|
|
78
|
-
extensions = [
|
|
79
|
-
ext
|
|
80
|
-
for ext in nova_client.discover_extensions(version)
|
|
81
|
-
if ext.name == "list_extensions"
|
|
82
|
-
]
|
|
83
|
-
|
|
84
|
-
# Remember interface only if it is set
|
|
85
|
-
kwargs = utils.build_kwargs_dict('endpoint_type', instance.interface)
|
|
86
|
-
|
|
87
|
-
client = nova_client.Client(
|
|
88
|
-
version,
|
|
89
|
-
session=instance.session,
|
|
90
|
-
extensions=extensions,
|
|
91
|
-
http_log_debug=http_log_debug,
|
|
92
|
-
timings=instance.timing,
|
|
93
|
-
region_name=instance.region_name,
|
|
94
|
-
**kwargs
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
client.api = compute_api(
|
|
98
|
-
session=instance.session,
|
|
99
|
-
service_type=COMPUTE_API_TYPE,
|
|
100
|
-
endpoint=instance.get_endpoint_for_service_type(
|
|
101
|
-
COMPUTE_API_TYPE,
|
|
102
|
-
region_name=instance.region_name,
|
|
103
|
-
interface=instance.interface,
|
|
104
|
-
),
|
|
35
|
+
LOG.debug(
|
|
36
|
+
'Compute client initialized using OpenStack SDK: %s',
|
|
37
|
+
instance.sdk_connection.compute,
|
|
105
38
|
)
|
|
106
|
-
|
|
107
|
-
return client
|
|
39
|
+
return instance.sdk_connection.compute
|
|
108
40
|
|
|
109
41
|
|
|
110
42
|
def build_option_parser(parser):
|
|
@@ -113,48 +45,7 @@ def build_option_parser(parser):
|
|
|
113
45
|
'--os-compute-api-version',
|
|
114
46
|
metavar='<compute-api-version>',
|
|
115
47
|
default=utils.env('OS_COMPUTE_API_VERSION'),
|
|
116
|
-
help=_(
|
|
117
|
-
"Compute API version, default=%s " "(Env: OS_COMPUTE_API_VERSION)"
|
|
118
|
-
)
|
|
48
|
+
help=_("Compute API version, default=%s (Env: OS_COMPUTE_API_VERSION)")
|
|
119
49
|
% DEFAULT_API_VERSION,
|
|
120
50
|
)
|
|
121
51
|
return parser
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
def check_api_version(check_version):
|
|
125
|
-
"""Validate version supplied by user
|
|
126
|
-
|
|
127
|
-
Returns:
|
|
128
|
-
|
|
129
|
-
* True if version is OK
|
|
130
|
-
* False if the version has not been checked and the previous plugin
|
|
131
|
-
check should be performed
|
|
132
|
-
* throws an exception if the version is no good
|
|
133
|
-
|
|
134
|
-
TODO(dtroyer): make the exception thrown a version-related one
|
|
135
|
-
"""
|
|
136
|
-
|
|
137
|
-
# Defer client imports until we actually need them
|
|
138
|
-
import novaclient
|
|
139
|
-
from novaclient import api_versions
|
|
140
|
-
|
|
141
|
-
global _compute_api_version
|
|
142
|
-
|
|
143
|
-
# Copy some logic from novaclient 3.3.0 for basic version detection
|
|
144
|
-
# NOTE(dtroyer): This is only enough to resume operations using API
|
|
145
|
-
# version 2.0 or any valid version supplied by the user.
|
|
146
|
-
_compute_api_version = api_versions.get_api_version(check_version)
|
|
147
|
-
|
|
148
|
-
# Bypass X.latest format microversion
|
|
149
|
-
if not _compute_api_version.is_latest():
|
|
150
|
-
if _compute_api_version > api_versions.APIVersion("2.0"):
|
|
151
|
-
if not _compute_api_version.matches(
|
|
152
|
-
novaclient.API_MIN_VERSION,
|
|
153
|
-
novaclient.API_MAX_VERSION,
|
|
154
|
-
):
|
|
155
|
-
msg = _("versions supported by client: %(min)s - %(max)s") % {
|
|
156
|
-
"min": novaclient.API_MIN_VERSION.get_string(),
|
|
157
|
-
"max": novaclient.API_MAX_VERSION.get_string(),
|
|
158
|
-
}
|
|
159
|
-
raise exceptions.CommandError(msg)
|
|
160
|
-
return True
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
import logging
|
|
19
19
|
|
|
20
|
+
from openstack import exceptions as sdk_exceptions
|
|
20
21
|
from osc_lib.command import command
|
|
21
22
|
from osc_lib import exceptions
|
|
22
23
|
from osc_lib import utils
|
|
@@ -36,7 +37,7 @@ class CreateAgent(command.ShowOne):
|
|
|
36
37
|
"""
|
|
37
38
|
|
|
38
39
|
def get_parser(self, prog_name):
|
|
39
|
-
parser = super(
|
|
40
|
+
parser = super().get_parser(prog_name)
|
|
40
41
|
parser.add_argument("os", metavar="<os>", help=_("Type of OS"))
|
|
41
42
|
parser.add_argument(
|
|
42
43
|
"architecture",
|
|
@@ -55,16 +56,26 @@ class CreateAgent(command.ShowOne):
|
|
|
55
56
|
return parser
|
|
56
57
|
|
|
57
58
|
def take_action(self, parsed_args):
|
|
58
|
-
compute_client = self.app.client_manager.compute
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
compute_client = self.app.client_manager.sdk_connection.compute
|
|
60
|
+
|
|
61
|
+
# doing this since openstacksdk has decided not to support this
|
|
62
|
+
# deprecated command
|
|
63
|
+
data = {
|
|
64
|
+
'agent': {
|
|
65
|
+
'hypervisor': parsed_args.hypervisor,
|
|
66
|
+
'os': parsed_args.os,
|
|
67
|
+
'architecture': parsed_args.architecture,
|
|
68
|
+
'version': parsed_args.version,
|
|
69
|
+
'url': parsed_args.url,
|
|
70
|
+
'md5hash': parsed_args.md5hash,
|
|
71
|
+
},
|
|
72
|
+
}
|
|
73
|
+
response = compute_client.post(
|
|
74
|
+
'/os-agents', json=data, microversion='2.1'
|
|
66
75
|
)
|
|
67
|
-
|
|
76
|
+
sdk_exceptions.raise_from_response(response)
|
|
77
|
+
agent = response.json().get('agent')
|
|
78
|
+
|
|
68
79
|
return zip(*sorted(agent.items()))
|
|
69
80
|
|
|
70
81
|
|
|
@@ -77,18 +88,23 @@ class DeleteAgent(command.Command):
|
|
|
77
88
|
"""
|
|
78
89
|
|
|
79
90
|
def get_parser(self, prog_name):
|
|
80
|
-
parser = super(
|
|
91
|
+
parser = super().get_parser(prog_name)
|
|
81
92
|
parser.add_argument(
|
|
82
93
|
"id", metavar="<id>", nargs='+', help=_("ID of agent(s) to delete")
|
|
83
94
|
)
|
|
84
95
|
return parser
|
|
85
96
|
|
|
86
97
|
def take_action(self, parsed_args):
|
|
87
|
-
compute_client = self.app.client_manager.compute
|
|
98
|
+
compute_client = self.app.client_manager.sdk_connection.compute
|
|
88
99
|
result = 0
|
|
89
100
|
for id in parsed_args.id:
|
|
90
101
|
try:
|
|
91
|
-
|
|
102
|
+
# doing this since openstacksdk has decided not to support this
|
|
103
|
+
# deprecated command
|
|
104
|
+
response = compute_client.delete(
|
|
105
|
+
f'/os-agents/{id}', microversion='2.1'
|
|
106
|
+
)
|
|
107
|
+
sdk_exceptions.raise_from_response(response)
|
|
92
108
|
except Exception as e:
|
|
93
109
|
result += 1
|
|
94
110
|
LOG.error(
|
|
@@ -114,7 +130,7 @@ class ListAgent(command.Lister):
|
|
|
114
130
|
"""
|
|
115
131
|
|
|
116
132
|
def get_parser(self, prog_name):
|
|
117
|
-
parser = super(
|
|
133
|
+
parser = super().get_parser(prog_name)
|
|
118
134
|
parser.add_argument(
|
|
119
135
|
"--hypervisor",
|
|
120
136
|
metavar="<hypervisor>",
|
|
@@ -123,7 +139,7 @@ class ListAgent(command.Lister):
|
|
|
123
139
|
return parser
|
|
124
140
|
|
|
125
141
|
def take_action(self, parsed_args):
|
|
126
|
-
compute_client = self.app.client_manager.compute
|
|
142
|
+
compute_client = self.app.client_manager.sdk_connection.compute
|
|
127
143
|
columns = (
|
|
128
144
|
"Agent ID",
|
|
129
145
|
"Hypervisor",
|
|
@@ -133,30 +149,36 @@ class ListAgent(command.Lister):
|
|
|
133
149
|
"Md5Hash",
|
|
134
150
|
"URL",
|
|
135
151
|
)
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
152
|
+
|
|
153
|
+
# doing this since openstacksdk has decided not to support this
|
|
154
|
+
# deprecated command
|
|
155
|
+
path = '/os-agents'
|
|
156
|
+
if parsed_args.hypervisor:
|
|
157
|
+
path += f'?hypervisor={parsed_args.hypervisor}'
|
|
158
|
+
|
|
159
|
+
response = compute_client.get(path, microversion='2.1')
|
|
160
|
+
sdk_exceptions.raise_from_response(response)
|
|
161
|
+
agents = response.json().get('agents')
|
|
162
|
+
|
|
163
|
+
return columns, (utils.get_dict_properties(s, columns) for s in agents)
|
|
147
164
|
|
|
148
165
|
|
|
149
166
|
class SetAgent(command.Command):
|
|
150
167
|
"""Set compute agent properties.
|
|
151
168
|
|
|
152
|
-
The compute agent functionality is hypervisor
|
|
169
|
+
The compute agent functionality is hypervisor-specific and is only
|
|
153
170
|
supported by the XenAPI hypervisor driver. It was removed from nova in the
|
|
154
171
|
23.0.0 (Wallaby) release.
|
|
155
172
|
"""
|
|
156
173
|
|
|
157
174
|
def get_parser(self, prog_name):
|
|
158
|
-
parser = super(
|
|
159
|
-
parser.add_argument(
|
|
175
|
+
parser = super().get_parser(prog_name)
|
|
176
|
+
parser.add_argument(
|
|
177
|
+
"id",
|
|
178
|
+
metavar="<id>",
|
|
179
|
+
type=int,
|
|
180
|
+
help=_("ID of the agent"),
|
|
181
|
+
)
|
|
160
182
|
parser.add_argument(
|
|
161
183
|
"--agent-version",
|
|
162
184
|
dest="version",
|
|
@@ -172,30 +194,34 @@ class SetAgent(command.Command):
|
|
|
172
194
|
return parser
|
|
173
195
|
|
|
174
196
|
def take_action(self, parsed_args):
|
|
175
|
-
compute_client = self.app.client_manager.compute
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
197
|
+
compute_client = self.app.client_manager.sdk_connection.compute
|
|
198
|
+
|
|
199
|
+
response = compute_client.get('/os-agents', microversion='2.1')
|
|
200
|
+
sdk_exceptions.raise_from_response(response)
|
|
201
|
+
agents = response.json().get('agents')
|
|
202
|
+
data = {}
|
|
203
|
+
for agent in agents:
|
|
204
|
+
if agent['agent_id'] == parsed_args.id:
|
|
205
|
+
data['version'] = agent['version']
|
|
206
|
+
data['url'] = agent['url']
|
|
207
|
+
data['md5hash'] = agent['md5hash']
|
|
208
|
+
break
|
|
209
|
+
else:
|
|
185
210
|
msg = _("No agent with a ID of '%(id)s' exists.")
|
|
186
|
-
raise exceptions.CommandError(msg % parsed_args.id)
|
|
211
|
+
raise exceptions.CommandError(msg % {'id': parsed_args.id})
|
|
187
212
|
|
|
188
213
|
if parsed_args.version:
|
|
189
|
-
|
|
214
|
+
data['version'] = parsed_args.version
|
|
190
215
|
if parsed_args.url:
|
|
191
|
-
|
|
216
|
+
data['url'] = parsed_args.url
|
|
192
217
|
if parsed_args.md5hash:
|
|
193
|
-
|
|
218
|
+
data['md5hash'] = parsed_args.md5hash
|
|
219
|
+
|
|
220
|
+
data = {'para': data}
|
|
194
221
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
agent['md5hash'],
|
|
222
|
+
# doing this since openstacksdk has decided not to support this
|
|
223
|
+
# deprecated command
|
|
224
|
+
response = compute_client.put(
|
|
225
|
+
f'/os-agents/{parsed_args.id}', json=data, microversion='2.1'
|
|
200
226
|
)
|
|
201
|
-
|
|
227
|
+
sdk_exceptions.raise_from_response(response)
|
|
@@ -55,7 +55,7 @@ class AddAggregateHost(command.ShowOne):
|
|
|
55
55
|
_description = _("Add host to aggregate")
|
|
56
56
|
|
|
57
57
|
def get_parser(self, prog_name):
|
|
58
|
-
parser = super(
|
|
58
|
+
parser = super().get_parser(prog_name)
|
|
59
59
|
parser.add_argument(
|
|
60
60
|
'aggregate',
|
|
61
61
|
metavar='<aggregate>',
|
|
@@ -88,7 +88,7 @@ class CreateAggregate(command.ShowOne):
|
|
|
88
88
|
_description = _("Create a new aggregate")
|
|
89
89
|
|
|
90
90
|
def get_parser(self, prog_name):
|
|
91
|
-
parser = super(
|
|
91
|
+
parser = super().get_parser(prog_name)
|
|
92
92
|
parser.add_argument(
|
|
93
93
|
"name", metavar="<name>", help=_("New aggregate name")
|
|
94
94
|
)
|
|
@@ -136,7 +136,7 @@ class DeleteAggregate(command.Command):
|
|
|
136
136
|
_description = _("Delete existing aggregate(s)")
|
|
137
137
|
|
|
138
138
|
def get_parser(self, prog_name):
|
|
139
|
-
parser = super(
|
|
139
|
+
parser = super().get_parser(prog_name)
|
|
140
140
|
parser.add_argument(
|
|
141
141
|
'aggregate',
|
|
142
142
|
metavar='<aggregate>',
|
|
@@ -178,7 +178,7 @@ class ListAggregate(command.Lister):
|
|
|
178
178
|
_description = _("List all aggregates")
|
|
179
179
|
|
|
180
180
|
def get_parser(self, prog_name):
|
|
181
|
-
parser = super(
|
|
181
|
+
parser = super().get_parser(prog_name)
|
|
182
182
|
parser.add_argument(
|
|
183
183
|
'--long',
|
|
184
184
|
action='store_true',
|
|
@@ -232,7 +232,7 @@ class RemoveAggregateHost(command.ShowOne):
|
|
|
232
232
|
_description = _("Remove host from aggregate")
|
|
233
233
|
|
|
234
234
|
def get_parser(self, prog_name):
|
|
235
|
-
parser = super(
|
|
235
|
+
parser = super().get_parser(prog_name)
|
|
236
236
|
parser.add_argument(
|
|
237
237
|
'aggregate',
|
|
238
238
|
metavar='<aggregate>',
|
|
@@ -265,7 +265,7 @@ class SetAggregate(command.Command):
|
|
|
265
265
|
_description = _("Set aggregate properties")
|
|
266
266
|
|
|
267
267
|
def get_parser(self, prog_name):
|
|
268
|
-
parser = super(
|
|
268
|
+
parser = super().get_parser(prog_name)
|
|
269
269
|
parser.add_argument(
|
|
270
270
|
'aggregate',
|
|
271
271
|
metavar='<aggregate>',
|
|
@@ -337,7 +337,7 @@ class ShowAggregate(command.ShowOne):
|
|
|
337
337
|
_description = _("Display aggregate details")
|
|
338
338
|
|
|
339
339
|
def get_parser(self, prog_name):
|
|
340
|
-
parser = super(
|
|
340
|
+
parser = super().get_parser(prog_name)
|
|
341
341
|
parser.add_argument(
|
|
342
342
|
'aggregate',
|
|
343
343
|
metavar='<aggregate>',
|
|
@@ -366,7 +366,7 @@ class UnsetAggregate(command.Command):
|
|
|
366
366
|
_description = _("Unset aggregate properties")
|
|
367
367
|
|
|
368
368
|
def get_parser(self, prog_name):
|
|
369
|
-
parser = super(
|
|
369
|
+
parser = super().get_parser(prog_name)
|
|
370
370
|
parser.add_argument(
|
|
371
371
|
"aggregate",
|
|
372
372
|
metavar="<aggregate>",
|
|
@@ -403,7 +403,7 @@ class CacheImageForAggregate(command.Command):
|
|
|
403
403
|
# not be anything to return.
|
|
404
404
|
|
|
405
405
|
def get_parser(self, prog_name):
|
|
406
|
-
parser = super(
|
|
406
|
+
parser = super().get_parser(prog_name)
|
|
407
407
|
parser.add_argument(
|
|
408
408
|
'aggregate',
|
|
409
409
|
metavar='<aggregate>',
|
|
@@ -36,7 +36,7 @@ class ShowConsoleLog(command.Command):
|
|
|
36
36
|
_description = _("Show server's console output")
|
|
37
37
|
|
|
38
38
|
def get_parser(self, prog_name):
|
|
39
|
-
parser = super(
|
|
39
|
+
parser = super().get_parser(prog_name)
|
|
40
40
|
parser.add_argument(
|
|
41
41
|
'server',
|
|
42
42
|
metavar='<server>',
|
|
@@ -78,7 +78,7 @@ class ShowConsoleURL(command.ShowOne):
|
|
|
78
78
|
_description = _("Show server's remote console URL")
|
|
79
79
|
|
|
80
80
|
def get_parser(self, prog_name):
|
|
81
|
-
parser = super(
|
|
81
|
+
parser = super().get_parser(prog_name)
|
|
82
82
|
parser.add_argument(
|
|
83
83
|
'server',
|
|
84
84
|
metavar='<server>',
|
|
@@ -58,7 +58,7 @@ class CreateFlavor(command.ShowOne):
|
|
|
58
58
|
_description = _("Create new flavor")
|
|
59
59
|
|
|
60
60
|
def get_parser(self, prog_name):
|
|
61
|
-
parser = super(
|
|
61
|
+
parser = super().get_parser(prog_name)
|
|
62
62
|
parser.add_argument(
|
|
63
63
|
"name", metavar="<flavor-name>", help=_("New flavor name")
|
|
64
64
|
)
|
|
@@ -214,7 +214,7 @@ class DeleteFlavor(command.Command):
|
|
|
214
214
|
_description = _("Delete flavor(s)")
|
|
215
215
|
|
|
216
216
|
def get_parser(self, prog_name):
|
|
217
|
-
parser = super(
|
|
217
|
+
parser = super().get_parser(prog_name)
|
|
218
218
|
parser.add_argument(
|
|
219
219
|
"flavor",
|
|
220
220
|
metavar="<flavor>",
|
|
@@ -253,7 +253,7 @@ class ListFlavor(command.Lister):
|
|
|
253
253
|
_description = _("List flavors")
|
|
254
254
|
|
|
255
255
|
def get_parser(self, prog_name):
|
|
256
|
-
parser = super(
|
|
256
|
+
parser = super().get_parser(prog_name)
|
|
257
257
|
public_group = parser.add_mutually_exclusive_group()
|
|
258
258
|
public_group.add_argument(
|
|
259
259
|
"--public",
|
|
@@ -375,7 +375,7 @@ class SetFlavor(command.Command):
|
|
|
375
375
|
_description = _("Set flavor properties")
|
|
376
376
|
|
|
377
377
|
def get_parser(self, prog_name):
|
|
378
|
-
parser = super(
|
|
378
|
+
parser = super().get_parser(prog_name)
|
|
379
379
|
parser.add_argument(
|
|
380
380
|
"flavor",
|
|
381
381
|
metavar="<flavor>",
|
|
@@ -491,7 +491,7 @@ class ShowFlavor(command.ShowOne):
|
|
|
491
491
|
_description = _("Display flavor details")
|
|
492
492
|
|
|
493
493
|
def get_parser(self, prog_name):
|
|
494
|
-
parser = super(
|
|
494
|
+
parser = super().get_parser(prog_name)
|
|
495
495
|
parser.add_argument(
|
|
496
496
|
"flavor",
|
|
497
497
|
metavar="<flavor>",
|
|
@@ -540,7 +540,7 @@ class UnsetFlavor(command.Command):
|
|
|
540
540
|
_description = _("Unset flavor properties")
|
|
541
541
|
|
|
542
542
|
def get_parser(self, prog_name):
|
|
543
|
-
parser = super(
|
|
543
|
+
parser = super().get_parser(prog_name)
|
|
544
544
|
parser.add_argument(
|
|
545
545
|
"flavor",
|
|
546
546
|
metavar="<flavor>",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
"""Host action implementations"""
|
|
17
17
|
|
|
18
|
+
from openstack import exceptions as sdk_exceptions
|
|
18
19
|
from osc_lib.command import command
|
|
19
20
|
from osc_lib import utils
|
|
20
21
|
|
|
@@ -35,37 +36,29 @@ class ListHost(command.Lister):
|
|
|
35
36
|
|
|
36
37
|
def take_action(self, parsed_args):
|
|
37
38
|
compute_client = self.app.client_manager.sdk_connection.compute
|
|
38
|
-
columns = ("Host Name", "Service", "Zone")
|
|
39
39
|
|
|
40
40
|
self.log.warning(
|
|
41
|
-
"API has been deprecated
|
|
42
|
-
"
|
|
41
|
+
"API has been deprecated; "
|
|
42
|
+
"consider using 'hypervisor list' instead."
|
|
43
43
|
)
|
|
44
44
|
|
|
45
45
|
# doing this since openstacksdk has decided not to support this
|
|
46
46
|
# deprecated command
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
.get('hosts')
|
|
51
|
-
)
|
|
52
|
-
|
|
47
|
+
response = compute_client.get('/os-hosts', microversion='2.1')
|
|
48
|
+
sdk_exceptions.raise_from_response(response)
|
|
49
|
+
hosts = response.json().get('hosts')
|
|
53
50
|
if parsed_args.zone is not None:
|
|
54
|
-
|
|
55
|
-
for host in hosts:
|
|
56
|
-
if host['zone'] == parsed_args.zone:
|
|
57
|
-
filtered_hosts.append(host)
|
|
58
|
-
|
|
59
|
-
hosts = filtered_hosts
|
|
51
|
+
hosts = [h for h in hosts if h['zone'] == parsed_args.zone]
|
|
60
52
|
|
|
53
|
+
columns = ("Host Name", "Service", "Zone")
|
|
61
54
|
return columns, (utils.get_dict_properties(s, columns) for s in hosts)
|
|
62
55
|
|
|
63
56
|
|
|
64
57
|
class SetHost(command.Command):
|
|
65
|
-
_description = _("Set host properties")
|
|
58
|
+
_description = _("DEPRECATED: Set host properties")
|
|
66
59
|
|
|
67
60
|
def get_parser(self, prog_name):
|
|
68
|
-
parser = super(
|
|
61
|
+
parser = super().get_parser(prog_name)
|
|
69
62
|
parser.add_argument(
|
|
70
63
|
"host", metavar="<host>", help=_("Host to modify (name only)")
|
|
71
64
|
)
|
|
@@ -90,20 +83,33 @@ class SetHost(command.Command):
|
|
|
90
83
|
return parser
|
|
91
84
|
|
|
92
85
|
def take_action(self, parsed_args):
|
|
93
|
-
|
|
86
|
+
compute_client = self.app.client_manager.sdk_connection.compute
|
|
87
|
+
|
|
88
|
+
self.log.warning(
|
|
89
|
+
"API has been deprecated; "
|
|
90
|
+
"consider using 'compute service set' instead."
|
|
91
|
+
)
|
|
94
92
|
|
|
93
|
+
data = {}
|
|
95
94
|
if parsed_args.enable:
|
|
96
|
-
|
|
95
|
+
data['status'] = 'enable'
|
|
97
96
|
if parsed_args.disable:
|
|
98
|
-
|
|
97
|
+
data['status'] = 'disable'
|
|
99
98
|
if parsed_args.enable_maintenance:
|
|
100
|
-
|
|
99
|
+
data['maintenance_mode'] = 'enable'
|
|
101
100
|
if parsed_args.disable_maintenance:
|
|
102
|
-
|
|
101
|
+
data['maintenance_mode'] = 'disable'
|
|
103
102
|
|
|
104
|
-
|
|
103
|
+
if not data:
|
|
104
|
+
# don't bother calling if nothing given
|
|
105
|
+
return
|
|
105
106
|
|
|
106
|
-
|
|
107
|
+
# doing this since openstacksdk has decided not to support this
|
|
108
|
+
# deprecated command
|
|
109
|
+
response = compute_client.put(
|
|
110
|
+
f'/os-hosts/{parsed_args.host}', json=data, microversion='2.1'
|
|
111
|
+
)
|
|
112
|
+
sdk_exceptions.raise_from_response(response)
|
|
107
113
|
|
|
108
114
|
|
|
109
115
|
class ShowHost(command.Lister):
|
|
@@ -116,26 +122,25 @@ class ShowHost(command.Lister):
|
|
|
116
122
|
|
|
117
123
|
def take_action(self, parsed_args):
|
|
118
124
|
compute_client = self.app.client_manager.sdk_connection.compute
|
|
119
|
-
columns = ("Host", "Project", "CPU", "Memory MB", "Disk GB")
|
|
120
125
|
|
|
121
126
|
self.log.warning(
|
|
122
|
-
"API has been deprecated
|
|
123
|
-
"
|
|
127
|
+
"API has been deprecated; "
|
|
128
|
+
"consider using 'hypervisor show' instead."
|
|
124
129
|
)
|
|
125
130
|
|
|
126
131
|
# doing this since openstacksdk has decided not to support this
|
|
127
132
|
# deprecated command
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
'/os-hosts/' + parsed_args.host, microversion='2.1'
|
|
131
|
-
)
|
|
132
|
-
.json()
|
|
133
|
-
.get('host')
|
|
133
|
+
response = compute_client.get(
|
|
134
|
+
f'/os-hosts/{parsed_args.host}', microversion='2.1'
|
|
134
135
|
)
|
|
136
|
+
sdk_exceptions.raise_from_response(response)
|
|
137
|
+
resources = response.json().get('host')
|
|
135
138
|
|
|
136
139
|
data = []
|
|
137
140
|
if resources is not None:
|
|
138
141
|
for resource in resources:
|
|
139
142
|
data.append(resource['resource'])
|
|
140
143
|
|
|
144
|
+
columns = ("Host", "Project", "CPU", "Memory MB", "Disk GB")
|
|
145
|
+
|
|
141
146
|
return columns, (utils.get_dict_properties(s, columns) for s in data)
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import json
|
|
19
19
|
import re
|
|
20
20
|
|
|
21
|
-
from
|
|
21
|
+
from openstack import exceptions as sdk_exceptions
|
|
22
22
|
from openstack import utils as sdk_utils
|
|
23
23
|
from osc_lib.cli import format_columns
|
|
24
24
|
from osc_lib.command import command
|
|
@@ -223,8 +223,9 @@ class ShowHypervisor(command.ShowOne):
|
|
|
223
223
|
hypervisor['uptime'] = m.group(2)
|
|
224
224
|
hypervisor['users'] = m.group(3)
|
|
225
225
|
hypervisor['load_average'] = m.group(4)
|
|
226
|
-
except
|
|
227
|
-
|
|
226
|
+
except sdk_exceptions.HttpException as exc:
|
|
227
|
+
if exc.status_code != 501:
|
|
228
|
+
raise
|
|
228
229
|
|
|
229
230
|
hypervisor['service_id'] = service_details['id']
|
|
230
231
|
hypervisor['service_host'] = service_details['host']
|