Merge "Remove six from zonemanager module"

This commit is contained in:
Zuul 2024-05-17 22:30:51 +00:00 committed by Gerrit Code Review
commit c043681eb4
8 changed files with 53 additions and 77 deletions

View File

@ -26,7 +26,6 @@ from eventlet import greenthread
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 _
@ -195,7 +194,7 @@ class BrcdFCZoneClientCLI(object):
self._cfg_trans_abort()
msg = _("Creating and activating zone set failed: "
"(Zone set=%(cfg_name)s error=%(err)s)."
) % {'cfg_name': cfg_name, 'err': six.text_type(e)}
) % {'cfg_name': cfg_name, 'err': str(e)}
LOG.error(msg)
raise b_exception.BrocadeZoningCliException(reason=msg)
@ -260,7 +259,7 @@ class BrcdFCZoneClientCLI(object):
self._cfg_trans_abort()
msg = _("Activating zone set failed: "
"(Zone set=%(cfg_name)s error=%(err)s)."
) % {'cfg_name': cfg_name, 'err': six.text_type(e)}
) % {'cfg_name': cfg_name, 'err': str(e)}
LOG.error(msg)
raise b_exception.BrocadeZoningCliException(reason=msg)
@ -314,7 +313,7 @@ class BrcdFCZoneClientCLI(object):
self._cfg_save()
except Exception as e:
msg = _("Deleting zones failed: (command=%(cmd)s error=%(err)s)."
) % {'cmd': cmd, 'err': six.text_type(e)}
) % {'cmd': cmd, 'err': str(e)}
LOG.error(msg)
self._cfg_trans_abort()
raise b_exception.BrocadeZoningCliException(reason=msg)
@ -410,7 +409,7 @@ class BrcdFCZoneClientCLI(object):
return False
except processutils.ProcessExecutionError as e:
msg = _("Error while getting data via ssh: (command=%(cmd)s "
"error=%(err)s).") % {'cmd': cmd, 'err': six.text_type(e)}
"error=%(err)s).") % {'cmd': cmd, 'err': str(e)}
LOG.error(msg)
raise b_exception.BrocadeZoningCliException(reason=msg)
@ -424,7 +423,7 @@ class BrcdFCZoneClientCLI(object):
except processutils.ProcessExecutionError as e:
msg = _("Error while getting data via ssh: (command=%(cmd)s "
"error=%(err)s).") % {'cmd': cmd_list,
'err': six.text_type(e)}
'err': str(e)}
LOG.error(msg)
raise b_exception.BrocadeZoningCliException(reason=msg)

View File

