XenAPI: Workaround for 6.5 iSCSI bug

XenServer 6.5 doesn't handle iSCSI connections correctly, due to a bug
introduced when changing the backend support.
This has been fixed upstream for the next version of XenServer, but
fix in Nova as well to ensure users of 6.5 can use Cinder-provided
volumes

Change-Id: I74e690228690d42e247f948e8be8e82ba1bf4c5b
Closes-bug: 1502929
(cherry picked from commit 46c55399c0)
Depends-On: Iefa5b16a3fa1789ed583426ea47ebb22e6cb571e
This commit is contained in:
Bob Ball 2015-10-06 11:53:44 +01:00
parent 76c488e79a
commit 9fbd706607
2 changed files with 42 additions and 0 deletions

View File

@ -241,6 +241,38 @@ class FindVBDTestCase(stubs.XenAPITestBaseNoDB):
session.VBD.get_userdevice.assert_called_once_with("a")
class IntroduceSRTestCase(stubs.XenAPITestBaseNoDB):
@mock.patch.object(volume_utils, '_create_pbd')
def test_backend_kind(self, create_pbd):
session = mock.Mock()
session.product_version = (6, 5, 0)
session.call_xenapi.return_value = 'sr_ref'
params = {'sr_type': 'iscsi'}
sr_uuid = 'sr_uuid'
label = 'label'
expected_params = {'backend-kind': 'vbd'}
volume_utils.introduce_sr(session, sr_uuid, label, params)
session.call_xenapi.assert_any_call('SR.introduce', sr_uuid,
label, '', 'iscsi',
'', False, expected_params)
@mock.patch.object(volume_utils, '_create_pbd')
def test_backend_kind_upstream_fix(self, create_pbd):
session = mock.Mock()
session.product_version = (7, 0, 0)
session.call_xenapi.return_value = 'sr_ref'
params = {'sr_type': 'iscsi'}
sr_uuid = 'sr_uuid'
label = 'label'
expected_params = {}
volume_utils.introduce_sr(session, sr_uuid, label, params)
session.call_xenapi.assert_any_call('SR.introduce', sr_uuid,
label, '', 'iscsi',
'', False, expected_params)
class BootedFromVolumeTestCase(stubs.XenAPITestBaseNoDB):
def test_booted_from_volume(self):
session = mock.Mock()

View File

@ -27,6 +27,7 @@ from eventlet import greenthread
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import strutils
from oslo_utils import versionutils
from nova import exception
from nova.i18n import _, _LE, _LW
@ -132,6 +133,9 @@ def introduce_sr(session, sr_uuid, label, params):
sr_type, sr_desc = _handle_sr_params(params)
if _requires_backend_kind(session.product_version) and sr_type == 'iscsi':
params['backend-kind'] = 'vbd'
sr_ref = session.call_xenapi('SR.introduce', sr_uuid, label, sr_desc,
sr_type, '', False, params)
@ -145,6 +149,12 @@ def introduce_sr(session, sr_uuid, label, params):
return sr_ref
def _requires_backend_kind(version):
# Fix for Bug #1502929
version_as_string = '.'.join(str(v) for v in version)
return (versionutils.is_compatible('6.5', version_as_string))
def _handle_sr_params(params):
if 'id' in params:
del params['id']