Fix Cinder volumes support with xenserver

Fixes bug: #1193422

Change-Id: I8cd36112a647c4207dec8290511b01f1c22c0879
This commit is contained in:
Sergey Reshetnyak 2013-09-23 12:11:58 +04:00
parent 25237c9708
commit 289e781d48
2 changed files with 14 additions and 2 deletions

View File

@ -108,8 +108,14 @@ def _get_device_paths(instance):
def _get_free_device_path(instance):
device_paths = _get_device_paths(instance)
device_prefix = '/dev/vd'
for dp in device_paths:
if re.search('^/dev/xvd.*', dp):
device_prefix = '/dev/xvd'
for idx in range(0, 26):
device_path = '/dev/vd' + chr(ord('a') + idx)
device_path = device_prefix + chr(ord('a') + idx)
if device_path not in device_paths:
return device_path

View File

@ -80,10 +80,16 @@ class TestAttachVolume(models_test_base.DbTestCase):
8 0 488386584 vda
8 1 102400 vda1"""
p_ex_cmd.return_value = (0, stdout)
self.assertEqual(volumes._get_free_device_path(instance), '/dev/vdb')
stdout = """major minor #blocks name
8 0 488386584 xvda
8 1 102400 xvda1"""
p_ex_cmd.return_value = (0, stdout)
self.assertEqual(volumes._get_free_device_path(instance), '/dev/xvdb')
stdout = "major minor #blocks name\n"
for idx in range(0, 26):
line = " 8 0 488386584 vd" + chr(ord('a') + idx) + '\n'