--- /dev/null
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# (c) Copyright 2013 Hewlett-Packard Development Company, L.P.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+"""Exceptions for the Brick library."""
+
+
+class NoFibreChannelHostsFound(Exception):
+ def __init__(self):
+ message = _("We are unable to locate any Fibre Channel devices")
+ super(NoFibreChannelHostsFound, self).__init__(message)
+
+
+class NoFibreChannelVolumeDeviceFound(Exception):
+ def __init__(self):
+ message = _("Unable to find a Fibre Channel volume device")
+ super(NoFibreChannelVolumeDeviceFound, self).__init__(message)
+
+
+class VolumeDeviceNotFound(Exception):
+ def __init__(self, device):
+ message = _("Volume device not found at %s") % device
+ super(VolumeDeviceNotFound, self).__init__(message)
from oslo.config import cfg
-from cinder import exception
+from cinder.brick import exceptions
from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import lockutils
from cinder.openstack.common import log as logging
wwpns = fc.get_fc_wwpns()
if wwpns:
props['wwpns'] = wwpns
+ wwnns = fc.get_fc_wwnns()
+ if wwnns:
+ props['wwnns'] = wwnns
return props
try:
out, info = self._execute(*cmd, run_as_root=True,
root_helper=self._root_helper)
- except exception.ProcessExecutionError as e:
+ except putils.ProcessExecutionError as e:
LOG.error(_("Failed to access the device on the path "
"%(path)s: %(error)s %(info)s.") %
{"path": path, "error": e.stderr,
tries = 0
while not os.path.exists(host_device):
if tries >= CONF.num_iscsi_scan_tries:
- raise exception.CinderException(
- _("iSCSI device not found at %s") % (host_device))
+ raise exceptions.VolumeDeviceNotFound(host_device)
LOG.warn(_("ISCSI volume not yet found at: %(host_device)s. "
"Will rescan & retry. Try number: %(tries)s"),
def get_initiator(self):
"""Secure helper to read file as root."""
+ file_path = '/etc/iscsi/initiatorname.iscsi'
try:
- file_path = '/etc/iscsi/initiatorname.iscsi'
lines, _err = self._execute('cat', file_path, run_as_root=True,
root_helper=self._root_helper)
for l in lines.split('\n'):
if l.startswith('InitiatorName='):
return l[l.index('=') + 1:].strip()
- except exception.ProcessExecutionError:
+ except putils.ProcessExecutionError:
+ msg = (_("Could not find the iSCSI Initiator File %s")
+ % file_path)
+ LOG.warn(msg)
return None
def _run_iscsiadm(self, connection_properties, iscsi_command, **kwargs):
if len(host_devices) == 0:
# this is empty because we don't have any FC HBAs
msg = _("We are unable to locate any Fibre Channel devices")
- raise exception.CinderException(msg)
+ LOG.warn(msg)
+ raise exceptions.NoFibreChannelHostsFound()
# The /dev/disk/by-path/... node is not always present immediately
# We only need to find the first device. Once we see the first device
raise loopingcall.LoopingCallDone()
if self.tries >= CONF.num_iscsi_scan_tries:
- msg = _("Fibre Channel device not found.")
- raise exception.CinderException(msg)
+ msg = _("Fibre Channel volume device not found.")
+ LOG.error(msg)
+ raise exceptions.NoFibreChannelVolumeDeviceFound()
LOG.warn(_("Fibre volume not yet found. "
"Will rescan & retry. Try number: %(tries)s"),
import os.path
import string
+from cinder.brick import exceptions
from cinder.brick.initiator import connector
from cinder.brick.initiator import host_driver
from cinder.brick.initiator import linuxfc
from cinder.brick.initiator import linuxscsi
-from cinder import exception
from cinder.openstack.common import log as logging
+from cinder.openstack.common import processutils as putils
from cinder import test
LOG = logging.getLogger(__name__)
def test_get_initiator(self):
def initiator_no_file(*args, **kwargs):
- raise exception.ProcessExecutionError('No file')
+ raise putils.ProcessExecutionError('No file')
def initiator_get_text(*arg, **kwargs):
text = ('## DO NOT EDIT OR REMOVE THIS FILE!\n'
lambda: [])
self.stubs.Set(self.connector._linuxfc, 'get_fc_hbas_info',
lambda: [])
- self.assertRaises(exception.CinderException,
+ self.assertRaises(exceptions.NoFibreChannelHostsFound,
self.connector.connect_volume,
connection_info['data'])