summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Alvares Gomes <lucasagomes@gmail.com>2014-03-31 17:18:41 +0100
committerLucas Alvares Gomes <lucasagomes@gmail.com>2014-03-31 18:05:19 +0100
commit8e809a68910d1a193e209f01c83e6537add3039d (patch)
tree33c06d9b88d22bf60dbd4d3afbacb6567488b3fd
parentfbc47c51fb20a52b40a21f4ce7237a31630650c1 (diff)
downloadironic-8e809a68910d1a193e209f01c83e6537add3039d.tar.gz
If no swap is specified default to 1MB
After a244d1bc7b the Nova Ironic Driver will add the pxe_swap_mb parameter using the value in the flavor (which defaults to 0 if not specified). In the Ironic code we had something like get('pxe_swap_mb', 1) to prevent the swap size for being 0, but that get() won't work anymore because the pxe_swap_mb is set. So this patch is taking another approach to force the the pxe_swap_mb parameter to be > 0. Related-Bug: #1297937 Change-Id: Ie124f58681fc184950918cde1bc8c565c1387fc8
-rw-r--r--ironic/drivers/modules/pxe.py10
-rw-r--r--ironic/tests/drivers/test_pxe.py7
2 files changed, 15 insertions, 2 deletions
diff --git a/ironic/drivers/modules/pxe.py b/ironic/drivers/modules/pxe.py
index 8a557e3d7..7561af0c7 100644
--- a/ironic/drivers/modules/pxe.py
+++ b/ironic/drivers/modules/pxe.py
@@ -110,8 +110,8 @@ def _parse_driver_info(node):
# Internal use only
d_info['deploy_key'] = info.get('pxe_deploy_key')
- #TODO(ghe): Should we get rid of swap partition?
- d_info['swap_mb'] = info.get('pxe_swap_mb', 1)
+ # TODO(ghe): Should we get rid of swap partition?
+ d_info['swap_mb'] = info.get('pxe_swap_mb', 0)
d_info['ephemeral_gb'] = info.get('pxe_ephemeral_gb', 0)
d_info['ephemeral_format'] = info.get('pxe_ephemeral_format')
@@ -125,6 +125,12 @@ def _parse_driver_info(node):
raise exception.InvalidParameterValue(err_msg_invalid %
{'param': param, 'reason': reason})
+ # NOTE(lucasagomes): For simpler code paths on the deployment side,
+ # we always create a swap partition. if the size is
+ # <= 0 we default to 1MB
+ if int(d_info['swap_mb']) <= 0:
+ d_info['swap_mb'] = 1
+
if d_info['ephemeral_gb'] and not d_info['ephemeral_format']:
msg = _("The deploy contains an ephemeral partition, but no "
"filesystem type was specified by the pxe_ephemeral_format "
diff --git a/ironic/tests/drivers/test_pxe.py b/ironic/tests/drivers/test_pxe.py
index 0ae6b98c7..86e7a24c8 100644
--- a/ironic/tests/drivers/test_pxe.py
+++ b/ironic/tests/drivers/test_pxe.py
@@ -174,6 +174,13 @@ class PXEValidateParametersTestCase(base.TestCase):
pxe._parse_driver_info,
node)
+ def test__parse_driver_info_swap_defaults_to_1mb(self):
+ info = dict(INFO_DICT)
+ info['pxe_swap_mb'] = 0
+ node = self._create_test_node(driver_info=info)
+ data = pxe._parse_driver_info(node)
+ self.assertEqual(1, data.get('swap_mb'))
+
def test__get_pxe_mac_path(self):
mac = '00:11:22:33:44:55:66'
self.assertEqual('/tftpboot/pxelinux.cfg/01-00-11-22-33-44-55-66',