trivial: Remove unused '_instance_to_allocations_dict' function
This appears to have been unused since commit 73d7ef428
. Remove both the
function and its tests.
Change-Id: I680f0bab766693b8cc6f0f912f0b7987a9debec9
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
parent
d780216c6a
commit
c686544e28
|
@ -35,7 +35,6 @@ import nova.conf
|
|||
from nova import exception
|
||||
from nova.i18n import _
|
||||
from nova import objects
|
||||
from nova.scheduler import utils as scheduler_utils
|
||||
from nova import utils
|
||||
|
||||
|
||||
|
@ -123,19 +122,6 @@ def retries(f):
|
|||
return wrapper
|
||||
|
||||
|
||||
def _instance_to_allocations_dict(instance):
|
||||
"""Given an `objects.Instance` object, return a dict, keyed by resource
|
||||
class of the amount used by the instance.
|
||||
|
||||
:param instance: `objects.Instance` object to translate
|
||||
"""
|
||||
alloc_dict = scheduler_utils.resources_from_flavor(instance,
|
||||
instance.flavor)
|
||||
|
||||
# Remove any zero allocations.
|
||||
return {key: val for key, val in alloc_dict.items() if val}
|
||||
|
||||
|
||||
def _move_operation_alloc_request(source_allocs, dest_alloc_req):
|
||||
"""Given existing allocations for a source host and a new allocation
|
||||
request for a destination host, return a new allocation_request that
|
||||
|
|
|
@ -3124,95 +3124,6 @@ class TestAssociations(SchedulerReportClientTestCase):
|
|||
|
||||
class TestAllocations(SchedulerReportClientTestCase):
|
||||
|
||||
@mock.patch('nova.compute.utils.is_volume_backed_instance')
|
||||
def test_instance_to_allocations_dict(self, mock_vbi):
|
||||
mock_vbi.return_value = False
|
||||
inst = objects.Instance(
|
||||
uuid=uuids.inst,
|
||||
flavor=objects.Flavor(root_gb=10,
|
||||
swap=1023,
|
||||
ephemeral_gb=100,
|
||||
memory_mb=1024,
|
||||
vcpus=2,
|
||||
extra_specs={}))
|
||||
result = report._instance_to_allocations_dict(inst)
|
||||
expected = {
|
||||
'MEMORY_MB': 1024,
|
||||
'VCPU': 2,
|
||||
'DISK_GB': 111,
|
||||
}
|
||||
self.assertEqual(expected, result)
|
||||
|
||||
@mock.patch('nova.compute.utils.is_volume_backed_instance')
|
||||
def test_instance_to_allocations_dict_overrides(self, mock_vbi):
|
||||
"""Test that resource overrides in an instance's flavor extra_specs
|
||||
are reported to placement.
|
||||
"""
|
||||
|
||||
mock_vbi.return_value = False
|
||||
specs = {
|
||||
'resources:CUSTOM_DAN': '123',
|
||||
'resources:%s' % orc.VCPU: '4',
|
||||
'resources:NOTATHING': '456',
|
||||
'resources:NOTEVENANUMBER': 'catfood',
|
||||
'resources:': '7',
|
||||
'resources:ferret:weasel': 'smelly',
|
||||
'foo': 'bar',
|
||||
}
|
||||
inst = objects.Instance(
|
||||
uuid=uuids.inst,
|
||||
flavor=objects.Flavor(root_gb=10,
|
||||
swap=1023,
|
||||
ephemeral_gb=100,
|
||||
memory_mb=1024,
|
||||
vcpus=2,
|
||||
extra_specs=specs))
|
||||
result = report._instance_to_allocations_dict(inst)
|
||||
expected = {
|
||||
'MEMORY_MB': 1024,
|
||||
'VCPU': 4,
|
||||
'DISK_GB': 111,
|
||||
'CUSTOM_DAN': 123,
|
||||
}
|
||||
self.assertEqual(expected, result)
|
||||
|
||||
@mock.patch('nova.compute.utils.is_volume_backed_instance')
|
||||
def test_instance_to_allocations_dict_boot_from_volume(self, mock_vbi):
|
||||
mock_vbi.return_value = True
|
||||
inst = objects.Instance(
|
||||
uuid=uuids.inst,
|
||||
flavor=objects.Flavor(root_gb=10,
|
||||
swap=1,
|
||||
ephemeral_gb=100,
|
||||
memory_mb=1024,
|
||||
vcpus=2,
|
||||
extra_specs={}))
|
||||
result = report._instance_to_allocations_dict(inst)
|
||||
expected = {
|
||||
'MEMORY_MB': 1024,
|
||||
'VCPU': 2,
|
||||
'DISK_GB': 101,
|
||||
}
|
||||
self.assertEqual(expected, result)
|
||||
|
||||
@mock.patch('nova.compute.utils.is_volume_backed_instance')
|
||||
def test_instance_to_allocations_dict_zero_disk(self, mock_vbi):
|
||||
mock_vbi.return_value = True
|
||||
inst = objects.Instance(
|
||||
uuid=uuids.inst,
|
||||
flavor=objects.Flavor(root_gb=10,
|
||||
swap=0,
|
||||
ephemeral_gb=0,
|
||||
memory_mb=1024,
|
||||
vcpus=2,
|
||||
extra_specs={}))
|
||||
result = report._instance_to_allocations_dict(inst)
|
||||
expected = {
|
||||
'MEMORY_MB': 1024,
|
||||
'VCPU': 2,
|
||||
}
|
||||
self.assertEqual(expected, result)
|
||||
|
||||
@mock.patch("nova.scheduler.client.report.SchedulerReportClient."
|
||||
"delete")
|
||||
@mock.patch("nova.scheduler.client.report.SchedulerReportClient."
|
||||
|
|
Loading…
Reference in New Issue