@ -34,7 +34,6 @@ from oslo_config import cfg
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 _
@ -475,7 +474,7 @@ class BrcdFCZoneDriver(fc_zone_driver.FCZoneDriver):
LOG.exception("Error getting name server info.")
except Exception as e:
msg = (_("Failed to retrieve active zoning configuration %s")
% six.text_type(e))
% str(e))
LOG.error(msg)
raise exception.FCZoneDriverException(msg)
LOG.debug("Active zone set from fabric: %(cfgmap)s",

View File

@ -24,7 +24,6 @@ from oslo_log import log as logging
from oslo_serialization import base64
from oslo_utils import encodeutils
import requests
import six
from cinder.i18n import _
from cinder.zonemanager.drivers.brocade import exception as b_exception
@ -125,7 +124,7 @@ class BrcdHTTPFCZoneClient(object):
"with protocol %(protocol)s. Error: %(error)s.")
% {'switch_id': self.switch_ip,
'protocol': self.protocol,
'error': six.text_type(e)})
'error': str(e)})
LOG.error(msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
except b_exception.BrocadeZoningHttpException as ex:
@ -135,7 +134,7 @@ class BrcdHTTPFCZoneClient(object):
% {'switch_id': self.switch_ip,
'protocol': self.protocol,
'page': requestURL,
'error': six.text_type(ex)})
'error': str(ex)})
LOG.error(msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
@ -174,7 +173,7 @@ class BrcdHTTPFCZoneClient(object):
auth_token) # Build the proper header
except Exception as e:
msg = (_("Error while creating authentication token: %s")
% six.text_type(e))
% str(e))
LOG.error(msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
return auth_header
@ -219,7 +218,7 @@ class BrcdHTTPFCZoneClient(object):
raise b_exception.BrocadeZoningHttpException(reason=msg)
except Exception as e:
msg = (_("Error while authenticating with switch: %s.")
% six.text_type(e))
% str(e))
LOG.error(msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
@ -236,7 +235,7 @@ class BrcdHTTPFCZoneClient(object):
header=headers)
except Exception as e:
msg = (_("Error while getting session information %s.")
% six.text_type(e))
% str(e))
LOG.error(msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
return response
@ -255,7 +254,7 @@ class BrcdHTTPFCZoneClient(object):
end = data.index(delim2)
return data[start:end]
except ValueError as e:
msg = (_("Error while parsing the data: %s.") % six.text_type(e))
msg = (_("Error while parsing the data: %s.") % str(e))
LOG.error(msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
@ -273,7 +272,7 @@ class BrcdHTTPFCZoneClient(object):
end = temp.index("\n")
return (temp[:end].lstrip('= '))
except ValueError as e:
msg = (_("Error while getting nvp value: %s.") % six.text_type(e))
msg = (_("Error while getting nvp value: %s.") % str(e))
LOG.error(msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
@ -293,7 +292,7 @@ class BrcdHTTPFCZoneClient(object):
vf_list = vf_list.split(",") # convert the string to list
except b_exception.BrocadeZoningHttpException as e:
msg = (_("Error while checking whether "
"VF is available for management %s.") % six.text_type(e))
"VF is available for management %s.") % str(e))
LOG.error(msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
return vf_list[:-1]
@ -338,7 +337,7 @@ class BrcdHTTPFCZoneClient(object):
LOG.error(msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
except b_exception.BrocadeZoningHttpException as e:
msg = (_("Error while changing VF context %s.") % six.text_type(e))
msg = (_("Error while changing VF context %s.") % str(e))
LOG.error(msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
@ -413,7 +412,7 @@ class BrcdHTTPFCZoneClient(object):
else:
i = i + 1
except Exception as e:
msg = (_("Error while changing VF context %s.") % six.text_type(e))
msg = (_("Error while changing VF context %s.") % str(e))
LOG.error(msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
@ -451,7 +450,7 @@ class BrcdHTTPFCZoneClient(object):
except Exception as e:
msg = (_("Error while checking the firmware version %s.")
% six.text_type(e))
% str(e))
LOG.error(msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
return isfwsupported
@ -493,7 +492,7 @@ class BrcdHTTPFCZoneClient(object):
return active_zone_set
except Exception as e:
msg = (_("Failed getting active zone set from fabric %s.")
% six.text_type(e))
% str(e))
LOG.error(msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
@ -659,7 +658,7 @@ class BrcdHTTPFCZoneClient(object):
zoneString += zone_constant.ZONE_END_DELIM + saveonly
except Exception as e:
msg = (_("Exception while forming the zone string: %s.")
% six.text_type(e))
% str(e))
LOG.error(msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
# Reconstruct the zoneString to type base string for OpenSSL
@ -706,7 +705,7 @@ class BrcdHTTPFCZoneClient(object):
except Exception as e:
msg = (_("Error while updating the new zones and cfgs "
"in the zone string. Error %(description)s.")
% {'description': six.text_type(e)})
% {'description': str(e)})
LOG.error(msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
return zones, cfgs, active_cfg
@ -742,7 +741,7 @@ class BrcdHTTPFCZoneClient(object):
except Exception as e:
msg = (_("Error while updating the zones "
"in the zone string. Error %(description)s.")
% {'description': six.text_type(e)})
% {'description': str(e)})
LOG.error(msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
return zones
@ -825,7 +824,7 @@ class BrcdHTTPFCZoneClient(object):
except KeyError as e:
msg = (_("Error while removing the zones and cfgs "
"in the zone string: %(description)s.")
% {'description': six.text_type(e)})
% {'description': str(e)})
LOG.error(msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
return zones, cfgs, active_cfg
@ -955,7 +954,7 @@ class BrcdHTTPFCZoneClient(object):
"with protocol %(protocol)s. Error: %(error)s.")
% {'switch_id': self.switch_ip,
'protocol': self.protocol,
'error': six.text_type(e)})
'error': str(e)})
LOG.error(msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)
except b_exception.BrocadeZoningHttpException as ex:
@ -965,7 +964,7 @@ class BrcdHTTPFCZoneClient(object):
% {'switch_id': self.switch_ip,
'protocol': self.protocol,
'page': zone_constant.LOGOUT_PAGE,
'error': six.text_type(ex)})
'error': str(ex)})
LOG.error(msg)
raise b_exception.BrocadeZoningHttpException(reason=msg)

