Merge "XenAPI: Workaround for 6.5 iSCSI bug" into stable/liberty
This commit is contained in:
commit
db135984c5
|
@ -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()
|
||||
|
|
|
@ -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']
|
||||
|
|
Loading…
Reference in New Issue