Merge "Added by_path
root device hint"
This commit is contained in:
commit
6807cbed7d
@ -198,7 +198,7 @@ class ParseRootDeviceTestCase(base.IronicLibTestCase):
|
|||||||
'serial': 'foo-serial', 'vendor': 'foo VENDOR with space',
|
'serial': 'foo-serial', 'vendor': 'foo VENDOR with space',
|
||||||
'name': '/dev/sda', 'wwn_with_extension': '123456111',
|
'name': '/dev/sda', 'wwn_with_extension': '123456111',
|
||||||
'wwn_vendor_extension': '111', 'rotational': True,
|
'wwn_vendor_extension': '111', 'rotational': True,
|
||||||
'hctl': '1:0:0:0'}
|
'hctl': '1:0:0:0', 'by_path': '/dev/disk/by-path/1:0:0:0'}
|
||||||
result = utils.parse_root_device_hints(root_device)
|
result = utils.parse_root_device_hints(root_device)
|
||||||
expected = {
|
expected = {
|
||||||
'wwn': 's== 123456', 'model': 's== foo%20model',
|
'wwn': 's== 123456', 'model': 's== foo%20model',
|
||||||
@ -206,7 +206,8 @@ class ParseRootDeviceTestCase(base.IronicLibTestCase):
|
|||||||
'vendor': 's== foo%20vendor%20with%20space',
|
'vendor': 's== foo%20vendor%20with%20space',
|
||||||
'name': 's== /dev/sda', 'wwn_with_extension': 's== 123456111',
|
'name': 's== /dev/sda', 'wwn_with_extension': 's== 123456111',
|
||||||
'wwn_vendor_extension': 's== 111', 'rotational': True,
|
'wwn_vendor_extension': 's== 111', 'rotational': True,
|
||||||
'hctl': 's== 1%3A0%3A0%3A0'}
|
'hctl': 's== 1%3A0%3A0%3A0',
|
||||||
|
'by_path': 's== /dev/disk/by-path/1%3A0%3A0%3A0'}
|
||||||
self.assertEqual(expected, result)
|
self.assertEqual(expected, result)
|
||||||
|
|
||||||
def test_parse_root_device_hints_with_operators(self):
|
def test_parse_root_device_hints_with_operators(self):
|
||||||
@ -216,13 +217,14 @@ class ParseRootDeviceTestCase(base.IronicLibTestCase):
|
|||||||
'name': '<or> /dev/sda <or> /dev/sdb',
|
'name': '<or> /dev/sda <or> /dev/sdb',
|
||||||
'wwn_with_extension': 's!= 123456111',
|
'wwn_with_extension': 's!= 123456111',
|
||||||
'wwn_vendor_extension': 's== 111', 'rotational': True,
|
'wwn_vendor_extension': 's== 111', 'rotational': True,
|
||||||
'hctl': 's== 1:0:0:0'}
|
'hctl': 's== 1:0:0:0', 'by_path': 's== /dev/disk/by-path/1:0:0:0'}
|
||||||
|
|
||||||
# Validate strings being normalized
|
# Validate strings being normalized
|
||||||
expected = copy.deepcopy(root_device)
|
expected = copy.deepcopy(root_device)
|
||||||
expected['model'] = 's== foo%20model'
|
expected['model'] = 's== foo%20model'
|
||||||
expected['vendor'] = 's== foo%20vendor%20with%20space'
|
expected['vendor'] = 's== foo%20vendor%20with%20space'
|
||||||
expected['hctl'] = 's== 1%3A0%3A0%3A0'
|
expected['hctl'] = 's== 1%3A0%3A0%3A0'
|
||||||
|
expected['by_path'] = 's== /dev/disk/by-path/1%3A0%3A0%3A0'
|
||||||
|
|
||||||
result = utils.parse_root_device_hints(root_device)
|
result = utils.parse_root_device_hints(root_device)
|
||||||
# The hints already contain the operators, make sure we keep it
|
# The hints already contain the operators, make sure we keep it
|
||||||
@ -307,6 +309,10 @@ class ParseRootDeviceTestCase(base.IronicLibTestCase):
|
|||||||
self.assertRaises(ValueError, utils.parse_root_device_hints,
|
self.assertRaises(ValueError, utils.parse_root_device_hints,
|
||||||
{'hctl': 123})
|
{'hctl': 123})
|
||||||
|
|
||||||
|
def test_parse_root_device_hints_invalid_by_path(self):
|
||||||
|
self.assertRaises(ValueError, utils.parse_root_device_hints,
|
||||||
|
{'by_path': 123})
|
||||||
|
|
||||||
def test_parse_root_device_hints_non_existent_hint(self):
|
def test_parse_root_device_hints_non_existent_hint(self):
|
||||||
self.assertRaises(ValueError, utils.parse_root_device_hints,
|
self.assertRaises(ValueError, utils.parse_root_device_hints,
|
||||||
{'non-existent': 'foo'})
|
{'non-existent': 'foo'})
|
||||||
|
@ -52,7 +52,7 @@ LOG = logging.getLogger(__name__)
|
|||||||
VALID_ROOT_DEVICE_HINTS = {
|
VALID_ROOT_DEVICE_HINTS = {
|
||||||
'size': int, 'model': str, 'wwn': str, 'serial': str, 'vendor': str,
|
'size': int, 'model': str, 'wwn': str, 'serial': str, 'vendor': str,
|
||||||
'wwn_with_extension': str, 'wwn_vendor_extension': str, 'name': str,
|
'wwn_with_extension': str, 'wwn_vendor_extension': str, 'name': str,
|
||||||
'rotational': bool, 'hctl': str,
|
'rotational': bool, 'hctl': str, 'by_path': str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -348,6 +348,8 @@ def match_root_device_hints(devices, root_device_hints):
|
|||||||
(not rotational).
|
(not rotational).
|
||||||
:hctl: (String): The SCSI address: Host, channel, target and lun.
|
:hctl: (String): The SCSI address: Host, channel, target and lun.
|
||||||
For example: '1:0:0:0'.
|
For example: '1:0:0:0'.
|
||||||
|
:by_path: (String): The alternative device name,
|
||||||
|
e.g. /dev/disk/by-path/pci-0000:00
|
||||||
|
|
||||||
:param root_device_hints: A dictionary with the root device hints.
|
:param root_device_hints: A dictionary with the root device hints.
|
||||||
:raises: ValueError, if some information is invalid.
|
:raises: ValueError, if some information is invalid.
|
||||||
|
Loading…
Reference in New Issue
Block a user