ignore_dirs = [
"cinder/db",
"cinder/openstack",
- "cinder/volume",
- "cinder/zonemanager"]
+ "cinder/volume"]
for directory in ignore_dirs:
if directory in filename:
return
fabric_configs = {}
for fabric_name in fabric_names:
config = configuration.Configuration(brcd_zone_opts, fabric_name)
- LOG.debug("Loaded FC fabric config %s" % fabric_name)
+ LOG.debug("Loaded FC fabric config %s", fabric_name)
fabric_configs[fabric_name] = config
return fabric_configs
from oslo_log import log as logging
from oslo_utils import excutils
import paramiko
+import six
from cinder import exception
from cinder.i18n import _, _LE
except exception.FCSanLookupServiceException:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Failed collecting name server info from"
- " fabric %s") % fabric_ip)
+ " fabric %s"), fabric_ip)
except Exception as e:
msg = _("SSH connection failed "
"for %(fabric)s with error: %(err)s"
switch_data = stdout.readlines()
except paramiko.SSHException as e:
msg = (_("SSH Command failed with error '%(err)s' "
- "'%(command)s'") % {'err': e,
+ "'%(command)s'") % {'err': six.text_type(e),
'command': cmd})
LOG.error(msg)
raise exception.FCSanLookupServiceException(message=msg)
from oslo_concurrency import processutils
from oslo_log import log as logging
from oslo_utils import excutils
+import six
from cinder import exception
from cinder.i18n import _, _LE
zone_member_list.append(zone_member)
zone_set[ZoneConstant.CFG_ZONES] = zone
zone_set[ZoneConstant.ACTIVE_ZONE_CONFIG] = zone_set_name
- except Exception as ex:
+ except Exception:
# Incase of parsing error here, it should be malformed cli output.
msg = _("Malformed zone configuration: (switch=%(switch)s "
"zone_config=%(zone_config)s)."
) % {'switch': self.switch_ip,
'zone_config': switch_data}
- LOG.error(msg)
- LOG.exception(ex)
+ LOG.exception(msg)
raise exception.FCZoneDriverException(reason=msg)
switch_data = None
return zone_set
zone_with_sep = ''
if not active_zone_set:
active_zone_set = self.get_active_zone_set()
- LOG.debug("Active zone set:%s", active_zone_set)
+ LOG.debug("Active zone set: %s", active_zone_set)
zone_list = active_zone_set[ZoneConstant.CFG_ZONES]
- LOG.debug("zone list:%s", zone_list)
+ LOG.debug("zone list: %s", zone_list)
for zone in zones.keys():
# if zone exists, its an update. Delete & insert
# TODO(skolathur): This can be optimized to an update call later
self._cfg_trans_abort()
msg = _("Creating and activating zone set failed: "
"(Zone set=%(cfg_name)s error=%(err)s)."
- ) % {'cfg_name': cfg_name, 'err': e}
+ ) % {'cfg_name': cfg_name, 'err': six.text_type(e)}
LOG.error(msg)
raise exception.BrocadeZoningCliException(reason=msg)
% {'active_zoneset_name': active_zoneset_name,
'zone_names': zone_names
}
- LOG.debug("Delete zones: Config cmd to run:%s", cmd)
+ LOG.debug("Delete zones: Config cmd to run: %s", cmd)
self.apply_zone_change(cmd.split())
for zone in zones:
self._zone_delete(zone)
self._cfg_save()
except Exception as e:
msg = _("Deleting zones failed: (command=%(cmd)s error=%(err)s)."
- ) % {'cmd': cmd, 'err': e}
+ ) % {'cmd': cmd, 'err': six.text_type(e)}
LOG.error(msg)
self._cfg_trans_abort()
raise exception.BrocadeZoningCliException(reason=msg)
if (stdout):
for line in stdout:
if 'Fabric OS: v' in line:
- LOG.debug("Firmware version string:%s", line)
+ LOG.debug("Firmware version string: %s", line)
ver = line.split('Fabric OS: v')[1].split('.')
if (ver):
firmware = int(ver[0] + ver[1])
return False
except processutils.ProcessExecutionError as e:
msg = _("Error while getting data via ssh: (command=%(cmd)s "
- "error=%(err)s).") % {'cmd': cmd, 'err': e}
+ "error=%(err)s).") % {'cmd': cmd, 'err': six.text_type(e)}
LOG.error(msg)
raise exception.BrocadeZoningCliException(reason=msg)
except processutils.ProcessExecutionError as e:
msg = _("Error while getting data via ssh: (command=%(cmd)s "
"error=%(err)s).") % {'cmd': cmd_list,
- 'err': e}
+ 'err': six.text_type(e)}
LOG.error(msg)
raise exception.BrocadeZoningCliException(reason=msg)
command,
check_exit_code=check_exit_code)
except Exception as e:
- LOG.error(e)
+ LOG.exception(_LE('Error executing SSH command.'))
last_exception = e
greenthread.sleep(random.randint(20, 500) / 100.0)
try:
cmd=command)
except Exception:
with excutils.save_and_reraise_exception():
- LOG.error(_LE("Error running SSH command: %s") % command)
+ LOG.error(_LE("Error running SSH command: %s"), command)
def _ssh_execute(self, cmd_list, check_exit_code=True, attempts=1):
"""Execute cli with status update.
min_size=1,
max_size=5)
stdin, stdout, stderr = None, None, None
- LOG.debug("Executing command via ssh: %s" % command)
+ LOG.debug("Executing command via ssh: %s", command)
last_exception = None
try:
with self.sshpool.item() as ssh:
stdin.write("%s\n" % ZoneConstant.YES)
channel = stdout.channel
exit_status = channel.recv_exit_status()
- LOG.debug("Exit Status from ssh:%s", exit_status)
+ LOG.debug("Exit Status from ssh: %s", exit_status)
# exit_status == -1 if no exit code was returned
if exit_status != -1:
- LOG.debug('Result was %s' % exit_status)
+ LOG.debug('Result was %s', exit_status)
if check_exit_code and exit_status != 0:
raise processutils.ProcessExecutionError(
exit_code=exit_status,
else:
return True
except Exception as e:
- LOG.error(e)
+ LOG.exception(_LE('Error executing SSH command.'))
last_exception = e
greenthread.sleep(random.randint(20, 500) / 100.0)
LOG.debug("Handling error case after "
- "SSH:%s", last_exception)
+ "SSH: %s", last_exception)
try:
raise processutils.ProcessExecutionError(
exit_code=last_exception.exit_code,
min_size=1,
max_size=5)
with self.sshpool.item() as ssh:
- LOG.debug('Running cmd (SSH): %s' % command)
+ LOG.debug('Running cmd (SSH): %s', command)
channel = ssh.invoke_shell()
stdin_stream = channel.makefile('wb')
stdout_stream = channel.makefile('rb')
exit_status = channel.recv_exit_status()
# exit_status == -1 if no exit code was returned
if exit_status != -1:
- LOG.debug('Result was %s' % exit_status)
+ LOG.debug('Result was %s', exit_status)
if exit_status != 0:
- msg = "command %s failed" % command
- LOG.debug(msg)
+ LOG.debug("command %s failed", command)
raise processutils.ProcessExecutionError(
exit_code=exit_status,
stdout=stdout,
cmd=command)
try:
channel.close()
- except Exception as e:
- LOG.exception(e)
- LOG.debug("_execute_cmd: stderr to return:%s" % stderr)
+ except Exception:
+ LOG.exception(_LE('Error closing channel.'))
+ LOG.debug("_execute_cmd: stderr to return: %s", stderr)
return (stdout, stderr)
def cleanup(self):
from oslo_log import log as logging
from oslo_utils import excutils
from oslo_utils import importutils
+import six
from cinder import exception
from cinder.i18n import _, _LE, _LI
:param fabric: Fabric name from cinder.conf file
:param initiator_target_map: Mapping of initiator to list of targets
"""
- LOG.debug("Add connection for Fabric:%s", fabric)
+ LOG.debug("Add connection for Fabric: %s", fabric)
LOG.info(_LI("BrcdFCZoneDriver - Add connection "
"for I-T map: %s"), initiator_target_map)
zoning_policy = self.configuration.zoning_policy
cli_client.cleanup()
except exception.BrocadeZoningCliException as brocade_ex:
raise exception.FCZoneDriverException(brocade_ex)
- except Exception as e:
- LOG.error(e)
- msg = _("Failed to add zoning configuration %s") % e
+ except Exception:
+ msg = _("Failed to add zoning configuration.")
+ LOG.exception(msg)
raise exception.FCZoneDriverException(msg)
LOG.debug("Zones added successfully: %s", zone_map)
:param fabric: Fabric name from cinder.conf file
:param initiator_target_map: Mapping of initiator to list of targets
"""
- LOG.debug("Delete connection for fabric:%s", fabric)
+ LOG.debug("Delete connection for fabric: %s", fabric)
LOG.info(_LI("BrcdFCZoneDriver - Delete connection for I-T map: %s"),
initiator_target_map)
zoning_policy = self.configuration.zoning_policy
# to it and update zone if filtered list is empty, we
# remove that zone.
LOG.debug("Zone delete - I mode: "
- "filtered targets:%s", filtered_members)
+ "filtered targets: %s", filtered_members)
if filtered_members:
filtered_members.append(formatted_initiator)
LOG.debug("Filtered zone members to "
'%s%s' % (
zone_name_string, zones_to_delete[i]))
else:
- zone_name_string = '%s%s%s' % (
- zone_name_string, ';', zones_to_delete[i])
+ zone_name_string = '%s;%s' % (
+ zone_name_string, zones_to_delete[i])
conn.delete_zones(
zone_name_string, zone_activate,
cfgmap_from_fabric)
conn.cleanup()
- except Exception as e:
- LOG.error(e)
+ except Exception:
msg = _("Failed to update or delete zoning configuration")
+ LOG.exception(msg)
raise exception.FCZoneDriverException(msg)
def get_san_context(self, target_wwn_list):
nsinfo = None
try:
nsinfo = conn.get_nameserver_info()
- LOG.debug("name server info from fabric:%s", nsinfo)
+ LOG.debug("name server info from fabric: %s", nsinfo)
conn.cleanup()
- except exception.BrocadeZoningCliException as ex:
+ except exception.BrocadeZoningCliException:
if not conn.is_supported_firmware():
msg = _("Unsupported firmware on switch %s. Make sure "
"switch is running firmware v6.4 or higher"
LOG.error(msg)
raise exception.FCZoneDriverException(msg)
with excutils.save_and_reraise_exception():
- LOG.error(_LE("Error getting name server "
- "info: %s"), ex)
- except Exception as e:
- msg = (_("Failed to get name server info:%s") % e)
- LOG.error(msg)
+ LOG.exception(_LE("Error getting name server info."))
+ except Exception:
+ msg = _("Failed to get name server info.")
+ LOG.exception(msg)
raise exception.FCZoneDriverException(msg)
visible_targets = filter(
lambda x: x in formatted_target_list,
else:
LOG.debug("No targets are in the nameserver for SAN %s",
fabric_name)
- LOG.debug("Return SAN context output:%s", fabric_map)
+ LOG.debug("Return SAN context output: %s", fabric_map)
return fabric_map
def _get_active_zone_set(self, conn):
LOG.error(msg)
raise exception.FCZoneDriverException(msg)
except Exception as e:
- LOG.error(e)
- msg = _("Failed to retrieve active zoning configuration %s") % e
+ msg = (_("Failed to retrieve active zoning configuration %s")
+ % six.text_type(e))
raise exception.FCZoneDriverException(msg)
LOG.debug("Active zone set from fabric: %s", cfgmap)
return cfgmap
stdout, stderr, sw_data = None, None, None
try:
stdout, stderr = self._run_ssh(cmd_list, True, 1)
- LOG.debug("CLI output from ssh - output:%s", stdout)
+ LOG.debug("CLI output from ssh - output: %s", stdout)
if (stdout):
sw_data = stdout.splitlines()
return sw_data
cmd=command)
except Exception:
with excutils.save_and_reraise_exception():
- LOG.error(_LE("Error running SSH command: %s") % command)
+ LOG.error(_LE("Error running SSH command: %s"), command)
def _ssh_execute(self, cmd_list, check_exit_code=True, attempts=1):
"""Execute cli with status update.
min_size=1,
max_size=5)
stdin, stdout, stderr = None, None, None
- LOG.debug("Executing command via ssh: %s" % command)
+ LOG.debug("Executing command via ssh: %s", command)
last_exception = None
try:
with self.sshpool.item() as ssh:
LOG.debug("Exit Status from ssh:%s", exit_status)
# exit_status == -1 if no exit code was returned
if exit_status != -1:
- LOG.debug('Result was %s' % exit_status)
+ LOG.debug('Result was %s', exit_status)
if check_exit_code and exit_status != 0:
raise processutils.ProcessExecutionError(
exit_code=exit_status,
'zone_config': switch_data}
LOG.error(msg)
exc_msg = _("Exception: %s") % six.text_type(ex)
- LOG.exception(exc_msg)
+ LOG.error(exc_msg)
raise exception.FCZoneDriverException(reason=msg)
return zone_set
"""
LOG.debug("Add Zones - Zones passed: %s", zones)
- LOG.debug("Active zone set:%s", active_zone_set)
+ LOG.debug("Active zone set: %s", active_zone_set)
zone_list = active_zone_set[ZoneConstant.CFG_ZONES]
- LOG.debug("zone list:%s", zone_list)
- LOG.debug("zone status:%s", zone_status)
+ LOG.debug("zone list: %s", zone_list)
+ LOG.debug("zone status: %s", zone_status)
cfg_name = active_zone_set[ZoneConstant.ACTIVE_ZONE_CONFIG]
zone_cmds.append(['end'])
try:
- LOG.debug("Add zones: Config cmd to run:%s", zone_cmds)
+ LOG.debug("Add zones: Config cmd to run: %s", zone_cmds)
self._ssh_execute(zone_cmds, True, 1)
if activate:
def activate_zoneset(self, cfgname, fabric_vsan, zone_status):
"""Method to Activate the zone config. Param cfgname - ZonesetName."""
- LOG.debug("zone status:%s", zone_status)
+ LOG.debug("zone status: %s", zone_status)
cmd_list = [['conf'],
['zoneset', 'activate', 'name', cfgname, 'vsan',
'zone_status': switch_data}
LOG.error(msg)
exc_msg = _("Exception: %s") % six.text_type(ex)
- LOG.exception(exc_msg)
+ LOG.error(exc_msg)
raise exception.FCZoneDriverException(reason=msg)
return zone_status
cmds.append(['end'])
- LOG.debug("Delete zones: Config cmd to run:%s", cmds)
+ LOG.debug("Delete zones: Config cmd to run: %s", cmds)
self._ssh_execute(cmds, True, 1)
if activate:
stdout, stderr, sw_data = None, None, None
try:
stdout, stderr = self._run_ssh(cmd_list, True, 1)
- LOG.debug("CLI output from ssh - output:%s", stdout)
+ LOG.debug("CLI output from ssh - output: %s", stdout)
if (stdout):
sw_data = stdout.splitlines()
return sw_data
cmd=command)
except Exception:
with excutils.save_and_reraise_exception():
- LOG.error(_LE("Error running SSH command: %s") % command)
+ LOG.error(_LE("Error running SSH command: %s"), command)
def _ssh_execute(self, cmd_list, check_exit_code=True, attempts=1):
"""Execute cli with status update.
min_size=1,
max_size=5)
stdin, stdout, stderr = None, None, None
- LOG.debug("Executing command via ssh: %s" % command)
+ LOG.debug("Executing command via ssh: %s", command)
last_exception = None
try:
with self.sshpool.item() as ssh:
greenthread.sleep(random.randint(20, 500) / 100.0)
channel = stdout.channel
exit_status = channel.recv_exit_status()
- LOG.debug("Exit Status from ssh:%s", exit_status)
+ LOG.debug("Exit Status from ssh: %s", exit_status)
# exit_status == -1 if no exit code was returned
if exit_status != -1:
- LOG.debug('Result was %s' % exit_status)
+ LOG.debug('Result was %s', exit_status)
if check_exit_code and exit_status != 0:
raise processutils.ProcessExecutionError(
exit_code=exit_status,
else:
return True
except Exception as e:
- msg = _("Exception: %s") % six.text_type(e)
- LOG.error(msg)
+ LOG.exception(_LE('Error executing SSH command.'))
last_exception = e
greenthread.sleep(random.randint(20, 500) / 100.0)
- LOG.debug("Handling error case after SSH:%s", last_exception)
+ LOG.debug("Handling error case after SSH: %s", last_exception)
try:
raise processutils.ProcessExecutionError(
exit_code=last_exception.exit_code,
stdout="",
stderr="Error running SSH command",
cmd=command)
- except Exception as e:
+ except Exception:
with excutils.save_and_reraise_exception():
- msg = (_("Error executing command via ssh: %s") %
- six.text_type(e))
- LOG.error(msg)
+ LOG.exception(_LE("Error executing command via ssh."))
finally:
if stdin:
stdin.flush()
:param initiator_target_map: Mapping of initiator to list of targets
"""
- LOG.debug("Add connection for Fabric:%s", fabric)
+ LOG.debug("Add connection for Fabric: %s", fabric)
LOG.info(_LI("CiscoFCZoneDriver - Add connection "
"for I-T map: %s"), initiator_target_map)
fabric_ip = self.fabric_configs[fabric].safe_get(
except exception.CiscoZoningCliException as cisco_ex:
msg = _("Exception: %s") % six.text_type(cisco_ex)
raise exception.FCZoneDriverException(msg)
- except Exception as e:
- LOG.error(_LE("Exception: %s") % six.text_type(e))
- msg = (_("Failed to add zoning configuration %s") %
- six.text_type(e))
+ except Exception:
+ msg = _("Failed to add zoning configuration.")
+ LOG.exception(msg)
raise exception.FCZoneDriverException(msg)
LOG.debug("Zones added successfully: %s", zone_map)
else:
:param fabric: Fabric name from cinder.conf file
:param initiator_target_map: Mapping of initiator to list of targets
"""
- LOG.debug("Delete connection for fabric:%s", fabric)
+ LOG.debug("Delete connection for fabric: %s", fabric)
LOG.info(_LI("CiscoFCZoneDriver - Delete connection for I-T map: %s"),
initiator_target_map)
fabric_ip = self.fabric_configs[fabric].safe_get(
# We find the filtered list and if it is non-empty,
# add initiator to it and update zone if filtered
# list is empty, we remove that zone.
- LOG.debug("Zone delete - I mode: filtered targets:%s",
+ LOG.debug("Zone delete - I mode: filtered targets: %s",
filtered_members)
if filtered_members:
filtered_members.append(formatted_initiator)
zoning_vsan, cfgmap_from_fabric,
statusmap_from_fabric)
conn.cleanup()
- except Exception as e:
- msg = _("Exception: %s") % six.text_type(e)
- LOG.error(msg)
+ except Exception:
msg = _("Failed to update or delete zoning configuration")
+ LOG.exception(msg)
raise exception.FCZoneDriverException(msg)
LOG.debug("Zones deleted successfully: %s", zone_map)
else:
password=fabric_pwd, port=fabric_port,
vsan=zoning_vsan)
nsinfo = conn.get_nameserver_info()
- LOG.debug("show fcns database info from fabric:%s", nsinfo)
+ LOG.debug("show fcns database info from fabric: %s",
+ nsinfo)
conn.cleanup()
- except exception.CiscoZoningCliException as ex:
+ except exception.CiscoZoningCliException:
with excutils.save_and_reraise_exception():
- LOG.error(_LE("Error getting show fcns database "
- "info: %s"), six.text_type(ex))
- except Exception as e:
- msg = (_("Failed to get show fcns database info:%s") %
- six.text_type(e))
- LOG.error(msg)
+ LOG.exception(_LE("Error getting show fcns database "
+ "info."))
+ except Exception:
+ msg = _("Failed to get show fcns database info.")
+ LOG.exception(msg)
raise exception.FCZoneDriverException(msg)
visible_targets = filter(
lambda x: x in formatted_target_list, nsinfo)
else:
LOG.debug("No targets are in the fcns info for SAN %s",
fabric_name)
- LOG.debug("Return SAN context output:%s", fabric_map)
+ LOG.debug("Return SAN context output: %s", fabric_map)
return fabric_map
def get_active_zone_set(self, fabric_ip,
password=fabric_pwd, port=fabric_port, vsan=zoning_vsan)
cfgmap = conn.get_active_zone_set()
conn.cleanup()
- except Exception as e:
- msg = (_("Failed to access active zoning configuration:%s") %
- six.text_type(e))
- LOG.error(msg)
+ except Exception:
+ msg = _("Failed to access active zoning configuration.")
+ LOG.exception(msg)
raise exception.FCZoneDriverException(msg)
LOG.debug("Active zone set from fabric: %s", cfgmap)
return cfgmap
password=fabric_pwd, port=fabric_port, vsan=zoning_vsan)
statusmap = conn.get_zoning_status()
conn.cleanup()
- except Exception as e:
- msg = (_("Failed to access zoneset status:%s") %
- six.text_type(e))
- LOG.error(msg)
+ except Exception:
+ msg = _("Failed to access zoneset status:%s")
+ LOG.exception(msg)
raise exception.FCZoneDriverException(msg)
LOG.debug("Zoneset status from fabric: %s", statusmap)
return statusmap
from oslo_utils import importutils
from cinder import exception
-from cinder.i18n import _
+from cinder.i18n import _, _LE
from cinder.volume import configuration as config
from cinder.zonemanager import fc_common
from cinder.zonemanager import fc_zone_manager
device_map = self.lookup_service.get_device_mapping_from_network(
initiator_list, target_list)
except Exception as e:
- LOG.error(e)
+ LOG.exception(_LE('Unable to get device mapping from network.'))
raise exception.FCSanLookupServiceException(e)
return device_map
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import importutils
+import six
from cinder import exception
from cinder.i18n import _, _LI
except Exception as e:
msg = _("Failed adding connection for fabric=%(fabric)s: "
"Error: %(err)s") % {'fabric': connected_fabric,
- 'err': e}
+ 'err': six.text_type(e)}
LOG.error(msg)
raise exception.ZoneManagerException(reason=msg)
except Exception as e:
msg = _("Failed removing connection for fabric=%(fabric)s: "
"Error: %(err)s") % {'fabric': connected_fabric,
- 'err': e}
+ 'err': six.text_type(e)}
LOG.error(msg)
raise exception.ZoneManagerException(reason=msg)
def decorator(self, *args, **kwargs):
conn_info = initialize_connection(self, *args, **kwargs)
if not conn_info:
- LOG.warn(_LW("Driver didn't return connection info, "
- "can't add zone."))
+ LOG.warning(_LW("Driver didn't return connection info, "
+ "can't add zone."))
return None
vol_type = conn_info.get('driver_volume_type', None)
def decorator(self, *args, **kwargs):
conn_info = terminate_connection(self, *args, **kwargs)
if not conn_info:
- LOG.warn(_LW("Driver didn't return connection info from "
- "terminate_connection call."))
+ LOG.warning(_LW("Driver didn't return connection info from "
+ "terminate_connection call."))
return None
vol_type = conn_info.get('driver_volume_type', None)