diff --git a/ironic/drivers/modules/pxe.py b/ironic/drivers/modules/pxe.py index 401cf66392..0f174c1b18 100644 --- a/ironic/drivers/modules/pxe.py +++ b/ironic/drivers/modules/pxe.py @@ -113,6 +113,15 @@ def _parse_driver_info(node): #TODO(ghe): Should we get rid of swap partition? d_info['swap_mb'] = info.get('swap_mb', 1) d_info['key_data'] = info.get('key_data', None) + + for param in ('root_gb', 'swap_mb'): + try: + int(d_info[param]) + except ValueError: + raise exception.InvalidParameterValue(_( + "Can not validate PXE bootloader. Invalid " + "parameter %s") % param) + return d_info diff --git a/ironic/tests/drivers/test_pxe.py b/ironic/tests/drivers/test_pxe.py index e45599f842..43d03f6339 100644 --- a/ironic/tests/drivers/test_pxe.py +++ b/ironic/tests/drivers/test_pxe.py @@ -128,6 +128,15 @@ class PXEValidateParametersTestCase(base.TestCase): node) self.mox.VerifyAll() + def test__parse_driver_info_invalid_root_gb(self): + tmp_dict = dict(INFO_DICT) + tmp_dict['root_gb'] = 'foobar' + info = {'pxe': tmp_dict} + node = self._create_test_node(driver_info=info) + self.assertRaises(exception.InvalidParameterValue, + pxe._parse_driver_info, + node) + def test__get_pxe_mac_path(self): mac = '00:11:22:33:44:55:66' self.assertEqual(pxe._get_pxe_mac_path(mac),