summaryrefslogtreecommitdiff
path: root/nova
diff options
context:
space:
mode:
authorBrian Waldon <bcwaldon@gmail.com>2012-02-28 16:18:53 -0800
committerBrian Waldon <bcwaldon@gmail.com>2012-02-28 16:32:12 -0800
commit2fa6e23e9cefb8e45bd5a6cec36b1ac6b7ac65c3 (patch)
tree924fb14ca0dc6493c9f2d09a87cbee891bdacd3e /nova
parent315a45a35bd577129a49c4c3b08a1319f7d2e9a6 (diff)
downloadnova-2fa6e23e9cefb8e45bd5a6cec36b1ac6b7ac65c3.tar.gz
Allow xvd* to be supplied for volume in xenapi
* Fixes bug 942880 Change-Id: I7d0817051b837e3ba17f4edd8c47fd2c730c9822
Diffstat (limited to 'nova')
-rw-r--r--nova/tests/test_xenapi.py22
-rw-r--r--nova/virt/xenapi/volume_utils.py4
2 files changed, 24 insertions, 2 deletions
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py
index 4a971ff21d..f8b0c17910 100644
--- a/nova/tests/test_xenapi.py
+++ b/nova/tests/test_xenapi.py
@@ -139,6 +139,28 @@ class XenAPIVolumeTestCase(test.TestCase):
}
}
+ def test_mountpoint_to_number(self):
+ cases = {
+ 'sda': 0,
+ 'sdp': 15,
+ 'hda': 0,
+ 'hdp': 15,
+ 'vda': 0,
+ 'xvda': 0,
+ '0': 0,
+ '10': 10,
+ 'vdq': -1,
+ 'sdq': -1,
+ 'hdq': -1,
+ 'xvdq': -1,
+ }
+
+ for (input, expected) in cases.iteritems():
+ func = volume_utils.VolumeHelper.mountpoint_to_number
+ actual = func(input)
+ self.assertEqual(actual, expected,
+ '%s yielded %s, not %s' % (input, actual, expected))
+
def test_parse_volume_info_raise_exception(self):
"""This shows how to test helper classes' methods."""
stubs.stubout_session(self.stubs, stubs.FakeSessionForVolumeTests)
diff --git a/nova/virt/xenapi/volume_utils.py b/nova/virt/xenapi/volume_utils.py
index e8124f7efb..da1921bad0 100644
--- a/nova/virt/xenapi/volume_utils.py
+++ b/nova/virt/xenapi/volume_utils.py
@@ -357,8 +357,8 @@ class VolumeHelper(HelperBase):
mountpoint = mountpoint[5:]
if re.match('^[hs]d[a-p]$', mountpoint):
return (ord(mountpoint[2:3]) - ord('a'))
- elif re.match('^vd[a-p]$', mountpoint):
- return (ord(mountpoint[2:3]) - ord('a'))
+ elif re.match('^x?vd[a-p]$', mountpoint):
+ return (ord(mountpoint[-1]) - ord('a'))
elif re.match('^[0-9]+$', mountpoint):
return string.atoi(mountpoint, 10)
else: