move cisco zonemanager exception
This patch moves the cisco zonemanager exception to the new cisco/exception.py file. Change-Id: I632e5f986f58d6790d722aaa7c0a9fef2a42d29c
This commit is contained in:
parent
b8a41b8d42
commit
cf49fc7a90
@ -1033,10 +1033,6 @@ class ZoneManagerNotInitialized(CinderException):
|
||||
message = _("Fibre Channel Zone Manager not initialized")
|
||||
|
||||
|
||||
class CiscoZoningCliException(CinderException):
|
||||
message = _("Cisco Fibre Channel Zoning CLI error: %(reason)s")
|
||||
|
||||
|
||||
# ConsistencyGroup
|
||||
class ConsistencyGroupNotFound(NotFound):
|
||||
message = _("ConsistencyGroup %(consistencygroup_id)s could not be found.")
|
||||
|
@ -23,10 +23,10 @@ import mock
|
||||
from oslo_concurrency import processutils
|
||||
from six.moves import range
|
||||
|
||||
from cinder import exception
|
||||
from cinder import test
|
||||
from cinder.zonemanager.drivers.cisco \
|
||||
import cisco_fc_zone_client_cli as cli
|
||||
from cinder.zonemanager.drivers.cisco import exception as c_exception
|
||||
import cinder.zonemanager.drivers.cisco.fc_zone_constants as ZoneConstant
|
||||
|
||||
nsshow = '20:1a:00:05:1e:e8:e3:29'
|
||||
@ -147,7 +147,7 @@ class TestCiscoFCZoneClientCLI(cli.CiscoFCZoneClientCLI, test.TestCase):
|
||||
@mock.patch.object(cli.CiscoFCZoneClientCLI, '_run_ssh')
|
||||
def test_get_active_zone_set_ssh_error(self, run_ssh_mock):
|
||||
run_ssh_mock.side_effect = processutils.ProcessExecutionError
|
||||
self.assertRaises(exception.CiscoZoningCliException,
|
||||
self.assertRaises(c_exception.CiscoZoningCliException,
|
||||
self.get_active_zone_set)
|
||||
|
||||
@mock.patch.object(cli.CiscoFCZoneClientCLI, '_get_switch_info')
|
||||
@ -188,7 +188,7 @@ class TestCiscoFCZoneClientCLI(cli.CiscoFCZoneClientCLI, test.TestCase):
|
||||
@mock.patch.object(cli.CiscoFCZoneClientCLI, '_run_ssh')
|
||||
def test_get_nameserver_info_ssh_error(self, run_ssh_mock):
|
||||
run_ssh_mock.side_effect = processutils.ProcessExecutionError
|
||||
self.assertRaises(exception.CiscoZoningCliException,
|
||||
self.assertRaises(c_exception.CiscoZoningCliException,
|
||||
self.get_nameserver_info)
|
||||
|
||||
@mock.patch.object(cli.CiscoFCZoneClientCLI, '_run_ssh')
|
||||
|
@ -28,6 +28,7 @@ from cinder.i18n import _
|
||||
from cinder import ssh_utils
|
||||
from cinder import utils
|
||||
from cinder.zonemanager.drivers.cisco import cisco_fabric_opts as fabric_opts
|
||||
from cinder.zonemanager.drivers.cisco import exception as c_exception
|
||||
import cinder.zonemanager.drivers.cisco.fc_zone_constants as zone_constant
|
||||
from cinder.zonemanager import fc_san_lookup_service as fc_service
|
||||
from cinder.zonemanager import utils as zm_utils
|
||||
@ -207,7 +208,7 @@ class CiscoFCSanLookupService(fc_service.FCSanLookupService):
|
||||
"error=%(err)s).") % {'cmd': cmd_list,
|
||||
'err': six.text_type(e)}
|
||||
LOG.error(msg)
|
||||
raise exception.CiscoZoningCliException(reason=msg)
|
||||
raise c_exception.CiscoZoningCliException(reason=msg)
|
||||
|
||||
def _parse_ns_output(self, switch_data):
|
||||
"""Parses name server data.
|
||||
|
@ -31,6 +31,7 @@ from cinder import exception
|
||||
from cinder.i18n import _
|
||||
from cinder import ssh_utils
|
||||
from cinder import utils
|
||||
from cinder.zonemanager.drivers.cisco import exception as c_exception
|
||||
import cinder.zonemanager.drivers.cisco.fc_zone_constants as ZoneConstant
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -88,7 +89,7 @@ class CiscoFCZoneClientCLI(object):
|
||||
switch_data = self._get_switch_info(
|
||||
[ZoneConstant.GET_ACTIVE_ZONE_CFG, self.fabric_vsan,
|
||||
' | no-more'])
|
||||
except exception.CiscoZoningCliException:
|
||||
except c_exception.CiscoZoningCliException:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.error("Failed getting active zone set "
|
||||
"from fabric %s", self.switch_ip)
|
||||
@ -194,7 +195,7 @@ class CiscoFCZoneClientCLI(object):
|
||||
"(Zone set=%(zoneset)s error=%(err)s)."
|
||||
) % {'zoneset': cfg_name, 'err': six.text_type(e)}
|
||||
LOG.error(msg)
|
||||
raise exception.CiscoZoningCliException(reason=msg)
|
||||
raise c_exception.CiscoZoningCliException(reason=msg)
|
||||
|
||||
def update_zones(self, zones, activate, fabric_vsan, operation,
|
||||
active_zone_set, zone_status):
|
||||
@ -260,7 +261,7 @@ class CiscoFCZoneClientCLI(object):
|
||||
"(Zone set=%(zoneset)s error=%(err)s).")
|
||||
% {'zoneset': cfg_name, 'err': six.text_type(e)})
|
||||
LOG.error(msg)
|
||||
raise exception.CiscoZoningCliException(reason=msg)
|
||||
raise c_exception.CiscoZoningCliException(reason=msg)
|
||||
|
||||
def activate_zoneset(self, cfgname, fabric_vsan, zone_status):
|
||||
"""Method to Activate the zone config. Param cfgname - ZonesetName."""
|
||||
@ -284,7 +285,7 @@ class CiscoFCZoneClientCLI(object):
|
||||
try:
|
||||
switch_data = self._get_switch_info(
|
||||
[ZoneConstant.GET_ZONE_STATUS, self.fabric_vsan])
|
||||
except exception.CiscoZoningCliException:
|
||||
except c_exception.CiscoZoningCliException:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.error("Failed getting zone status "
|
||||
"from fabric %s", self.switch_ip)
|
||||
@ -350,7 +351,7 @@ class CiscoFCZoneClientCLI(object):
|
||||
msg = _("Deleting zones failed: (command=%(cmd)s error=%(err)s)."
|
||||
) % {'cmd': cmds, 'err': six.text_type(e)}
|
||||
LOG.error(msg)
|
||||
raise exception.CiscoZoningCliException(reason=msg)
|
||||
raise c_exception.CiscoZoningCliException(reason=msg)
|
||||
|
||||
def get_nameserver_info(self):
|
||||
"""Get name server data from fabric.
|
||||
@ -365,7 +366,7 @@ class CiscoFCZoneClientCLI(object):
|
||||
try:
|
||||
cli_output = self._get_switch_info([ZoneConstant.FCNS_SHOW,
|
||||
self.fabric_vsan])
|
||||
except exception.CiscoZoningCliException:
|
||||
except c_exception.CiscoZoningCliException:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.error("Failed collecting fcns database "
|
||||
"info for fabric %s", self.switch_ip)
|
||||
@ -395,7 +396,7 @@ class CiscoFCZoneClientCLI(object):
|
||||
"error=%(err)s).") % {'cmd': cmd_list,
|
||||
'err': six.text_type(e)}
|
||||
LOG.error(msg)
|
||||
raise exception.CiscoZoningCliException(reason=msg)
|
||||
raise c_exception.CiscoZoningCliException(reason=msg)
|
||||
|
||||
def _parse_ns_output(self, switch_data):
|
||||
"""Parses name server data.
|
||||
|
@ -39,6 +39,7 @@ from cinder import exception
|
||||
from cinder.i18n import _
|
||||
from cinder import interface
|
||||
from cinder.zonemanager.drivers.cisco import cisco_fabric_opts as fabric_opts
|
||||
from cinder.zonemanager.drivers.cisco import exception as c_exception
|
||||
from cinder.zonemanager.drivers.cisco import fc_zone_constants as ZoneConstant
|
||||
from cinder.zonemanager.drivers import driver_utils
|
||||
from cinder.zonemanager.drivers import fc_zone_driver
|
||||
@ -267,7 +268,7 @@ class CiscoFCZoneDriver(fc_zone_driver.FCZoneDriver):
|
||||
cfgmap_from_fabric,
|
||||
statusmap_from_fabric)
|
||||
conn.cleanup()
|
||||
except exception.CiscoZoningCliException as cisco_ex:
|
||||
except c_exception.CiscoZoningCliException as cisco_ex:
|
||||
msg = _("Exception: %s") % six.text_type(cisco_ex)
|
||||
raise exception.FCZoneDriverException(msg)
|
||||
except Exception:
|
||||
@ -498,7 +499,7 @@ class CiscoFCZoneDriver(fc_zone_driver.FCZoneDriver):
|
||||
LOG.debug("show fcns database info from fabric: %s",
|
||||
nsinfo)
|
||||
conn.cleanup()
|
||||
except exception.CiscoZoningCliException:
|
||||
except c_exception.CiscoZoningCliException:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.exception("Error getting show fcns database info.")
|
||||
except Exception:
|
||||
|
19
cinder/zonemanager/drivers/cisco/exception.py
Normal file
19
cinder/zonemanager/drivers/cisco/exception.py
Normal file
@ -0,0 +1,19 @@
|
||||
# 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 CiscoZoningCliException(exception.CinderException):
|
||||
message = _("Cisco Fibre Channel Zoning CLI error: %(reason)s")
|
Loading…
x
Reference in New Issue
Block a user