Always convert the size root device hints to an integer
This matches the IPA behaviour and is more user-friendly. Change-Id: Ic7134c338e703361fedbf9917a3484c0bcc9d493 Closes-Bug: #1580664
This commit is contained in:
parent
1061b124cb
commit
8fe0344cfd
@ -53,6 +53,15 @@ class RootDiskSelectionHook(base.ProcessingHook):
|
|||||||
'as an inspection ramdisk'),
|
'as an inspection ramdisk'),
|
||||||
node_info=node_info, data=introspection_data)
|
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', [])
|
disks = inventory.get('disks', [])
|
||||||
if not disks:
|
if not disks:
|
||||||
raise utils.Error(_('No disks found'),
|
raise utils.Error(_('No disks found'),
|
||||||
|
@ -388,6 +388,19 @@ class TestRootDiskSelection(test_base.NodeTest):
|
|||||||
self.assertNotIn('local_gb', self.data)
|
self.assertNotIn('local_gb', self.data)
|
||||||
self.assertNotIn('root_disk', 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):
|
class TestRamdiskError(test_base.BaseTest):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
4
releasenotes/notes/size-hint-ea2a264468e1fcb7.yaml
Normal file
4
releasenotes/notes/size-hint-ea2a264468e1fcb7.yaml
Normal file
@ -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
Block a user