From a148b11410d29845387e8abc819deae9f2dabc66 Mon Sep 17 00:00:00 2001 From: Eric Fried Date: Wed, 31 Oct 2018 16:48:42 -0500 Subject: [PATCH] PowerVM upt parity for reshaper, DISK_GB reserved The PowerVM patch to implement the update_provider_tree method (in a fashion backward compatible with the existing get_available_resource method) [1] was in flight at the same time as a bp reshape-provider-tree patch introducing the 'allocations' kwarg [2] and another patch which provided a ComputeDriver helper method for calculating the reserved value for the DISK_GB resource from config [3]. This brings PowerVM's update_provider_tree method up to scratch with those changes. [1] I96da858e6a63e3339a009fd17ee0d8939b364510 [2] Ic062446e5c620c89aec3065b34bcdc6bf5966275 [3] I72c83a95dabd581998470edb9543079acb6536a5 Change-Id: I89ad36f19672368a1f795e1f29c5af6368ccfeec --- nova/tests/unit/virt/powervm/test_driver.py | 9 +++++++-- nova/virt/powervm/driver.py | 7 +++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/nova/tests/unit/virt/powervm/test_driver.py b/nova/tests/unit/virt/powervm/test_driver.py index 21bbac43144e..9f3cd9d8c736 100644 --- a/nova/tests/unit/virt/powervm/test_driver.py +++ b/nova/tests/unit/virt/powervm/test_driver.py @@ -146,7 +146,7 @@ class TestPowerVMDriver(test.NoDBTestCase): self.assertEqual('sys', self.drv.host_wrapper) @contextlib.contextmanager - def _update_provider_tree(self): + def _update_provider_tree(self, allocations=None): """Host resource dict gets converted properly to provider tree inv.""" with mock.patch('nova.virt.powervm.host.' @@ -182,7 +182,8 @@ class TestPowerVMDriver(test.NoDBTestCase): ptree.new_root('compute_host', uuids.cn) # Let the caller muck with these yield ptree, exp_inv - self.drv.update_provider_tree(ptree, 'compute_host') + self.drv.update_provider_tree(ptree, 'compute_host', + allocations=allocations) self.assertEqual(exp_inv, ptree.data('compute_host').inventory) mock_bhrfm.assert_called_once_with('host_wrapper') @@ -192,6 +193,10 @@ class TestPowerVMDriver(test.NoDBTestCase): with self._update_provider_tree(): pass + def test_update_provider_tree_ignore_allocations(self): + with self._update_provider_tree(allocations="This is ignored"): + pass + def test_update_provider_tree_conf_overrides(self): # Non-default CONF values for allocation ratios and reserved. self.flags(cpu_allocation_ratio=12.3, diff --git a/nova/virt/powervm/driver.py b/nova/virt/powervm/driver.py index 8ab8f5183aad..a153257ee721 100644 --- a/nova/virt/powervm/driver.py +++ b/nova/virt/powervm/driver.py @@ -29,7 +29,6 @@ import six from taskflow.patterns import linear_flow as tf_lf from nova.compute import task_states -from nova.compute import utils as compute_utils from nova import conf as cfg from nova.console import type as console_type from nova import exception as exc @@ -170,7 +169,7 @@ class PowerVMDriver(driver.ComputeDriver): return data - def update_provider_tree(self, provider_tree, nodename): + def update_provider_tree(self, provider_tree, nodename, allocations=None): """Update a ProviderTree with current provider and inventory data. :param nova.compute.provider_tree.ProviderTree provider_tree: @@ -184,6 +183,7 @@ class PowerVMDriver(driver.ComputeDriver): String name of the compute node (i.e. ComputeNode.hypervisor_hostname) for which the caller is requesting updated provider information. + :param allocations: Currently ignored by this driver. """ # Get (legacy) resource information. Same as get_available_resource, # but we don't need to refresh self.host_wrapper as it was *just* @@ -200,8 +200,7 @@ class PowerVMDriver(driver.ComputeDriver): mem_alloc_ratio = CONF.ram_allocation_ratio or 1.5 mem_reserved = CONF.reserved_host_memory_mb disk_alloc_ratio = CONF.disk_allocation_ratio or 1.0 - disk_reserved = compute_utils.convert_mb_to_ceil_gb( - CONF.reserved_host_disk_mb) + disk_reserved = self._get_reserved_host_disk_gb_from_config() inventory = { rc_fields.ResourceClass.VCPU: {