Prepend /dev/ to root_device_name in get_next_device_name
Because the API docs for booting an instance from a volume have shown to use 'vda' for a long time, and it has worked, there may be instances with root_device_name = 'vda'. These instances will fail a check in get_next_device_name when attempting to attach another volume, making that impossible. Another patch fixes new block_device_mappings by prepending /dev/ when the root_device_name is populated, but this will allow incorrectly populated instances to attach volumes. Change-Id: I709a195c7e3f559315a2c307de62cbae8b72ac46 Partial-Bug: #1337821
This commit is contained in:
parent
29d174e541
commit
426d394b77
@ -148,7 +148,8 @@ def get_next_device_name(instance, device_name_list,
|
||||
root_device_name = block_device.DEFAULT_ROOT_DEV_NAME
|
||||
|
||||
try:
|
||||
prefix = block_device.match_device(root_device_name)[0]
|
||||
prefix = block_device.match_device(
|
||||
block_device.prepend_dev(root_device_name))[0]
|
||||
except (TypeError, AttributeError, ValueError):
|
||||
raise exception.InvalidDevicePath(path=root_device_name)
|
||||
|
||||
|
@ -168,11 +168,6 @@ class ComputeValidateDeviceTestCase(test.TestCase):
|
||||
device = self._validate_device('/dev/xvdc')
|
||||
self.assertEqual(device, '/dev/vdc')
|
||||
|
||||
def test_invalid_bdms(self):
|
||||
self.instance['root_device_name'] = "baddata"
|
||||
self.assertRaises(exception.InvalidDevicePath,
|
||||
self._validate_device)
|
||||
|
||||
def test_invalid_device_prefix(self):
|
||||
self.assertRaises(exception.InvalidDevicePath,
|
||||
self._validate_device, '/baddata/vdc')
|
||||
@ -236,6 +231,11 @@ class ComputeValidateDeviceTestCase(test.TestCase):
|
||||
device = self._validate_device()
|
||||
self.assertEqual(device, '/dev/xvdd')
|
||||
|
||||
def test_no_dev_root_device_name_get_next_name(self):
|
||||
self.instance['root_device_name'] = 'vda'
|
||||
device = self._validate_device()
|
||||
self.assertEqual('/dev/vdc', device)
|
||||
|
||||
|
||||
class DefaultDeviceNamesForInstanceTestCase(test.NoDBTestCase):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user