View File

@ -23,7 +23,6 @@ import json
from oslo_log import log as logging
from oslo_serialization import base64
import requests
import six
from cinder.i18n import _
from cinder.zonemanager.drivers.brocade import exception
@ -120,8 +119,7 @@ class BrcdRestFCZoneClient(object):
rest_constants.YANG,
rest_constants.AUTHORIZATION: auth}
else:
msg = (_("REST login failed: %s")
% six.text_type(response.text))
msg = (_("REST login failed: %s") % response.text)
LOG.error(msg)
raise exception.BrocadeZoningRestException(reason=msg)
return response.status_code
@ -131,8 +129,7 @@ class BrcdRestFCZoneClient(object):
if response.status_code == 204:
LOG.info("REST logout success")
else:
msg = (_("REST logout failed: %s")
% six.text_type(response.text))
msg = (_("REST logout failed: %s") % response.text)
LOG.error(msg)
raise exception.BrocadeZoningRestException(reason=msg)
@ -146,8 +143,7 @@ class BrcdRestFCZoneClient(object):
firmware_version = switch[rest_constants.FIRMWARE_VERSION]
LOG.info("REST firmware version: %s", firmware_version)
else:
msg = (_("REST get switch fw version failed: %s")
% six.text_type(response.text))
msg = (_("REST get switch fw version failed: %s") % response.text)
LOG.error(msg)
raise exception.BrocadeZoningRestException(reason=msg)
return firmware_version
@ -165,8 +161,7 @@ class BrcdRestFCZoneClient(object):
port_names.append(nsinfos[i][rest_constants.PORT_NAME])
i = i + 1
else:
msg = (_("REST get NS info failed: %s")
% six.text_type(response.text))
msg = (_("REST get NS info failed: %s") % response.text)
LOG.error(msg)
raise exception.BrocadeZoningRestException(reason=msg)
return port_names
@ -201,8 +196,7 @@ class BrcdRestFCZoneClient(object):
"active cfg: %(cfg_name)s, checksum: %(chksum)s",
{'cfg_name': active_cfg_name, 'chksum': checksum})
else:
msg = (_("REST get effective zoneset failed: %s")
% six.text_type(response.text))
msg = (_("REST get effective zoneset failed: %s") % response.text)
LOG.error(msg)
raise exception.BrocadeZoningRestException(reason=msg)
active_zone_set = {"active_zone_config": active_cfg_name,
@ -226,8 +220,7 @@ class BrcdRestFCZoneClient(object):
if response.status_code == 201:
LOG.info("REST create zone success: %s", zone_name)
else:
msg = (_("REST create zone failed: %s")
% six.text_type(response.text))
msg = (_("REST create zone failed: %s") % response.text)
LOG.error(msg)
raise exception.BrocadeZoningRestException(reason=msg)
# update the cfg with the new zones
@ -247,8 +240,7 @@ class BrcdRestFCZoneClient(object):
self._save_and_activate_cfg(checksum, activate,
active_cfg_name)
else:
msg = (_("REST cfg create failed: %s")
% six.text_type(response.text))
msg = (_("REST cfg create failed: %s") % response.text)
LOG.error(msg)
raise exception.BrocadeZoningRestException(reason=msg)
else:
@ -260,8 +252,7 @@ class BrcdRestFCZoneClient(object):
self._save_and_activate_cfg(checksum, activate,
active_cfg_name)
else:
msg = (_("REST cfg update failed: %s")
% six.text_type(response.text))
msg = (_("REST cfg update failed: %s") % response.text)
LOG.error(msg)
raise exception.BrocadeZoningRestException(reason=msg)
@ -290,8 +281,7 @@ class BrcdRestFCZoneClient(object):
if response.status_code == 204:
LOG.info("REST zone update success: %s", zone)
else:
msg = (_("REST zone update failed: %s")
% six.text_type(response.text))
msg = (_("REST zone update failed: %s") % response.text)
LOG.error(msg)
raise exception.BrocadeZoningRestException(reason=msg)
# save and activate the config changes
@ -307,8 +297,7 @@ class BrcdRestFCZoneClient(object):
if response.status_code == 204:
LOG.info("REST delete zone success: %s", zone)
else:
msg = (_("REST delete zone failed: %s")
% six.text_type(response.text))
msg = (_("REST delete zone failed: %s") % response.text)
LOG.error(msg)
raise exception.BrocadeZoningRestException(reason=msg)
# update the cfg removing the deleted zones
@ -324,8 +313,7 @@ class BrcdRestFCZoneClient(object):
if response.status_code == 204:
LOG.info("REST cfg disable success")
else:
msg = (_("REST cfg disable failed: %s")
% six.text_type(response.text))
msg = (_("REST cfg disable failed: %s") % response.text)
LOG.error(msg)
raise exception.BrocadeZoningRestException(reason=msg)
# delete the cfg
@ -334,8 +322,7 @@ class BrcdRestFCZoneClient(object):
if response.status_code == 204:
LOG.info("REST cfg delete success: %s", active_cfg_name)
else:
msg = (_("REST cfg delete failed: %s")
% six.text_type(response.text))
msg = (_("REST cfg delete failed: %s") % response.text)
LOG.error(msg)
raise exception.BrocadeZoningRestException(reason=msg)
checksum = self._get_checksum()
@ -355,8 +342,7 @@ class BrcdRestFCZoneClient(object):
self._save_and_activate_cfg(checksum, activate,
active_cfg_name)
else:
msg = (_("REST cfg update failed: %s")
% six.text_type(response.text))
msg = (_("REST cfg update failed: %s") % response.text)
LOG.error(msg)
raise exception.BrocadeZoningRestException(reason=msg)
@ -368,8 +354,7 @@ class BrcdRestFCZoneClient(object):
if response.status_code == 204:
LOG.info("REST cfg save success")
else:
msg = (_("REST cfg save failed: %s")
% six.text_type(response.text))
msg = (_("REST cfg save failed: %s") % response.text)
LOG.error(msg)
raise exception.BrocadeZoningRestException(reason=msg)
# if activate=true, then enable the cfg changes to effective cfg
@ -383,8 +368,7 @@ class BrcdRestFCZoneClient(object):
if response.status_code == 204:
LOG.info("REST cfg activate success: %s", active_cfg_name)
else:
msg = (_("REST cfg activate failed: %s")
% six.text_type(response.text))
msg = (_("REST cfg activate failed: %s") % response.text)
LOG.error(msg)
raise exception.BrocadeZoningRestException(reason=msg)
@ -399,8 +383,7 @@ class BrcdRestFCZoneClient(object):
checksum = effective_cfg[rest_constants.CHECKSUM]
LOG.info("REST get checksum success: %s", checksum)
else:
msg = (_("REST get checksum failed: %s")
% six.text_type(response.text))
msg = (_("REST get checksum failed: %s") % response.text)
LOG.error(msg)
raise exception.BrocadeZoningRestException(reason=msg)
return checksum

View File

@ -21,7 +21,6 @@ from eventlet import greenthread
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 _
@ -206,7 +205,7 @@ class CiscoFCSanLookupService(fc_service.FCSanLookupService):
except processutils.ProcessExecutionError as e:
msg = _("Error while getting data via ssh: (command=%(cmd)s "
"error=%(err)s).") % {'cmd': cmd_list,
'err': six.text_type(e)}
'err': str(e)}
LOG.error(msg)
raise c_exception.CiscoZoningCliException(reason=msg)
@ -255,7 +254,7 @@ class CiscoFCSanLookupService(fc_service.FCSanLookupService):
command,
check_exit_code=check_exit_code)
except Exception as e:
msg = _("Exception: %s") % six.text_type(e)
msg = _("Exception: %s") % str(e)
LOG.error(msg)
last_exception = e
greenthread.sleep(random.randint(20, 500) / 100.0)
@ -328,7 +327,7 @@ class CiscoFCSanLookupService(fc_service.FCSanLookupService):
else:
return True
except Exception as e:
msg = _("Exception: %s") % six.text_type(e)
msg = _("Exception: %s") % str(e)
LOG.error(msg)
last_exception = e
greenthread.sleep(random.randint(20, 500) / 100.0)
@ -348,7 +347,7 @@ class CiscoFCSanLookupService(fc_service.FCSanLookupService):
except Exception as e:
with excutils.save_and_reraise_exception():
msg = (_("Error executing command via ssh: %s") %
six.text_type(e))
str(e))
LOG.error(msg)
finally:
if stdin:

