client.add_zones(
zone_map, zone_activate,
cfgmap_from_fabric)
- client.cleanup()
except (exception.BrocadeZoningCliException,
exception.BrocadeZoningHttpException) as brocade_ex:
raise exception.FCZoneDriverException(brocade_ex)
msg = _("Failed to add zoning configuration.")
LOG.exception(msg)
raise exception.FCZoneDriverException(msg)
- LOG.debug("Zones added successfully: %(zonemap)s",
- {'zonemap': zone_map})
+ LOG.debug("Zones added successfully: %(zonemap)s",
+ {'zonemap': zone_map})
+ client.cleanup()
@lockutils.synchronized('brcd', 'fcfabric-', True)
def delete_connection(self, fabric, initiator_target_map, host_name=None,
conn.delete_zones(
zone_name_string, zone_activate,
cfgmap_from_fabric)
- conn.cleanup()
except (exception.BrocadeZoningCliException,
exception.BrocadeZoningHttpException) as brocade_ex:
raise exception.FCZoneDriverException(brocade_ex)
"configuration.")
LOG.exception(msg)
raise exception.FCZoneDriverException(msg)
+ finally:
+ conn.cleanup()
def get_san_context(self, target_wwn_list):
"""Lookup SAN context for visible end devices.
nsinfo = conn.get_nameserver_info()
LOG.debug("Name server info from fabric: %(nsinfo)s",
{'nsinfo': nsinfo})
- conn.cleanup()
except (exception.BrocadeZoningCliException,
exception.BrocadeZoningHttpException):
if not conn.is_supported_firmware():
msg = _("Failed to get name server info.")
LOG.exception(msg)
raise exception.FCZoneDriverException(msg)
+ finally:
+ conn.cleanup()
visible_targets = filter(
lambda x: x in formatted_target_list,
nsinfo)
LOG.error(msg)
raise exception.BrocadeZoningHttpException(reason=msg)
+ def _disconnect(self):
+ """Disconnect from the switch using HTTP/HTTPS protocol.
+
+ :raises: BrocadeZoningHttpException
+ """
+ try:
+ headers = {zone_constant.AUTH_HEADER: self.auth_header}
+ response = self.connect(zone_constant.GET_METHOD,
+ zone_constant.LOGOUT_PAGE,
+ header=headers)
+ return response
+ except requests.exceptions.ConnectionError as e:
+ msg = (_("Error while connecting the switch %(switch_id)s "
+ "with protocol %(protocol)s. Error: %(error)s.")
+ % {'switch_id': self.switch_ip,
+ 'protocol': self.protocol,
+ 'error': six.text_type(e)})
+ LOG.error(msg)
+ raise exception.BrocadeZoningHttpException(reason=msg)
+ except 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")
+ % {'switch_id': self.switch_ip,
+ 'protocol': self.protocol,
+ 'page': zone_constant.LOG_OUT_PAGE,
+ 'error': six.text_type(ex)})
+ LOG.error(msg)
+ raise exception.BrocadeZoningHttpException(reason=msg)
+
def cleanup(self):
"""Close session."""
+ self._disconnect()
self.session.close()