Set IronicNodeState.uuid in _update_from_compute_node

The IronicNodeState extends the HostState class but failed
to set the uuid attribute, which is needed later when we
make allocation request claims to Placement in the FilterScheduler.

It seems like IronicNodeState._update_from_compute_node should
call super(IronicNodeState, self)._update_from_compute_node(compute)
so we don't need to worry about all of this duplication, but that
refactor is left for another change.

Part of blueprint placement-claims

Change-Id: I6210a7f0d5a0c71eb7cd9b9bd521b482d3aa9c66
This commit is contained in:
Matt Riedemann 2017-07-25 17:48:10 -04:00
parent a39a078bbc
commit f30b66245d
3 changed files with 10 additions and 5 deletions

View File

@ -58,6 +58,7 @@ class IronicNodeState(host_manager.HostState):
self.free_disk_mb = compute.free_disk_gb * 1024
self.stats = compute.stats or {}
self.uuid = compute.uuid
self.total_usable_disk_gb = compute.local_gb
self.hypervisor_type = compute.hypervisor_type

View File

@ -17,6 +17,7 @@ Fake nodes for Ironic host manager tests.
"""
from nova import objects
from nova.tests import uuidsentinel as uuids
COMPUTE_NODES = [
@ -34,7 +35,7 @@ COMPUTE_NODES = [
["i386", "baremetal", "baremetal"])],
free_disk_gb=10, free_ram_mb=1024,
cpu_allocation_ratio=16.0, ram_allocation_ratio=1.5,
disk_allocation_ratio=1.0),
disk_allocation_ratio=1.0, uuid=uuids.compute_node_1),
objects.ComputeNode(
id=2, local_gb=20, memory_mb=2048, vcpus=1,
vcpus_used=0, local_gb_used=0, memory_mb_used=0,
@ -49,7 +50,7 @@ COMPUTE_NODES = [
["i386", "baremetal", "baremetal"])],
free_disk_gb=20, free_ram_mb=2048,
cpu_allocation_ratio=16.0, ram_allocation_ratio=1.5,
disk_allocation_ratio=1.0),
disk_allocation_ratio=1.0, uuid=uuids.compute_node_2),
objects.ComputeNode(
id=3, local_gb=30, memory_mb=3072, vcpus=1,
vcpus_used=0, local_gb_used=0, memory_mb_used=0,
@ -64,7 +65,7 @@ COMPUTE_NODES = [
["i386", "baremetal", "baremetal"])],
free_disk_gb=30, free_ram_mb=3072,
cpu_allocation_ratio=16.0, ram_allocation_ratio=1.5,
disk_allocation_ratio=1.0),
disk_allocation_ratio=1.0, uuid=uuids.compute_node_3),
objects.ComputeNode(
id=4, local_gb=40, memory_mb=4096, vcpus=1,
vcpus_used=0, local_gb_used=0, memory_mb_used=0,
@ -79,7 +80,7 @@ COMPUTE_NODES = [
["i386", "baremetal", "baremetal"])],
free_disk_gb=40, free_ram_mb=4096,
cpu_allocation_ratio=16.0, ram_allocation_ratio=1.5,
disk_allocation_ratio=1.0),
disk_allocation_ratio=1.0, uuid=uuids.compute_node_4),
# Broken entry
objects.ComputeNode(
id=5, local_gb=50, memory_mb=5120, vcpus=1,
@ -90,7 +91,7 @@ COMPUTE_NODES = [
supported_hv_specs=[objects.HVSpec.from_list(
["i386", "baremetal", "baremetal"])],
free_disk_gb=50, free_ram_mb=5120,
hypervisor_hostname='fake-hyp'),
hypervisor_hostname='fake-hyp', uuid=uuids.compute_node_5),
]
SERVICES = [

View File

@ -277,6 +277,9 @@ class IronicHostManagerChangedNodesTestCase(test.NoDBTestCase):
self.assertEqual('ironic', host.hypervisor_type)
self.assertEqual(1, host.hypervisor_version)
self.assertEqual('fake_host', host.hypervisor_hostname)
# Make sure the uuid is set since that's needed for the allocation
# requests (claims to Placement) made in the FilterScheduler.
self.assertEqual(self.compute_node.uuid, host.uuid)
def test_update_from_compute_node_not_ready(self):
"""Tests that we ignore a compute node that does not have its