Merge "Use the device hints matching mechanism from ironic-lib"
This commit is contained in:
commit
7e349844c1
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from ironic_lib import utils as il_utils
|
||||||
import netaddr
|
import netaddr
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_utils import netutils
|
from oslo_utils import netutils
|
||||||
@ -47,41 +48,27 @@ class RootDiskSelectionHook(base.ProcessingHook):
|
|||||||
node_info=node_info, data=introspection_data)
|
node_info=node_info, data=introspection_data)
|
||||||
return
|
return
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
inventory = utils.get_inventory(introspection_data,
|
inventory = utils.get_inventory(introspection_data,
|
||||||
node_info=node_info)
|
node_info=node_info)
|
||||||
for disk in inventory['disks']:
|
try:
|
||||||
properties = disk.copy()
|
device = il_utils.match_root_device_hints(inventory['disks'],
|
||||||
# Root device hints are in GiB, data from IPA is in bytes
|
hints)
|
||||||
properties['size'] //= units.Gi
|
except (TypeError, ValueError) as e:
|
||||||
|
raise utils.Error(
|
||||||
|
_('No disks could be found using the root device hints '
|
||||||
|
'%(hints)s because they failed to validate. '
|
||||||
|
'Error: %(error)s') % {'hints': hints, 'error': e},
|
||||||
|
node_info=node_info, data=introspection_data)
|
||||||
|
|
||||||
for name, value in hints.items():
|
if not device:
|
||||||
actual = properties.get(name)
|
raise utils.Error(_('No disks satisfied root device hints'),
|
||||||
if actual != value:
|
|
||||||
LOG.debug('Disk %(disk)s does not satisfy hint '
|
|
||||||
'%(name)s=%(value)s, actual value is %(actual)s',
|
|
||||||
{'disk': disk.get('name'), 'name': name,
|
|
||||||
'value': value, 'actual': actual},
|
|
||||||
node_info=node_info, data=introspection_data)
|
node_info=node_info, data=introspection_data)
|
||||||
break
|
|
||||||
else:
|
|
||||||
LOG.debug('Disk %(disk)s of size %(size)s satisfies '
|
|
||||||
'root device hints',
|
|
||||||
{'disk': disk.get('name'), 'size': disk['size']},
|
|
||||||
node_info=node_info, data=introspection_data)
|
|
||||||
introspection_data['root_disk'] = disk
|
|
||||||
return
|
|
||||||
|
|
||||||
raise utils.Error(_('No disks satisfied root device hints'),
|
LOG.debug('Disk %(disk)s of size %(size)s satisfies '
|
||||||
node_info=node_info, data=introspection_data)
|
'root device hints',
|
||||||
|
{'disk': device.get('name'), 'size': device['size']},
|
||||||
|
node_info=node_info, data=introspection_data)
|
||||||
|
introspection_data['root_disk'] = device
|
||||||
|
|
||||||
|
|
||||||
class SchedulerHook(base.ProcessingHook):
|
class SchedulerHook(base.ProcessingHook):
|
||||||
|
@ -307,7 +307,7 @@ class TestRootDiskSelection(test_base.NodeTest):
|
|||||||
for bad_size in ('foo', None, {}):
|
for bad_size in ('foo', None, {}):
|
||||||
self.node.properties['root_device'] = {'size': bad_size}
|
self.node.properties['root_device'] = {'size': bad_size}
|
||||||
self.assertRaisesRegex(utils.Error,
|
self.assertRaisesRegex(utils.Error,
|
||||||
'Invalid root device size hint',
|
'No disks could be found',
|
||||||
self.hook.before_update,
|
self.hook.before_update,
|
||||||
self.data, self.node_info)
|
self.data, self.node_info)
|
||||||
|
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- Adds support for using operators with the root device hints mechanism.
|
||||||
|
The supported operators are ``=``, ``==``, ``!=``, ``>=``,
|
||||||
|
``<=``, ``>``, ``<``, ``s==``, ``s!=``, ``s>=``, ``s>``,
|
||||||
|
``s<=``, ``s<``, ``<in>``, ``<all-in>`` and ``<or>``.
|
@ -7,6 +7,7 @@ Babel>=2.3.4 # BSD
|
|||||||
eventlet!=0.18.3,>=0.18.2 # MIT
|
eventlet!=0.18.3,>=0.18.2 # MIT
|
||||||
Flask!=0.11,<1.0,>=0.10 # BSD
|
Flask!=0.11,<1.0,>=0.10 # BSD
|
||||||
futurist!=0.15.0,>=0.11.0 # Apache-2.0
|
futurist!=0.15.0,>=0.11.0 # Apache-2.0
|
||||||
|
ironic-lib>=2.2.0 # Apache-2.0
|
||||||
jsonpath-rw<2.0,>=1.2.0 # Apache-2.0
|
jsonpath-rw<2.0,>=1.2.0 # Apache-2.0
|
||||||
jsonschema!=2.5.0,<3.0.0,>=2.0.0 # MIT
|
jsonschema!=2.5.0,<3.0.0,>=2.0.0 # MIT
|
||||||
keystoneauth1>=2.16.0 # Apache-2.0
|
keystoneauth1>=2.16.0 # Apache-2.0
|
||||||
|
Loading…
Reference in New Issue
Block a user