Don't make nova-compute depend on iSCSI
Because not all volume drivers require iSCSI it makes sense to not set the initiator in the connector and let the volume drivers return an error if iSCSI is required. bug #1007084 Change-Id: I5da472e5013fdc0c733ecb12b919c1068873bdc6
This commit is contained in:
parent
bdf362b810
commit
3ba0c171c0
|
@ -4520,6 +4520,17 @@ class LibvirtUtilsTestCase(test.TestCase):
|
|||
result = libvirt_utils.get_iscsi_initiator()
|
||||
self.assertEqual(initiator, result)
|
||||
|
||||
def test_get_missing_iscsi_initiator(self):
|
||||
self.mox.StubOutWithMock(utils, 'execute')
|
||||
file_path = '/etc/iscsi/initiatorname.iscsi'
|
||||
utils.execute('cat', file_path, run_as_root=True).AndRaise(
|
||||
exception.FileNotFound(file_path=file_path)
|
||||
)
|
||||
# Start test
|
||||
self.mox.ReplayAll()
|
||||
result = libvirt_utils.get_iscsi_initiator()
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_create_image(self):
|
||||
self.mox.StubOutWithMock(utils, 'execute')
|
||||
utils.execute('qemu-img', 'create', '-f', 'raw',
|
||||
|
|
|
@ -929,15 +929,12 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
'world wide port names'),
|
||||
instance=instance)
|
||||
|
||||
if not self._initiator and not self._fc_wwnns and not self._fc_wwpns:
|
||||
msg = _("No Volume Connector found.")
|
||||
LOG.error(msg)
|
||||
raise exception.NovaException(msg)
|
||||
|
||||
connector = {'ip': CONF.my_ip,
|
||||
'initiator': self._initiator,
|
||||
'host': CONF.host}
|
||||
|
||||
if self._initiator:
|
||||
connector['initiator'] = self._initiator
|
||||
|
||||
if self._fc_wwnns and self._fc_wwpns:
|
||||
connector["wwnns"] = self._fc_wwnns
|
||||
connector["wwpns"] = self._fc_wwpns
|
||||
|
|
|
@ -26,6 +26,7 @@ import os
|
|||
from lxml import etree
|
||||
from oslo.config import cfg
|
||||
|
||||
from nova import exception
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.openstack.common import processutils
|
||||
from nova import utils
|
||||
|
@ -52,7 +53,11 @@ def get_iscsi_initiator():
|
|||
"""Get iscsi initiator name for this machine."""
|
||||
# NOTE(vish) openiscsi stores initiator name in a file that
|
||||
# needs root permission to read.
|
||||
contents = utils.read_file_as_root('/etc/iscsi/initiatorname.iscsi')
|
||||
try:
|
||||
contents = utils.read_file_as_root('/etc/iscsi/initiatorname.iscsi')
|
||||
except exception.FileNotFound:
|
||||
return None
|
||||
|
||||
for l in contents.split('\n'):
|
||||
if l.startswith('InitiatorName='):
|
||||
return l[l.index('=') + 1:].strip()
|
||||
|
|
Loading…
Reference in New Issue