From f30b66245dee6cbfbf4cc63d8beeaf6420a75d0a Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Tue, 25 Jul 2017 17:48:10 -0400 Subject: [PATCH] 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 --- nova/scheduler/ironic_host_manager.py | 1 + nova/tests/unit/scheduler/ironic_fakes.py | 11 ++++++----- nova/tests/unit/scheduler/test_ironic_host_manager.py | 3 +++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/nova/scheduler/ironic_host_manager.py b/nova/scheduler/ironic_host_manager.py index 84ead7d7a311..4e2b9a3b5035 100644 --- a/nova/scheduler/ironic_host_manager.py +++ b/nova/scheduler/ironic_host_manager.py @@ -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 diff --git a/nova/tests/unit/scheduler/ironic_fakes.py b/nova/tests/unit/scheduler/ironic_fakes.py index b1e23427f744..9d3ea49857fd 100644 --- a/nova/tests/unit/scheduler/ironic_fakes.py +++ b/nova/tests/unit/scheduler/ironic_fakes.py @@ -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 = [ diff --git a/nova/tests/unit/scheduler/test_ironic_host_manager.py b/nova/tests/unit/scheduler/test_ironic_host_manager.py index 85873ca9bc51..85e22d138ee3 100644 --- a/nova/tests/unit/scheduler/test_ironic_host_manager.py +++ b/nova/tests/unit/scheduler/test_ironic_host_manager.py @@ -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