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
This commit is contained in:
Lucas Alvares Gomes 2014-03-31 17:18:41 +01:00
parent fbc47c51fb
commit 8e809a6891
2 changed files with 15 additions and 2 deletions

View File

@ -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 "

View File

@ -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',