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 shlex
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
import netifaces
|
import netifaces
|
||||||
from oslo_concurrency import processutils
|
from oslo_concurrency import processutils
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
|
from oslo_utils import strutils
|
||||||
from oslo_utils import units
|
from oslo_utils import units
|
||||||
import pint
|
import pint
|
||||||
import psutil
|
import psutil
|
||||||
@ -604,6 +606,10 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
|
|
||||||
def match(hint, current_value, device):
|
def match(hint, current_value, device):
|
||||||
hint_value = root_device_hints[hint]
|
hint_value = root_device_hints[hint]
|
||||||
|
|
||||||
|
if hint == 'rotational':
|
||||||
|
hint_value = strutils.bool_from_string(hint_value)
|
||||||
|
|
||||||
if hint_value != current_value:
|
if hint_value != current_value:
|
||||||
LOG.debug("Root device hint %(hint)s=%(value)s does not "
|
LOG.debug("Root device hint %(hint)s=%(value)s does not "
|
||||||
"match the device %(device)s value of "
|
"match the device %(device)s value of "
|
||||||
@ -617,14 +623,17 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
def check_device_attrs(device):
|
def check_device_attrs(device):
|
||||||
for key in ('model', 'wwn', 'serial', 'vendor',
|
for key in ('model', 'wwn', 'serial', 'vendor',
|
||||||
'wwn_with_extension', 'wwn_vendor_extension',
|
'wwn_with_extension', 'wwn_vendor_extension',
|
||||||
'name'):
|
'name', 'rotational'):
|
||||||
if key not in root_device_hints:
|
if key not in root_device_hints:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
value = getattr(device, key)
|
value = getattr(device, key)
|
||||||
if not value:
|
if value is None:
|
||||||
return False
|
return False
|
||||||
value = utils.normalize(value)
|
|
||||||
|
if isinstance(value, six.string_types):
|
||||||
|
value = utils.normalize(value)
|
||||||
|
|
||||||
if not match(key, value, device.name):
|
if not match(key, value, device.name):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -448,7 +448,7 @@ class TestGenericHardwareManager(test_base.BaseTestCase):
|
|||||||
hardware.BlockDevice(name='/dev/sdb',
|
hardware.BlockDevice(name='/dev/sdb',
|
||||||
model=model,
|
model=model,
|
||||||
size=10737418240,
|
size=10737418240,
|
||||||
rotational=False,
|
rotational=True,
|
||||||
vendor='fake-vendor',
|
vendor='fake-vendor',
|
||||||
wwn='fake-wwn',
|
wwn='fake-wwn',
|
||||||
wwn_with_extension='fake-wwnven0',
|
wwn_with_extension='fake-wwnven0',
|
||||||
@ -485,6 +485,11 @@ class TestGenericHardwareManager(test_base.BaseTestCase):
|
|||||||
self._get_os_install_device_root_device_hints(
|
self._get_os_install_device_root_device_hints(
|
||||||
{'name': '/dev/sdb'}, '/dev/sdb')
|
{'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, 'list_all_block_devices')
|
||||||
@mock.patch.object(hardware, 'get_cached_node')
|
@mock.patch.object(hardware, 'get_cached_node')
|
||||||
def test_get_os_install_device_root_device_hints_no_device_found(
|
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