View File

@ -25,7 +25,6 @@ from eventlet import greenthread
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 _
@ -128,7 +127,7 @@ class CiscoFCZoneClientCLI(object):
) % {'switch': self.switch_ip,
'zone_config': switch_data}
LOG.error(msg)
exc_msg = _("Exception: %s") % six.text_type(ex)
exc_msg = _("Exception: %s") % str(ex)
LOG.error(exc_msg)
raise exception.FCZoneDriverException(reason=msg)
@ -193,7 +192,7 @@ class CiscoFCZoneClientCLI(object):
msg = _("Creating and activating zone set failed: "
"(Zone set=%(zoneset)s error=%(err)s)."
) % {'zoneset': cfg_name, 'err': six.text_type(e)}
) % {'zoneset': cfg_name, 'err': str(e)}
LOG.error(msg)
raise c_exception.CiscoZoningCliException(reason=msg)
@ -259,7 +258,7 @@ class CiscoFCZoneClientCLI(object):
msg = (_("Updating and activating zone set failed: "
"(Zone set=%(zoneset)s error=%(err)s).")
% {'zoneset': cfg_name, 'err': six.text_type(e)})
% {'zoneset': cfg_name, 'err': str(e)})
LOG.error(msg)
raise c_exception.CiscoZoningCliException(reason=msg)
@ -310,7 +309,7 @@ class CiscoFCZoneClientCLI(object):
) % {'switch': self.switch_ip,
'zone_status': switch_data}
LOG.error(msg)
exc_msg = _("Exception: %s") % six.text_type(ex)
exc_msg = _("Exception: %s") % str(ex)
LOG.error(exc_msg)
raise exception.FCZoneDriverException(reason=msg)
@ -349,7 +348,7 @@ class CiscoFCZoneClientCLI(object):
except Exception as e:
msg = _("Deleting zones failed: (command=%(cmd)s error=%(err)s)."
) % {'cmd': cmds, 'err': six.text_type(e)}
) % {'cmd': cmds, 'err': str(e)}
LOG.error(msg)
raise c_exception.CiscoZoningCliException(reason=msg)
@ -394,7 +393,7 @@ class CiscoFCZoneClientCLI(object):
except processutils.ProcessExecutionError as e:
msg = _("Error while getting data via ssh: (command=%(cmd)s "
"error=%(err)s).") % {'cmd': cmd_list,
'err': six.text_type(e)}
'err': str(e)}
LOG.error(msg)
raise c_exception.CiscoZoningCliException(reason=msg)

