diff options
author | Vishvananda Ishaya <vishvananda@gmail.com> | 2012-09-04 15:25:35 -0700 |
---|---|---|
committer | Vishvananda Ishaya <vishvananda@gmail.com> | 2012-09-04 17:30:26 -0700 |
commit | 07e0b779fda808211853242415087753ca186ac4 (patch) | |
tree | 0b3987f0e8340bf487b13c54158ac118f247d6f2 /nova/block_device.py | |
parent | 51f5b8c28e37af4ab7c86e5b4ed8a3be0460fe32 (diff) | |
download | nova-07e0b779fda808211853242415087753ca186ac4.tar.gz nova-07e0b779fda808211853242415087753ca186ac4.tar.xz nova-07e0b779fda808211853242415087753ca186ac4.zip |
Automatically convert device names
In the past, users have been able to specify xvda or xvdb and it
has worked. We are now validating device names against the expected
name from the backend, and this causes confusion, especially for lxc
which expecting device names to be /dev/a /dev/b /dev/c etc.
This patch addresses the issue by automatically converting between
different formats. The proper format for the backend will be returned
by the api. Includes tests to verify that the conversion works and
that the lxc values work as expected.
Fixes bug 1046020
Change-Id: Iffa552ba05f89f70b6fb93043edf8882c8412215
Diffstat (limited to 'nova/block_device.py')
-rw-r--r-- | nova/block_device.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/nova/block_device.py b/nova/block_device.py index fbb935d7c..bce71e183 100644 --- a/nova/block_device.py +++ b/nova/block_device.py @@ -131,3 +131,11 @@ def instance_block_mapping(instance, bdms): nebs += 1 return mappings + + +def match_device(device): + """Matches device name and returns prefix, suffix""" + match = re.match("(^/dev/x{0,1}[a-z]{0,1}d{0,1})([a-z]+)[0-9]*$", device) + if not match: + return None + return match.groups() |