Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow xvd* to be supplied for volume in xenapi
* Fixes bug 942880

Change-Id: I7d0817051b837e3ba17f4edd8c47fd2c730c9822
  • Loading branch information
bcwaldon committed Feb 29, 2012
1 parent 315a45a commit 2fa6e23
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
22 changes: 22 additions & 0 deletions nova/tests/test_xenapi.py
Expand Up @@ -139,6 +139,28 @@ def _make_info():
}
}

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)
Expand Down
4 changes: 2 additions & 2 deletions nova/virt/xenapi/volume_utils.py
Expand Up @@ -357,8 +357,8 @@ def mountpoint_to_number(cls, mountpoint):
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:
Expand Down

0 comments on commit 2fa6e23

Please sign in to comment.