move brocade zone manager exceptions

This patch moves the brocade zone manager exceptions to
brocade/exception.py

Change-Id: Ia9f7107cde306271faeca49a8d3e447b3962c47b
This commit is contained in:
Walter A. Boring IV 2019-05-09 18:28:18 +00:00
parent 05ddc36dd7
commit 659d4e390a
7 changed files with 98 additions and 80 deletions

View File

@ -1082,18 +1082,6 @@ class ZoneManagerNotInitialized(CinderException):
message = _("Fibre Channel Zone Manager not initialized")
class BrocadeZoningCliException(CinderException):
message = _("Brocade Fibre Channel Zoning CLI error: %(reason)s")
class BrocadeZoningHttpException(CinderException):
message = _("Brocade Fibre Channel Zoning HTTP error: %(reason)s")
class BrocadeZoningRestException(CinderException):
message = _("Brocade Fibre Channel Zoning REST error: %(reason)s")
class CiscoZoningCliException(CinderException):
message = _("Cisco Fibre Channel Zoning CLI error: %(reason)s")

View File

@ -24,6 +24,7 @@ from cinder import exception
from cinder import test
from cinder.zonemanager.drivers.brocade import (brcd_fc_zone_client_cli
as client_cli)
from cinder.zonemanager.drivers.brocade import exception as b_exception
import cinder.zonemanager.drivers.brocade.fc_zone_constants as zone_constant
@ -82,7 +83,7 @@ class TestBrcdFCZoneClientCLI(client_cli.BrcdFCZoneClientCLI, test.TestCase):
@mock.patch.object(client_cli.BrcdFCZoneClientCLI, '_run_ssh')
def test_get_active_zone_set_ssh_error(self, run_ssh_mock):
run_ssh_mock.side_effect = processutils.ProcessExecutionError
self.assertRaises(exception.BrocadeZoningCliException,
self.assertRaises(b_exception.BrocadeZoningCliException,
self.get_active_zone_set)
@mock.patch.object(client_cli.BrcdFCZoneClientCLI, 'get_active_zone_set')
@ -190,7 +191,7 @@ class TestBrcdFCZoneClientCLI(client_cli.BrcdFCZoneClientCLI, test.TestCase):
@mock.patch.object(client_cli.BrcdFCZoneClientCLI, '_run_ssh')
def test_get_nameserver_info_ssh_error(self, run_ssh_mock):
run_ssh_mock.side_effect = processutils.ProcessExecutionError
self.assertRaises(exception.BrocadeZoningCliException,
self.assertRaises(b_exception.BrocadeZoningCliException,
self.get_nameserver_info)
@mock.patch.object(client_cli.BrcdFCZoneClientCLI, '_ssh_execute')
@ -228,7 +229,7 @@ class TestBrcdFCZoneClientCLI(client_cli.BrcdFCZoneClientCLI, test.TestCase):
@mock.patch.object(client_cli.BrcdFCZoneClientCLI, '_run_ssh')
def test__is_trans_abortable_ssh_error(self, run_ssh_mock):
run_ssh_mock.return_value = (Stream(), Stream())
self.assertRaises(exception.BrocadeZoningCliException,
self.assertRaises(b_exception.BrocadeZoningCliException,
self._is_trans_abortable)
@mock.patch.object(client_cli.BrcdFCZoneClientCLI, '_run_ssh')
@ -282,7 +283,7 @@ class TestBrcdFCZoneClientCLI(client_cli.BrcdFCZoneClientCLI, test.TestCase):
@mock.patch.object(client_cli.BrcdFCZoneClientCLI, '_execute_shell_cmd')
def test_is_supported_firmware_ssh_error(self, exec_shell_cmd_mock):
exec_shell_cmd_mock.side_effect = processutils.ProcessExecutionError
self.assertRaises(exception.BrocadeZoningCliException,
self.assertRaises(b_exception.BrocadeZoningCliException,
self.is_supported_firmware)

View File

@ -23,10 +23,10 @@ import mock
from mock import patch
import six
from cinder import exception
from cinder import test
from cinder.zonemanager.drivers.brocade import (brcd_http_fc_zone_client
as client)
from cinder.zonemanager.drivers.brocade import exception as b_exception
import cinder.zonemanager.drivers.brocade.fc_zone_constants as zone_constant
@ -496,7 +496,7 @@ class TestBrcdHttpFCZoneClient(client.BrcdHTTPFCZoneClient, test.TestCase):
def test_authenticate_failed(self, connect_mock):
connect_mock.return_value = un_authenticate_resp
self.assertRaises(
exception.BrocadeZoningHttpException, self.authenticate)
b_exception.BrocadeZoningHttpException, self.authenticate)
def test_get_parsed_data(self):
valid_delimiter1 = zone_constant.SWITCHINFO_BEGIN
@ -504,12 +504,12 @@ class TestBrcdHttpFCZoneClient(client.BrcdHTTPFCZoneClient, test.TestCase):
invalid_delimiter = "--END SWITCH INFORMATION1"
self.assertEqual(parsed_value, self.get_parsed_data(
switch_page_resp, valid_delimiter1, valid_delimiter2))
self.assertRaises(exception.BrocadeZoningHttpException,
self.assertRaises(b_exception.BrocadeZoningHttpException,
self.get_parsed_data,
switch_page_resp,
valid_delimiter1,
invalid_delimiter)
self.assertRaises(exception.BrocadeZoningHttpException,
self.assertRaises(b_exception.BrocadeZoningHttpException,
self.get_parsed_data,
switch_page_resp,
invalid_delimiter,
@ -521,7 +521,7 @@ class TestBrcdHttpFCZoneClient(client.BrcdHTTPFCZoneClient, test.TestCase):
self.assertEqual(
"v7.3.0b_rc1_bld06", self.get_nvp_value(parsed_value,
valid_keyname))
self.assertRaises(exception.BrocadeZoningHttpException,
self.assertRaises(b_exception.BrocadeZoningHttpException,
self.get_nvp_value,
parsed_value,
invalid_keyname)
@ -530,7 +530,7 @@ class TestBrcdHttpFCZoneClient(client.BrcdHTTPFCZoneClient, test.TestCase):
manageable_list = ['2', '128']
self.assertEqual(
manageable_list, self.get_managable_vf_list(session_info_vf))
self.assertRaises(exception.BrocadeZoningHttpException,
self.assertRaises(b_exception.BrocadeZoningHttpException,
self.get_managable_vf_list, session_info_AD)
@mock.patch.object(client.BrcdHTTPFCZoneClient, 'is_vf_enabled')
@ -538,7 +538,7 @@ class TestBrcdHttpFCZoneClient(client.BrcdHTTPFCZoneClient, test.TestCase):
is_vf_enabled_mock.return_value = (True, session_info_vf)
self.vfid = None
self.assertRaises(
exception.BrocadeZoningHttpException,
b_exception.BrocadeZoningHttpException,
self.check_change_vf_context)
self.vfid = "2"
with mock.patch.object(self, 'change_vf_context') \
@ -552,7 +552,7 @@ class TestBrcdHttpFCZoneClient(client.BrcdHTTPFCZoneClient, test.TestCase):
is_vf_enabled_mock.return_value = (False, session_info_AD)
self.vfid = "128"
self.assertRaises(
exception.BrocadeZoningHttpException,
b_exception.BrocadeZoningHttpException,
self.check_change_vf_context)
@mock.patch.object(client.BrcdHTTPFCZoneClient, 'get_managable_vf_list')
@ -575,7 +575,7 @@ class TestBrcdHttpFCZoneClient(client.BrcdHTTPFCZoneClient, test.TestCase):
get_managable_vf_list_mock):
get_managable_vf_list_mock.return_value = ['2', '128']
connect_mock.return_value = session_info_vf_not_changed
self.assertRaises(exception.BrocadeZoningHttpException,
self.assertRaises(b_exception.BrocadeZoningHttpException,
self.change_vf_context, "2", session_info_vf)
data = zone_constant.CHANGE_VF.format(vfid="2")
headers = {zone_constant.AUTH_HEADER: self.auth_header}
@ -587,7 +587,7 @@ class TestBrcdHttpFCZoneClient(client.BrcdHTTPFCZoneClient, test.TestCase):
def test_change_vf_context_vfid_not_managaed(self,
get_managable_vf_list_mock):
get_managable_vf_list_mock.return_value = ['2', '128']
self.assertRaises(exception.BrocadeZoningHttpException,
self.assertRaises(b_exception.BrocadeZoningHttpException,
self.change_vf_context, "12", session_info_vf)
@patch.object(client.BrcdHTTPFCZoneClient, 'connect')
@ -655,7 +655,7 @@ class TestBrcdHttpFCZoneClient(client.BrcdHTTPFCZoneClient, test.TestCase):
'20:19:00:05:1e:e8:e3:29']
}
self.assertRaises(
exception.BrocadeZoningHttpException,
b_exception.BrocadeZoningHttpException,
self.add_zones, add_zones_info, False)
@patch.object(client.BrcdHTTPFCZoneClient, 'post_zone_data')
@ -714,7 +714,7 @@ class TestBrcdHttpFCZoneClient(client.BrcdHTTPFCZoneClient, test.TestCase):
self.ifas = ifas.copy()
self.active_cfg = active_cfg
delete_zones_info = 'openstack50060b0000c26604201900051ee8e32'
self.assertRaises(exception.BrocadeZoningHttpException,
self.assertRaises(b_exception.BrocadeZoningHttpException,
self.delete_zones, delete_zones_info, False)
@patch.object(time, 'sleep')

View File

@ -32,6 +32,7 @@ from cinder import exception
from cinder.i18n import _
from cinder import ssh_utils
from cinder import utils
from cinder.zonemanager.drivers.brocade import exception as b_exception
import cinder.zonemanager.drivers.brocade.fc_zone_constants as zone_constant
LOG = logging.getLogger(__name__)
@ -82,7 +83,7 @@ class BrcdFCZoneClientCLI(object):
try:
switch_data = self._get_switch_info(
[zone_constant.GET_ACTIVE_ZONE_CFG])
except exception.BrocadeZoningCliException:
except b_exception.BrocadeZoningCliException:
with excutils.save_and_reraise_exception():
LOG.error("Failed getting active zone set "
"from fabric %s", self.switch_ip)
@ -196,7 +197,7 @@ class BrcdFCZoneClientCLI(object):
"(Zone set=%(cfg_name)s error=%(err)s)."
) % {'cfg_name': cfg_name, 'err': six.text_type(e)}
LOG.error(msg)
raise exception.BrocadeZoningCliException(reason=msg)
raise b_exception.BrocadeZoningCliException(reason=msg)
def update_zones(self, zones, activate, operation, active_zone_set=None):
"""Update the zone configuration.
@ -261,7 +262,7 @@ class BrcdFCZoneClientCLI(object):
"(Zone set=%(cfg_name)s error=%(err)s)."
) % {'cfg_name': cfg_name, 'err': six.text_type(e)}
LOG.error(msg)
raise exception.BrocadeZoningCliException(reason=msg)
raise b_exception.BrocadeZoningCliException(reason=msg)
def activate_zoneset(self, cfgname):
"""Method to Activate the zone config. Param cfgname - ZonesetName."""
@ -316,7 +317,7 @@ class BrcdFCZoneClientCLI(object):
) % {'cmd': cmd, 'err': six.text_type(e)}
LOG.error(msg)
self._cfg_trans_abort()
raise exception.BrocadeZoningCliException(reason=msg)
raise b_exception.BrocadeZoningCliException(reason=msg)
def get_nameserver_info(self):
"""Get name server data from fabric.
@ -331,7 +332,7 @@ class BrcdFCZoneClientCLI(object):
'nsshow': zone_constant.NS_SHOW,
'nscamshow': zone_constant.NS_CAM_SHOW}
cli_output = self._get_switch_info([cmd])
except exception.BrocadeZoningCliException:
except b_exception.BrocadeZoningCliException:
with excutils.save_and_reraise_exception():
LOG.error("Failed collecting nsshow "
"info for fabric %s", self.switch_ip)
@ -365,7 +366,7 @@ class BrcdFCZoneClientCLI(object):
break
if stderr:
msg = _("Error while checking transaction status: %s") % stderr
raise exception.BrocadeZoningCliException(reason=msg)
raise b_exception.BrocadeZoningCliException(reason=msg)
else:
return is_abortable
@ -384,7 +385,7 @@ class BrcdFCZoneClientCLI(object):
"error=%(err)s).") % {'cmd': cmd_list, 'err': stdout}
LOG.error(msg)
self._cfg_trans_abort()
raise exception.BrocadeZoningCliException(reason=msg)
raise b_exception.BrocadeZoningCliException(reason=msg)
def is_supported_firmware(self):
"""Check firmware version is v6.4 or higher.
@ -411,7 +412,7 @@ class BrcdFCZoneClientCLI(object):
msg = _("Error while getting data via ssh: (command=%(cmd)s "
"error=%(err)s).") % {'cmd': cmd, 'err': six.text_type(e)}
LOG.error(msg)
raise exception.BrocadeZoningCliException(reason=msg)
raise b_exception.BrocadeZoningCliException(reason=msg)
def _get_switch_info(self, cmd_list):
stdout, stderr, sw_data = None, None, None
@ -425,7 +426,7 @@ class BrcdFCZoneClientCLI(object):
"error=%(err)s).") % {'cmd': cmd_list,
'err': six.text_type(e)}
LOG.error(msg)
raise exception.BrocadeZoningCliException(reason=msg)
raise b_exception.BrocadeZoningCliException(reason=msg)
def _parse_ns_output(self, switch_data):
"""Parses name server data.

View File

@ -40,6 +40,7 @@ from cinder import exception
from cinder.i18n import _
from cinder import interface
from cinder.zonemanager.drivers.brocade import brcd_fabric_opts as fabric_opts
from cinder.zonemanager.drivers.brocade import exception as b_exception
from cinder.zonemanager.drivers.brocade import fc_zone_constants
from cinder.zonemanager.drivers import driver_utils
from cinder.zonemanager.drivers import fc_zone_driver
@ -232,9 +233,9 @@ class BrcdFCZoneDriver(fc_zone_driver.FCZoneDriver):
cfgmap_from_fabric)
LOG.debug("Zones updated successfully: %(updatemap)s",
{'updatemap': zone_update_map})
except (exception.BrocadeZoningCliException,
exception.BrocadeZoningHttpException,
exception.BrocadeZoningRestException) as brocade_ex:
except (b_exception.BrocadeZoningCliException,
b_exception.BrocadeZoningHttpException,
b_exception.BrocadeZoningRestException) as brocade_ex:
raise exception.FCZoneDriverException(brocade_ex)
except Exception:
msg = _("Failed to add or update zoning configuration.")
@ -380,9 +381,9 @@ class BrcdFCZoneDriver(fc_zone_driver.FCZoneDriver):
conn.delete_zones(
zone_name_string, zone_activate,
cfgmap_from_fabric)
except (exception.BrocadeZoningCliException,
exception.BrocadeZoningHttpException,
exception.BrocadeZoningRestException) as brocade_ex:
except (b_exception.BrocadeZoningCliException,
b_exception.BrocadeZoningHttpException,
b_exception.BrocadeZoningRestException) as brocade_ex:
raise exception.FCZoneDriverException(brocade_ex)
except Exception:
msg = _("Failed to update or delete zoning "
@ -420,8 +421,8 @@ class BrcdFCZoneDriver(fc_zone_driver.FCZoneDriver):
nsinfo = conn.get_nameserver_info()
LOG.debug("Name server info from fabric: %(nsinfo)s",
{'nsinfo': nsinfo})
except (exception.BrocadeZoningCliException,
exception.BrocadeZoningHttpException):
except (b_exception.BrocadeZoningCliException,
b_exception.BrocadeZoningHttpException):
if not conn.is_supported_firmware():
msg = _("Unsupported firmware on switch %s. Make sure "
"switch is running firmware v6.4 or higher"
@ -460,8 +461,8 @@ class BrcdFCZoneDriver(fc_zone_driver.FCZoneDriver):
cfgmap = None
try:
cfgmap = conn.get_active_zone_set()
except (exception.BrocadeZoningCliException,
exception.BrocadeZoningHttpException):
except (b_exception.BrocadeZoningCliException,
b_exception.BrocadeZoningHttpException):
if not conn.is_supported_firmware():
msg = _("Unsupported firmware on switch %s. Make sure "
"switch is running firmware v6.4 or higher"

View File

@ -26,8 +26,8 @@ from oslo_log import log as logging
from oslo_serialization import base64
from oslo_utils import encodeutils
from cinder import exception
from cinder.i18n import _
from cinder.zonemanager.drivers.brocade import exception as b_exception
import cinder.zonemanager.drivers.brocade.fc_zone_constants as zone_constant
@ -117,7 +117,7 @@ class BrcdHTTPFCZoneClient(object):
msg = _("Error while querying page %(url)s on the switch, "
"reason %(error)s.") % {'url': url,
'error': response.reason}
raise exception.BrocadeZoningHttpException(msg)
raise b_exception.BrocadeZoningHttpException(msg)
else:
return response.text
except requests.exceptions.ConnectionError as e:
@ -127,8 +127,8 @@ class BrcdHTTPFCZoneClient(object):
'protocol': self.protocol,
'error': six.text_type(e)})
LOG.error(msg)
raise exception.BrocadeZoningHttpException(reason=msg)
except exception.BrocadeZoningHttpException as ex:
raise b_exception.BrocadeZoningHttpException(reason=msg)
except b_exception.BrocadeZoningHttpException as ex:
msg = (_("Unexpected status code from the switch %(switch_id)s "
"with protocol %(protocol)s for url %(page)s. "
"Error: %(error)s")
@ -137,7 +137,7 @@ class BrcdHTTPFCZoneClient(object):
'page': requestURL,
'error': six.text_type(ex)})
LOG.error(msg)
raise exception.BrocadeZoningHttpException(reason=msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
def create_auth_token(self):
"""Create the authentication token.
@ -176,7 +176,7 @@ class BrcdHTTPFCZoneClient(object):
msg = (_("Error while creating authentication token: %s")
% six.text_type(e))
LOG.error(msg)
raise exception.BrocadeZoningHttpException(reason=msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
return auth_header
def authenticate(self):
@ -216,12 +216,12 @@ class BrcdHTTPFCZoneClient(object):
msg = (_("Authentication failed, verify the switch "
"credentials, error code %s.") % auth_error_code)
LOG.error(msg)
raise exception.BrocadeZoningHttpException(reason=msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
except Exception as e:
msg = (_("Error while authenticating with switch: %s.")
% six.text_type(e))
LOG.error(msg)
raise exception.BrocadeZoningHttpException(reason=msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
def get_session_info(self):
"""Get the session information from the switch
@ -238,7 +238,7 @@ class BrcdHTTPFCZoneClient(object):
msg = (_("Error while getting session information %s.")
% six.text_type(e))
LOG.error(msg)
raise exception.BrocadeZoningHttpException(reason=msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
return response
def get_parsed_data(self, data, delim1, delim2):
@ -257,7 +257,7 @@ class BrcdHTTPFCZoneClient(object):
except ValueError as e:
msg = (_("Error while parsing the data: %s.") % six.text_type(e))
LOG.error(msg)
raise exception.BrocadeZoningHttpException(reason=msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
def get_nvp_value(self, data, keyname):
"""Get the value for the key passed.
@ -275,7 +275,7 @@ class BrcdHTTPFCZoneClient(object):
except ValueError as e:
msg = (_("Error while getting nvp value: %s.") % six.text_type(e))
LOG.error(msg)
raise exception.BrocadeZoningHttpException(reason=msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
def get_managable_vf_list(self, session_info):
"""List of VFIDs that can be managed.
@ -291,11 +291,11 @@ class BrcdHTTPFCZoneClient(object):
zone_constant.MANAGEABLE_VF)
if vf_list:
vf_list = vf_list.split(",") # convert the string to list
except exception.BrocadeZoningHttpException as e:
except b_exception.BrocadeZoningHttpException as e:
msg = (_("Error while checking whether "
"VF is available for management %s.") % six.text_type(e))
LOG.error(msg)
raise exception.BrocadeZoningHttpException(reason=msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
return vf_list[:-1]
def change_vf_context(self, vfid, session_data):
@ -328,7 +328,7 @@ class BrcdHTTPFCZoneClient(object):
else:
msg = _("Cannot change VF context in the session.")
LOG.error(msg)
raise exception.BrocadeZoningHttpException(reason=msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
else:
msg = (_("Cannot change VF context, "
@ -336,11 +336,11 @@ class BrcdHTTPFCZoneClient(object):
"in the manageable VF list %(vf_list)s.")
% {'vf_list': managable_vf_list})
LOG.error(msg)
raise exception.BrocadeZoningHttpException(reason=msg)
except exception.BrocadeZoningHttpException as e:
raise b_exception.BrocadeZoningHttpException(reason=msg)
except b_exception.BrocadeZoningHttpException as e:
msg = (_("Error while changing VF context %s.") % six.text_type(e))
LOG.error(msg)
raise exception.BrocadeZoningHttpException(reason=msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
def get_zone_info(self):
"""Parse all the zone information and store it in the dictionary."""
@ -415,7 +415,7 @@ class BrcdHTTPFCZoneClient(object):
except Exception as e:
msg = (_("Error while changing VF context %s.") % six.text_type(e))
LOG.error(msg)
raise exception.BrocadeZoningHttpException(reason=msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
def is_supported_firmware(self):
"""Check firmware version is v6.4 or higher.
@ -453,7 +453,7 @@ class BrcdHTTPFCZoneClient(object):
msg = (_("Error while checking the firmware version %s.")
% six.text_type(e))
LOG.error(msg)
raise exception.BrocadeZoningHttpException(reason=msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
return isfwsupported
def get_active_zone_set(self):
@ -495,7 +495,7 @@ class BrcdHTTPFCZoneClient(object):
msg = (_("Failed getting active zone set from fabric %s.")
% six.text_type(e))
LOG.error(msg)
raise exception.BrocadeZoningHttpException(reason=msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
def add_zones(self, add_zones_info, activate, active_zone_set=None):
"""Add zone configuration.
@ -555,7 +555,7 @@ class BrcdHTTPFCZoneClient(object):
% {'err_code': error_code, 'err_msg': error_msg})
LOG.error(msg)
raise exception.BrocadeZoningHttpException(reason=msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
def update_zones(self, zone_info, activate, operation,
active_zone_set=None):
@ -612,7 +612,7 @@ class BrcdHTTPFCZoneClient(object):
% {'err_code': error_code, 'err_msg': error_msg})
LOG.error(msg)
raise exception.BrocadeZoningHttpException(reason=msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
def form_zone_string(self, cfgs, active_cfg,
zones, alias, qlps, ifas, activate):
@ -661,7 +661,7 @@ class BrcdHTTPFCZoneClient(object):
msg = (_("Exception while forming the zone string: %s.")
% six.text_type(e))
LOG.error(msg)
raise exception.BrocadeZoningHttpException(reason=msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
# Reconstruct the zoneString to type base string for OpenSSL
return encodeutils.safe_encode(zoneString)
@ -708,7 +708,7 @@ class BrcdHTTPFCZoneClient(object):
"in the zone string. Error %(description)s.")
% {'description': six.text_type(e)})
LOG.error(msg)
raise exception.BrocadeZoningHttpException(reason=msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
return zones, cfgs, active_cfg
def _update_zones(self, zones, updated_zones_info, operation):
@ -744,7 +744,7 @@ class BrcdHTTPFCZoneClient(object):
"in the zone string. Error %(description)s.")
% {'description': six.text_type(e)})
LOG.error(msg)
raise exception.BrocadeZoningHttpException(reason=msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
return zones
def is_vf_enabled(self):
@ -759,7 +759,7 @@ class BrcdHTTPFCZoneClient(object):
try:
is_vf_enabled = bool(self.get_nvp_value(
parsed_data, zone_constant.VF_ENABLED))
except exception.BrocadeZoningHttpException:
except b_exception.BrocadeZoningHttpException:
is_vf_enabled = False
parsed_data = None
return is_vf_enabled, parsed_data
@ -827,7 +827,7 @@ class BrcdHTTPFCZoneClient(object):
"in the zone string: %(description)s.")
% {'description': six.text_type(e)})
LOG.error(msg)
raise exception.BrocadeZoningHttpException(reason=msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
return zones, cfgs, active_cfg
def delete_zones(self, delete_zones_info, activate, active_zone_set=None):
@ -869,7 +869,7 @@ class BrcdHTTPFCZoneClient(object):
"(error code=%(err_code)s error msg=%(err_msg)s.")
% {'err_code': error_code, 'err_msg': error_msg})
LOG.error(msg)
raise exception.BrocadeZoningHttpException(reason=msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
def post_zone_data(self, data):
"""Send POST request to the switch with the payload.
@ -930,14 +930,14 @@ class BrcdHTTPFCZoneClient(object):
if self.vfid is None:
msg = _("No VF ID is defined in the configuration file.")
LOG.error(msg)
raise exception.BrocadeZoningHttpException(reason=msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
elif self.vfid != 128:
self.change_vf_context(self.vfid, session_data)
else:
if self.vfid is not None:
msg = _("VF is not enabled.")
LOG.error(msg)
raise exception.BrocadeZoningHttpException(reason=msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
def _disconnect(self):
"""Disconnect from the switch using HTTP/HTTPS protocol.
@ -957,8 +957,8 @@ class BrcdHTTPFCZoneClient(object):
'protocol': self.protocol,
'error': six.text_type(e)})
LOG.error(msg)
raise exception.BrocadeZoningHttpException(reason=msg)
except exception.BrocadeZoningHttpException as ex:
raise b_exception.BrocadeZoningHttpException(reason=msg)
except b_exception.BrocadeZoningHttpException as ex:
msg = (_("Unexpected status code from the switch %(switch_id)s "
"with protocol %(protocol)s for url %(page)s. "
"Error: %(error)s")
@ -967,7 +967,7 @@ class BrcdHTTPFCZoneClient(object):
'page': zone_constant.LOGOUT_PAGE,
'error': six.text_type(ex)})
LOG.error(msg)
raise exception.BrocadeZoningHttpException(reason=msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
def cleanup(self):
"""Close session."""

View File

@ -0,0 +1,27 @@
# 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.
from cinder import exception
from cinder.i18n import _
class BrocadeZoningCliException(exception.CinderException):
message = _("Brocade Fibre Channel Zoning CLI error: %(reason)s")
class BrocadeZoningHttpException(exception.CinderException):
message = _("Brocade Fibre Channel Zoning HTTP error: %(reason)s")
class BrocadeZoningRestException(exception.CinderException):
message = _("Brocade Fibre Channel Zoning REST error: %(reason)s")