Merge "Always convert the size root device hints to an integer" into stable/mitaka
This commit is contained in:
commit
69e7f4e278
|
@ -56,6 +56,15 @@ class RootDiskSelectionHook(base.ProcessingHook):
|
|||
'as an inspection ramdisk'),
|
||||
node_info=node_info, data=introspection_data)
|
||||
|
||||
if 'size' in hints:
|
||||
# Special case to match IPA behaviour
|
||||
try:
|
||||
hints['size'] = int(hints['size'])
|
||||
except (TypeError, ValueError):
|
||||
raise utils.Error(_('Invalid root device size hint, expected '
|
||||
'an integer, got %s') % hints['size'],
|
||||
node_info=node_info, data=introspection_data)
|
||||
|
||||
disks = inventory.get('disks', [])
|
||||
if not disks:
|
||||
raise utils.Error(_('No disks found'),
|
||||
|
|
|
@ -393,6 +393,19 @@ class TestRootDiskSelection(test_base.NodeTest):
|
|||
self.assertNotIn('local_gb', self.data)
|
||||
self.assertNotIn('root_disk', self.data)
|
||||
|
||||
def test_size_string(self):
|
||||
self.node.properties['root_device'] = {'size': '10'}
|
||||
self.hook.before_update(self.data, self.node_info)
|
||||
self.assertEqual(self.matched, self.data['root_disk'])
|
||||
|
||||
def test_size_invalid(self):
|
||||
for bad_size in ('foo', None, {}):
|
||||
self.node.properties['root_device'] = {'size': bad_size}
|
||||
self.assertRaisesRegexp(utils.Error,
|
||||
'Invalid root device size hint',
|
||||
self.hook.before_update,
|
||||
self.data, self.node_info)
|
||||
|
||||
|
||||
class TestRamdiskError(test_base.BaseTest):
|
||||
def setUp(self):
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
fixes:
|
||||
- The "size" root device hint is now always converted to an integer for
|
||||
consistency with IPA.
|
Loading…
Reference in New Issue