Merge "Improve parameters validate in PXE driver"
This commit is contained in:
commit
884a5ececb
@ -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
|
||||
|
||||
|
||||
|
@ -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),
|
||||
|
Loading…
Reference in New Issue
Block a user