Extend root device hints to support "rotational"
This patch is extending the root device hints to also consider if a disk is a rotational device or not. This hint makes it easier to separate SSDs and HDDs when selecting the device to deploy the image onto. Partial-Bug: #1599517 Change-Id: I270fe57df825929bdef7911b3a6757cf7163a5f1
This commit is contained in:
parent
185780822f
commit
080e413b9c
ironic_python_agent
releasenotes/notes
@ -19,10 +19,12 @@ import os
|
||||
import shlex
|
||||
import time
|
||||
|
||||
|
||||
import netifaces
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
from oslo_utils import strutils
|
||||
from oslo_utils import units
|
||||
import pint
|
||||
import psutil
|
||||
@ -604,6 +606,10 @@ class GenericHardwareManager(HardwareManager):
|
||||
|
||||
def match(hint, current_value, device):
|
||||
hint_value = root_device_hints[hint]
|
||||
|
||||
if hint == 'rotational':
|
||||
hint_value = strutils.bool_from_string(hint_value)
|
||||
|
||||
if hint_value != current_value:
|
||||
LOG.debug("Root device hint %(hint)s=%(value)s does not "
|
||||
"match the device %(device)s value of "
|
||||
@ -617,14 +623,17 @@ class GenericHardwareManager(HardwareManager):
|
||||
def check_device_attrs(device):
|
||||
for key in ('model', 'wwn', 'serial', 'vendor',
|
||||
'wwn_with_extension', 'wwn_vendor_extension',
|
||||
'name'):
|
||||
'name', 'rotational'):
|
||||
if key not in root_device_hints:
|
||||
continue
|
||||
|
||||
value = getattr(device, key)
|
||||
if not value:
|
||||
if value is None:
|
||||
return False
|
||||
value = utils.normalize(value)
|
||||
|
||||
if isinstance(value, six.string_types):
|
||||
value = utils.normalize(value)
|
||||
|
||||
if not match(key, value, device.name):
|
||||
return False
|
||||
|
||||
|
@ -448,7 +448,7 @@ class TestGenericHardwareManager(test_base.BaseTestCase):
|
||||
hardware.BlockDevice(name='/dev/sdb',
|
||||
model=model,
|
||||
size=10737418240,
|
||||
rotational=False,
|
||||
rotational=True,
|
||||
vendor='fake-vendor',
|
||||
wwn='fake-wwn',
|
||||
wwn_with_extension='fake-wwnven0',
|
||||
@ -485,6 +485,11 @@ class TestGenericHardwareManager(test_base.BaseTestCase):
|
||||
self._get_os_install_device_root_device_hints(
|
||||
{'name': '/dev/sdb'}, '/dev/sdb')
|
||||
|
||||
def test_get_os_install_device_root_device_hints_rotational(self):
|
||||
for value in (True, 'true', 'on', 'y', 'yes'):
|
||||
self._get_os_install_device_root_device_hints(
|
||||
{'rotational': value}, '/dev/sdb')
|
||||
|
||||
@mock.patch.object(hardware, 'list_all_block_devices')
|
||||
@mock.patch.object(hardware, 'get_cached_node')
|
||||
def test_get_os_install_device_root_device_hints_no_device_found(
|
||||
|
@ -0,0 +1,4 @@
|
||||
---
|
||||
features:
|
||||
- Extend the root device hints to identify whether a disk is rotational
|
||||
or not.
|
Loading…
x
Reference in New Issue
Block a user