Merge "Restore get_compute_limits backward compatibility"
This commit is contained in:
commit
98f0c67120
@ -335,13 +335,14 @@ class ComputeCloudMixin(_normalize.Normalizer):
|
||||
return list(self.compute.server_groups())
|
||||
|
||||
def get_compute_limits(self, name_or_id=None):
|
||||
""" Get compute limits for a project
|
||||
""" Get absolute compute limits for a project
|
||||
|
||||
:param name_or_id: (optional) project name or ID to get limits for
|
||||
if different from the current project
|
||||
:raises: OpenStackCloudException if it's not a valid project
|
||||
|
||||
:returns: :class:`~openstack.compute.v2.limits.Limits` object.
|
||||
:returns:
|
||||
:class:`~openstack.compute.v2.limits.Limits.AbsoluteLimits` object.
|
||||
"""
|
||||
params = {}
|
||||
project_id = None
|
||||
@ -352,7 +353,7 @@ class ComputeCloudMixin(_normalize.Normalizer):
|
||||
raise exc.OpenStackCloudException("project does not exist")
|
||||
project_id = proj.id
|
||||
params['tenant_id'] = project_id
|
||||
return self.compute.get_limits(**params)
|
||||
return self.compute.get_limits(**params).absolute
|
||||
|
||||
def get_keypair(self, name_or_id, filters=None):
|
||||
"""Get a keypair by name or ID.
|
||||
|
@ -18,43 +18,51 @@ class AbsoluteLimits(resource.Resource):
|
||||
_max_microversion = '2.57'
|
||||
|
||||
#: The number of key-value pairs that can be set as image metadata.
|
||||
image_meta = resource.Body("maxImageMeta")
|
||||
image_meta = resource.Body("maxImageMeta", aka="max_image_meta")
|
||||
#: The maximum number of personality contents that can be supplied.
|
||||
personality = resource.Body("maxPersonality", deprecated=True)
|
||||
#: The maximum size, in bytes, of a personality.
|
||||
personality_size = resource.Body("maxPersonalitySize", deprecated=True)
|
||||
#: The maximum amount of security group rules allowed.
|
||||
security_group_rules = resource.Body("maxSecurityGroupRules")
|
||||
security_group_rules = resource.Body(
|
||||
"maxSecurityGroupRules", aka="max_security_group_rules")
|
||||
#: The maximum amount of security groups allowed.
|
||||
security_groups = resource.Body("maxSecurityGroups")
|
||||
security_groups = resource.Body(
|
||||
"maxSecurityGroups", aka="max_security_groups")
|
||||
#: The amount of security groups currently in use.
|
||||
security_groups_used = resource.Body("totalSecurityGroupsUsed")
|
||||
security_groups_used = resource.Body(
|
||||
"totalSecurityGroupsUsed", aka="total_security_groups_used")
|
||||
#: The number of key-value pairs that can be set as server metadata.
|
||||
server_meta = resource.Body("maxServerMeta")
|
||||
server_meta = resource.Body("maxServerMeta", aka="max_server_meta")
|
||||
#: The maximum amount of cores.
|
||||
total_cores = resource.Body("maxTotalCores")
|
||||
total_cores = resource.Body("maxTotalCores", aka="max_total_cores")
|
||||
#: The amount of cores currently in use.
|
||||
total_cores_used = resource.Body("totalCoresUsed")
|
||||
total_cores_used = resource.Body("totalCoresUsed", aka="total_cores_used")
|
||||
#: The maximum amount of floating IPs.
|
||||
floating_ips = resource.Body("maxTotalFloatingIps")
|
||||
floating_ips = resource.Body(
|
||||
"maxTotalFloatingIps", aka="max_total_floating_ips")
|
||||
#: The amount of floating IPs currently in use.
|
||||
floating_ips_used = resource.Body("totalFloatingIpsUsed")
|
||||
floating_ips_used = resource.Body(
|
||||
"totalFloatingIpsUsed", aka="total_floating_ips_used")
|
||||
#: The maximum amount of instances.
|
||||
instances = resource.Body("maxTotalInstances")
|
||||
instances = resource.Body("maxTotalInstances", aka="max_total_instances")
|
||||
#: The amount of instances currently in use.
|
||||
instances_used = resource.Body("totalInstancesUsed")
|
||||
instances_used = resource.Body(
|
||||
"totalInstancesUsed", aka="total_instances_used")
|
||||
#: The maximum amount of keypairs.
|
||||
keypairs = resource.Body("maxTotalKeypairs")
|
||||
keypairs = resource.Body("maxTotalKeypairs", aka="max_total_keypairs")
|
||||
#: The maximum RAM size in megabytes.
|
||||
total_ram = resource.Body("maxTotalRAMSize")
|
||||
total_ram = resource.Body("maxTotalRAMSize", aka="max_total_ram_size")
|
||||
#: The RAM size in megabytes currently in use.
|
||||
total_ram_used = resource.Body("totalRAMUsed")
|
||||
total_ram_used = resource.Body("totalRAMUsed", aka="total_ram_used")
|
||||
#: The maximum amount of server groups.
|
||||
server_groups = resource.Body("maxServerGroups")
|
||||
server_groups = resource.Body("maxServerGroups", aka="max_server_groups")
|
||||
#: The amount of server groups currently in use.
|
||||
server_groups_used = resource.Body("totalServerGroupsUsed")
|
||||
server_groups_used = resource.Body(
|
||||
"totalServerGroupsUsed", aka="total_server_groups_used")
|
||||
#: The maximum number of members in a server group.
|
||||
server_group_members = resource.Body("maxServerGroupMembers")
|
||||
server_group_members = resource.Body(
|
||||
"maxServerGroupMembers", aka="max_server_group_members")
|
||||
|
||||
|
||||
class RateLimit(resource.Resource):
|
||||
|
@ -27,26 +27,26 @@ class TestUsage(base.BaseFunctionalTest):
|
||||
limits = self.user_cloud.get_compute_limits()
|
||||
self.assertIsNotNone(limits)
|
||||
|
||||
self.assertIsInstance(limits, _limits.Limits)
|
||||
self.assertIsNotNone(limits.absolute.server_meta)
|
||||
self.assertIsNotNone(limits.absolute.image_meta)
|
||||
self.assertIsInstance(limits, _limits.AbsoluteLimits)
|
||||
self.assertIsNotNone(limits.server_meta)
|
||||
self.assertIsNotNone(limits.image_meta)
|
||||
|
||||
def test_get_other_compute_limits(self):
|
||||
'''Test quotas functionality'''
|
||||
limits = self.operator_cloud.get_compute_limits('demo')
|
||||
self.assertIsNotNone(limits)
|
||||
self.assertTrue(hasattr(limits.absolute, 'server_meta'))
|
||||
self.assertTrue(hasattr(limits, 'server_meta'))
|
||||
|
||||
# Test normalize limits
|
||||
self.assertFalse(hasattr(limits.absolute, 'maxImageMeta'))
|
||||
self.assertFalse(hasattr(limits, 'maxImageMeta'))
|
||||
|
||||
def test_get_our_volume_limits(self):
|
||||
'''Test quotas functionality'''
|
||||
limits = self.user_cloud.get_volume_limits()
|
||||
self.assertIsNotNone(limits)
|
||||
self.assertFalse(hasattr(limits.absolute, 'maxTotalVolumes'))
|
||||
self.assertFalse(hasattr(limits, 'maxTotalVolumes'))
|
||||
|
||||
def test_get_other_volume_limits(self):
|
||||
'''Test quotas functionality'''
|
||||
limits = self.operator_cloud.get_volume_limits('demo')
|
||||
self.assertFalse(hasattr(limits.absolute, 'maxTotalVolumes'))
|
||||
self.assertFalse(hasattr(limits, 'maxTotalVolumes'))
|
||||
|
Loading…
Reference in New Issue
Block a user