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