View File

@ -34,7 +34,6 @@ from oslo_config import cfg
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 _
@ -270,7 +269,7 @@ class CiscoFCZoneDriver(fc_zone_driver.FCZoneDriver):
statusmap_from_fabric)
conn.cleanup()
except c_exception.CiscoZoningCliException as cisco_ex:
msg = _("Exception: %s") % six.text_type(cisco_ex)
msg = _("Exception: %s") % str(cisco_ex)
raise exception.FCZoneDriverException(msg)
except Exception:
msg = _("Failed to add zoning configuration.")

View File

@ -34,7 +34,6 @@ detach operation.
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 _
@ -243,7 +242,7 @@ class ZoneManager(fc_common.FCCommon):
except Exception as e:
msg = _("Failed adding connection for fabric=%(fabric)s: "
"Error: %(err)s") % {'fabric': connected_fabric,
'err': six.text_type(e)}
'err': str(e)}
LOG.error(msg)
raise exception.ZoneManagerException(reason=msg)
@ -322,7 +321,7 @@ class ZoneManager(fc_common.FCCommon):
except Exception as e:
msg = _("Failed removing connection for fabric=%(fabric)s: "
"Error: %(err)s") % {'fabric': connected_fabric,
'err': six.text_type(e)}
'err': str(e)}
LOG.error(msg)
raise exception.ZoneManagerException(reason=msg)