From bd582e7400216219ee724d467cfff6dd9b033028 Mon Sep 17 00:00:00 2001 From: Nisha Agarwal Date: Wed, 9 Sep 2015 03:11:06 -0700 Subject: [PATCH] Make proliantutils return 1 size less than actual disk size Return disk size 1 less than the actual disk size. This prevents the deploy to fail from Nova when root_gb is same as local_gb in Ironic. When the disk size is used as root_device hints, then it should be given as the actual size i.e. ironic (node.properties['local_gb'] + 1) else deploy via root device hint will fail. Closes bug: 1492921 Change-Id: Ifbad87c08307bc12118dd8b01ad0114cf9ff7583 --- proliantutils/ilo/ribcl.py | 9 +++++++++ proliantutils/tests/ilo/test_ribcl.py | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/proliantutils/ilo/ribcl.py b/proliantutils/ilo/ribcl.py index ff0dc58..0e919af 100644 --- a/proliantutils/ilo/ribcl.py +++ b/proliantutils/ilo/ribcl.py @@ -847,6 +847,15 @@ class RIBCLOperations(operations.IloOperations): local_gb = int(local_bytes / (1024 * 1024 * 1024)) if minimum >= local_gb or minimum == 0: minimum = local_gb + + # Return disk size 1 less than the actual disk size. This prevents + # the deploy to fail from Nova when root_gb is same as local_gb + # in Ironic. When the disk size is used as root_device hints, + # then it should be given as the actual size i.e. + # ironic (node.properties['local_gb'] + 1) else root device + # hint will fail. + if minimum: + minimum = minimum - 1 return minimum def get_value_as_list(self, dictionary, key): diff --git a/proliantutils/tests/ilo/test_ribcl.py b/proliantutils/tests/ilo/test_ribcl.py index 337424e..e1d5ae8 100644 --- a/proliantutils/tests/ilo/test_ribcl.py +++ b/proliantutils/tests/ilo/test_ribcl.py @@ -513,14 +513,14 @@ class IloRibclTestCase(unittest.TestCase): json_data = json.loads(data) local_gb = self.ilo._parse_storage_embedded_health(json_data) self.assertTrue(type(local_gb), int) - self.assertEqual("99", str(local_gb)) + self.assertEqual("98", str(local_gb)) def test__parse_storage_embedded_health_controller_list(self): data = constants.GET_EMBEDDED_HEALTH_OUTPUT_LIST_STORAGE json_data = json.loads(data) local_gb = self.ilo._parse_storage_embedded_health(json_data) self.assertTrue(type(local_gb), int) - self.assertEqual("99", str(local_gb)) + self.assertEqual("98", str(local_gb)) def test__parse_storage_embedded_health_no_logical_drive(self): data = constants.GET_EMBEDDED_HEALTH_OUTPUT_NO_LOGICAL_DRIVE @@ -579,7 +579,7 @@ class IloRibclTestCase(unittest.TestCase): 'properties': { 'memory_mb': 32768, 'cpu_arch': 'x86_64', - 'local_gb': 99, + 'local_gb': 98, 'cpus': 2} } properties = self.ilo.get_essential_properties()