Skip to content
This repository has been archived by the owner on Sep 12, 2022. It is now read-only.

Commit

Permalink
Remove last occurrence of test_capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
cdosborn committed Oct 1, 2018
1 parent 6587c55 commit 688cf6e
Showing 1 changed file with 3 additions and 44 deletions.
47 changes: 3 additions & 44 deletions service/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
from service.networking import get_topology_cls
from service.exceptions import (
OverAllocationError, AllocationBlacklistedError, OverQuotaError,
SizeNotAvailable, HypervisorCapacityError, SecurityGroupNotCreated,
VolumeAttachConflict, VolumeDetachConflict, UnderThresholdError,
ActionNotAllowed, InstanceDoesNotExist, InstanceLaunchConflict, Unauthorized
SizeNotAvailable, SecurityGroupNotCreated, VolumeAttachConflict,
VolumeDetachConflict, UnderThresholdError, ActionNotAllowed,
InstanceDoesNotExist, InstanceLaunchConflict, Unauthorized
)

from service.accounts.openstack_manager import AccountDriver as OSAccountDriver
Expand Down Expand Up @@ -451,47 +451,6 @@ def restore_ip_chain(
return init_task


def test_capacity(hypervisor_hostname, instance, hypervisor_stats):
"""
Test that the hypervisor has the capacity to bring an inactive instance
back online on the compute node
"""
# CPU tests first (Most likely bottleneck)
cpu_total = hypervisor_stats['vcpus']
cpu_used = hypervisor_stats['vcpus_used']
cpu_needed = instance.size.cpu
log_str = "Resource:%s Used:%s Additional:%s Total:%s"\
% ("cpu", cpu_used, cpu_needed, cpu_total)
logger.debug(log_str)
if cpu_used + cpu_needed > cpu_total:
raise HypervisorCapacityError(
hypervisor_hostname, "Hypervisor is over-capacity. %s" % log_str
)

# ALL MEMORY VALUES IN MB
mem_total = hypervisor_stats['memory_mb']
mem_used = hypervisor_stats['memory_mb_used']
mem_needed = instance.size.ram
log_str = "Resource:%s Used:%s Additional:%s Total:%s"\
% ("mem", mem_used, mem_needed, mem_total)
logger.debug(log_str)
if mem_used + mem_needed > mem_total:
raise HypervisorCapacityError(
hypervisor_hostname, "Hypervisor is over-capacity. %s" % log_str
)

# ALL DISK VALUES IN GB
disk_total = hypervisor_stats['local_gb']
disk_used = hypervisor_stats['local_gb_used']
disk_needed = instance.size.disk + instance.size.ephemeral
log_str = "Resource:%s Used:%s Additional:%s Total:%s"\
% ("disk", disk_used, disk_needed, disk_total)
if disk_used + disk_needed > disk_total:
raise HypervisorCapacityError(
hypervisor_hostname, "Hypervisor is over-capacity. %s" % log_str
)


def resume_instance(
esh_driver,
esh_instance,
Expand Down

0 comments on commit 688cf6e

Please sign in to comment.