Remove six of dir cinder/volume/*
Replace the following items with Python 3 style code. - six.add_metaclass - six.PY3 - six.text_type - six.string_types - six.integer_types Change-Id: Ifc3484ef0897d25c3a5ed3c10efe4312dbbbd384 Implements: blueprint six-removal
This commit is contained in:
parent
6ad1ab0c72
commit
e02d909439
|
@ -27,7 +27,6 @@ from oslo_utils import excutils
|
||||||
from oslo_utils import strutils
|
from oslo_utils import strutils
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
from oslo_utils import versionutils
|
from oslo_utils import versionutils
|
||||||
import six
|
|
||||||
|
|
||||||
from cinder.api import common
|
from cinder.api import common
|
||||||
from cinder.common import constants
|
from cinder.common import constants
|
||||||
|
@ -619,7 +618,7 @@ class API(base.Base):
|
||||||
filters['no_migration_targets'] = True
|
filters['no_migration_targets'] = True
|
||||||
|
|
||||||
if filters:
|
if filters:
|
||||||
LOG.debug("Searching by: %s.", six.text_type(filters))
|
LOG.debug("Searching by: %s.", filters)
|
||||||
|
|
||||||
if context.is_admin and allTenants:
|
if context.is_admin and allTenants:
|
||||||
# Need to remove all_tenants to pass the filtering below.
|
# Need to remove all_tenants to pass the filtering below.
|
||||||
|
@ -1407,7 +1406,7 @@ class API(base.Base):
|
||||||
"to extend, currently %(status)s.")
|
"to extend, currently %(status)s.")
|
||||||
% {'vol_id': volume.id,
|
% {'vol_id': volume.id,
|
||||||
'status': volume.status,
|
'status': volume.status,
|
||||||
'expected': six.text_type(expected)})
|
'expected': str(expected)})
|
||||||
raise exception.InvalidVolume(reason=msg)
|
raise exception.InvalidVolume(reason=msg)
|
||||||
|
|
||||||
rollback = True
|
rollback = True
|
||||||
|
@ -1626,7 +1625,7 @@ class API(base.Base):
|
||||||
'vol_status': volume['status']}
|
'vol_status': volume['status']}
|
||||||
raise exception.InvalidVolume(reason=msg)
|
raise exception.InvalidVolume(reason=msg)
|
||||||
self.update_volume_admin_metadata(context.elevated(), volume,
|
self.update_volume_admin_metadata(context.elevated(), volume,
|
||||||
{'readonly': six.text_type(flag)})
|
{'readonly': str(flag)})
|
||||||
LOG.info("Update readonly setting on volume "
|
LOG.info("Update readonly setting on volume "
|
||||||
"completed successfully.",
|
"completed successfully.",
|
||||||
resource=volume)
|
resource=volume)
|
||||||
|
@ -1934,7 +1933,7 @@ class API(base.Base):
|
||||||
def _replication_db_change(self, ctxt, field, expected_value, new_value,
|
def _replication_db_change(self, ctxt, field, expected_value, new_value,
|
||||||
host, cluster_name, check_up=False):
|
host, cluster_name, check_up=False):
|
||||||
def _error_msg(service):
|
def _error_msg(service):
|
||||||
expected = utils.build_or_str(six.text_type(expected_value))
|
expected = utils.build_or_str(str(expected_value))
|
||||||
up_msg = 'and must be up ' if check_up else ''
|
up_msg = 'and must be up ' if check_up else ''
|
||||||
msg = (_('%(field)s in %(service)s must be %(expected)s '
|
msg = (_('%(field)s in %(service)s must be %(expected)s '
|
||||||
'%(up_msg)sto failover.')
|
'%(up_msg)sto failover.')
|
||||||
|
|
|
@ -24,7 +24,6 @@ from oslo_config import cfg
|
||||||
from oslo_config import types
|
from oslo_config import types
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_utils import excutils
|
from oslo_utils import excutils
|
||||||
import six
|
|
||||||
|
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
|
@ -357,8 +356,7 @@ CONF.register_opts(fqdn_opts, group=configuration.SHARED_CONF_GROUP)
|
||||||
CONF.import_opt('backup_use_same_host', 'cinder.backup.api')
|
CONF.import_opt('backup_use_same_host', 'cinder.backup.api')
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class BaseVD(object, metaclass=abc.ABCMeta):
|
||||||
class BaseVD(object):
|
|
||||||
"""Executes commands relating to Volumes.
|
"""Executes commands relating to Volumes.
|
||||||
|
|
||||||
Base Driver for Cinder Volume Control Path,
|
Base Driver for Cinder Volume Control Path,
|
||||||
|
@ -1046,15 +1044,13 @@ class BaseVD(object):
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
try:
|
try:
|
||||||
err_msg = (_('Unable to fetch connection information from '
|
err_msg = (_('Unable to fetch connection information from '
|
||||||
'backend: %(err)s') %
|
'backend: %(err)s') % {'err': err})
|
||||||
{'err': six.text_type(err)})
|
|
||||||
LOG.error(err_msg)
|
LOG.error(err_msg)
|
||||||
LOG.debug("Cleaning up failed connect initialization.")
|
LOG.debug("Cleaning up failed connect initialization.")
|
||||||
self.remove_export(context, volume)
|
self.remove_export(context, volume)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
ex_msg = (_('Error encountered during cleanup '
|
ex_msg = (_('Error encountered during cleanup '
|
||||||
'of a failed attach: %(ex)s') %
|
'of a failed attach: %(ex)s') % {'ex': ex})
|
||||||
{'ex': six.text_type(ex)})
|
|
||||||
LOG.error(err_msg)
|
LOG.error(err_msg)
|
||||||
raise exception.VolumeBackendAPIException(data=ex_msg)
|
raise exception.VolumeBackendAPIException(data=ex_msg)
|
||||||
raise exception.VolumeBackendAPIException(data=err_msg)
|
raise exception.VolumeBackendAPIException(data=err_msg)
|
||||||
|
@ -1112,15 +1108,13 @@ class BaseVD(object):
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
try:
|
try:
|
||||||
err_msg = (_('Unable to fetch connection information from '
|
err_msg = (_('Unable to fetch connection information from '
|
||||||
'backend: %(err)s') %
|
'backend: %(err)s') % {'err': err})
|
||||||
{'err': six.text_type(err)})
|
|
||||||
LOG.error(err_msg)
|
LOG.error(err_msg)
|
||||||
LOG.debug("Cleaning up failed connect initialization.")
|
LOG.debug("Cleaning up failed connect initialization.")
|
||||||
self.remove_export_snapshot(ctxt, snapshot)
|
self.remove_export_snapshot(ctxt, snapshot)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
ex_msg = (_('Error encountered during cleanup '
|
ex_msg = (_('Error encountered during cleanup '
|
||||||
'of a failed attach: %(ex)s') %
|
'of a failed attach: %(ex)s') % {'ex': ex})
|
||||||
{'ex': six.text_type(ex)})
|
|
||||||
LOG.error(err_msg)
|
LOG.error(err_msg)
|
||||||
raise exception.VolumeBackendAPIException(data=ex_msg)
|
raise exception.VolumeBackendAPIException(data=ex_msg)
|
||||||
raise exception.VolumeBackendAPIException(data=err_msg)
|
raise exception.VolumeBackendAPIException(data=err_msg)
|
||||||
|
@ -1953,8 +1947,7 @@ class BaseVD(object):
|
||||||
for cfg_name in cfg_names]
|
for cfg_name in cfg_names]
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class CloneableImageVD(object, metaclass=abc.ABCMeta):
|
||||||
class CloneableImageVD(object):
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def clone_image(self, volume, image_location,
|
def clone_image(self, volume, image_location,
|
||||||
image_id, image_meta, image_service):
|
image_id, image_meta, image_service):
|
||||||
|
@ -1983,8 +1976,7 @@ class CloneableImageVD(object):
|
||||||
return None, False
|
return None, False
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class MigrateVD(object, metaclass=abc.ABCMeta):
|
||||||
class MigrateVD(object):
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def migrate_volume(self, context, volume, host):
|
def migrate_volume(self, context, volume, host):
|
||||||
"""Migrate the volume to the specified host.
|
"""Migrate the volume to the specified host.
|
||||||
|
@ -2001,8 +1993,7 @@ class MigrateVD(object):
|
||||||
return (False, None)
|
return (False, None)
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class ManageableVD(object, metaclass=abc.ABCMeta):
|
||||||
class ManageableVD(object):
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def manage_existing(self, volume, existing_ref):
|
def manage_existing(self, volume, existing_ref):
|
||||||
"""Brings an existing backend storage object under Cinder management.
|
"""Brings an existing backend storage object under Cinder management.
|
||||||
|
@ -2098,8 +2089,7 @@ class ManageableVD(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class ManageableSnapshotsVD(object, metaclass=abc.ABCMeta):
|
||||||
class ManageableSnapshotsVD(object):
|
|
||||||
# NOTE: Can't use abstractmethod before all drivers implement it
|
# NOTE: Can't use abstractmethod before all drivers implement it
|
||||||
def manage_existing_snapshot(self, snapshot, existing_ref):
|
def manage_existing_snapshot(self, snapshot, existing_ref):
|
||||||
"""Brings an existing backend storage object under Cinder management.
|
"""Brings an existing backend storage object under Cinder management.
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import six
|
|
||||||
import taskflow.engines
|
import taskflow.engines
|
||||||
from taskflow.patterns import linear_flow
|
from taskflow.patterns import linear_flow
|
||||||
from taskflow.types import failure as ft
|
from taskflow.types import failure as ft
|
||||||
|
@ -175,7 +174,7 @@ class ExtractVolumeRequestTask(flow_utils.CinderTask):
|
||||||
raise exception.InvalidInput(reason=msg)
|
raise exception.InvalidInput(reason=msg)
|
||||||
|
|
||||||
def validate_int(size):
|
def validate_int(size):
|
||||||
if not isinstance(size, six.integer_types) or size <= 0:
|
if not isinstance(size, int) or size <= 0:
|
||||||
msg = _("Volume size '%(size)s' must be an integer and"
|
msg = _("Volume size '%(size)s' must be an integer and"
|
||||||
" greater than 0") % {'size': size}
|
" greater than 0") % {'size': size}
|
||||||
raise exception.InvalidInput(reason=msg)
|
raise exception.InvalidInput(reason=msg)
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import six
|
|
||||||
|
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
|
|
||||||
|
@ -66,7 +65,7 @@ def restore_source_status(context, db, volume_spec):
|
||||||
def _clean_reason(reason):
|
def _clean_reason(reason):
|
||||||
if reason is None:
|
if reason is None:
|
||||||
return 'Unknown reason'
|
return 'Unknown reason'
|
||||||
reason = six.text_type(reason)
|
reason = str(reason)
|
||||||
if len(reason) <= REASON_LENGTH:
|
if len(reason) <= REASON_LENGTH:
|
||||||
return reason
|
return reason
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -21,7 +21,6 @@ from oslo_log import log as logging
|
||||||
from oslo_utils import excutils
|
from oslo_utils import excutils
|
||||||
from oslo_utils import fileutils
|
from oslo_utils import fileutils
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import six
|
|
||||||
import taskflow.engines
|
import taskflow.engines
|
||||||
from taskflow.patterns import linear_flow
|
from taskflow.patterns import linear_flow
|
||||||
from taskflow.types import failure as ft
|
from taskflow.types import failure as ft
|
||||||
|
@ -531,7 +530,7 @@ class CreateVolumeFromSpecTask(flow_utils.CinderTask):
|
||||||
LOG.debug("attempting attach for rekey, attach_info: %s",
|
LOG.debug("attempting attach for rekey, attach_info: %s",
|
||||||
attach_info)
|
attach_info)
|
||||||
|
|
||||||
if (isinstance(attach_info['device']['path'], six.string_types)):
|
if (isinstance(attach_info['device']['path'], str)):
|
||||||
image_info = image_utils.qemu_img_info(
|
image_info = image_utils.qemu_img_info(
|
||||||
attach_info['device']['path'])
|
attach_info['device']['path'])
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_db import exception as db_exc
|
from oslo_db import exception as db_exc
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import six
|
|
||||||
import webob
|
import webob
|
||||||
|
|
||||||
from cinder import context
|
from cinder import context
|
||||||
|
@ -80,7 +79,7 @@ def destroy(context, id):
|
||||||
try:
|
try:
|
||||||
db.group_type_destroy(elevated, id)
|
db.group_type_destroy(elevated, id)
|
||||||
except exception.GroupTypeInUse as e:
|
except exception.GroupTypeInUse as e:
|
||||||
msg = _('Target group type is still in use. %s') % six.text_type(e)
|
msg = _('Target group type is still in use. %s') % e
|
||||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,6 @@ from oslo_utils import units
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
profiler = importutils.try_import('osprofiler.profiler')
|
profiler = importutils.try_import('osprofiler.profiler')
|
||||||
import requests
|
import requests
|
||||||
import six
|
|
||||||
from taskflow import exceptions as tfe
|
from taskflow import exceptions as tfe
|
||||||
|
|
||||||
from cinder.common import constants
|
from cinder.common import constants
|
||||||
|
@ -1071,7 +1070,7 @@ class VolumeManager(manager.CleanableManager,
|
||||||
'snapshot %(s_id)s failed with %(error)s.')
|
'snapshot %(s_id)s failed with %(error)s.')
|
||||||
msg_args = {'v_id': volume.id,
|
msg_args = {'v_id': volume.id,
|
||||||
's_id': snapshot.id,
|
's_id': snapshot.id,
|
||||||
'error': six.text_type(error)}
|
'error': error}
|
||||||
v_res = volume.update_single_status_where(
|
v_res = volume.update_single_status_where(
|
||||||
'error',
|
'error',
|
||||||
'reverting')
|
'reverting')
|
||||||
|
@ -1184,7 +1183,7 @@ class VolumeManager(manager.CleanableManager,
|
||||||
exception=ex,
|
exception=ex,
|
||||||
detail=message_field.Detail.SNAPSHOT_UPDATE_METADATA_FAILED
|
detail=message_field.Detail.SNAPSHOT_UPDATE_METADATA_FAILED
|
||||||
)
|
)
|
||||||
raise exception.MetadataCopyFailure(reason=six.text_type(ex))
|
raise exception.MetadataCopyFailure(reason=str(ex))
|
||||||
|
|
||||||
snapshot.status = fields.SnapshotStatus.AVAILABLE
|
snapshot.status = fields.SnapshotStatus.AVAILABLE
|
||||||
snapshot.progress = '100%'
|
snapshot.progress = '100%'
|
||||||
|
@ -1467,7 +1466,7 @@ class VolumeManager(manager.CleanableManager,
|
||||||
"remove-export failure.",
|
"remove-export failure.",
|
||||||
resource=volume)
|
resource=volume)
|
||||||
raise exception.RemoveExportException(volume=volume_id,
|
raise exception.RemoveExportException(volume=volume_id,
|
||||||
reason=six.text_type(ex))
|
reason=str(ex))
|
||||||
|
|
||||||
volume.finish_detach(attachment.id)
|
volume.finish_detach(attachment.id)
|
||||||
self._notify_about_volume_usage(context, volume, "detach.end")
|
self._notify_about_volume_usage(context, volume, "detach.end")
|
||||||
|
@ -1688,7 +1687,7 @@ class VolumeManager(manager.CleanableManager,
|
||||||
# Deletes the image if it is in queued or saving state
|
# Deletes the image if it is in queued or saving state
|
||||||
self._delete_image(context, image_meta['id'], image_service)
|
self._delete_image(context, image_meta['id'], image_service)
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception():
|
||||||
payload['message'] = six.text_type(error)
|
payload['message'] = str(error)
|
||||||
finally:
|
finally:
|
||||||
self.db.volume_update_status_based_on_attachment(context,
|
self.db.volume_update_status_based_on_attachment(context,
|
||||||
volume_id)
|
volume_id)
|
||||||
|
@ -1834,10 +1833,10 @@ class VolumeManager(manager.CleanableManager,
|
||||||
try:
|
try:
|
||||||
self.driver.validate_connector(connector)
|
self.driver.validate_connector(connector)
|
||||||
except exception.InvalidConnectorException as err:
|
except exception.InvalidConnectorException as err:
|
||||||
raise exception.InvalidInput(reason=six.text_type(err))
|
raise exception.InvalidInput(reason=str(err))
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
err_msg = (_("Validate volume connection failed "
|
err_msg = (_("Validate volume connection failed "
|
||||||
"(error: %(err)s).") % {'err': six.text_type(err)})
|
"(error: %(err)s).") % {'err': err})
|
||||||
LOG.exception(err_msg, resource=volume)
|
LOG.exception(err_msg, resource=volume)
|
||||||
raise exception.VolumeBackendAPIException(data=err_msg)
|
raise exception.VolumeBackendAPIException(data=err_msg)
|
||||||
|
|
||||||
|
@ -1859,13 +1858,13 @@ class VolumeManager(manager.CleanableManager,
|
||||||
self.driver.remove_export(context.elevated(), volume)
|
self.driver.remove_export(context.elevated(), volume)
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.exception('Could not remove export after DB model failed.')
|
LOG.exception('Could not remove export after DB model failed.')
|
||||||
raise exception.ExportFailure(reason=six.text_type(ex))
|
raise exception.ExportFailure(reason=str(ex))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
conn_info = self.driver.initialize_connection(volume, connector)
|
conn_info = self.driver.initialize_connection(volume, connector)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
err_msg = (_("Driver initialize connection failed "
|
err_msg = (_("Driver initialize connection failed "
|
||||||
"(error: %(err)s).") % {'err': six.text_type(err)})
|
"(error: %(err)s).") % {'err': err})
|
||||||
LOG.exception(err_msg, resource=volume)
|
LOG.exception(err_msg, resource=volume)
|
||||||
|
|
||||||
self.driver.remove_export(context.elevated(), volume)
|
self.driver.remove_export(context.elevated(), volume)
|
||||||
|
@ -1883,10 +1882,10 @@ class VolumeManager(manager.CleanableManager,
|
||||||
try:
|
try:
|
||||||
self.driver.validate_connector(connector)
|
self.driver.validate_connector(connector)
|
||||||
except exception.InvalidConnectorException as err:
|
except exception.InvalidConnectorException as err:
|
||||||
raise exception.InvalidInput(reason=six.text_type(err))
|
raise exception.InvalidInput(reason=str(err))
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
err_msg = (_("Validate snapshot connection failed "
|
err_msg = (_("Validate snapshot connection failed "
|
||||||
"(error: %(err)s).") % {'err': six.text_type(err)})
|
"(error: %(err)s).") % {'err': err})
|
||||||
LOG.exception(err_msg, resource=snapshot)
|
LOG.exception(err_msg, resource=snapshot)
|
||||||
raise exception.VolumeBackendAPIException(data=err_msg)
|
raise exception.VolumeBackendAPIException(data=err_msg)
|
||||||
|
|
||||||
|
@ -1912,7 +1911,7 @@ class VolumeManager(manager.CleanableManager,
|
||||||
snapshot.save()
|
snapshot.save()
|
||||||
except exception.CinderException as ex:
|
except exception.CinderException as ex:
|
||||||
LOG.exception("Model update failed.", resource=snapshot)
|
LOG.exception("Model update failed.", resource=snapshot)
|
||||||
raise exception.ExportFailure(reason=six.text_type(ex))
|
raise exception.ExportFailure(reason=str(ex))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
conn = self.driver.initialize_connection_snapshot(snapshot,
|
conn = self.driver.initialize_connection_snapshot(snapshot,
|
||||||
|
@ -1920,15 +1919,13 @@ class VolumeManager(manager.CleanableManager,
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
try:
|
try:
|
||||||
err_msg = (_('Unable to fetch connection information from '
|
err_msg = (_('Unable to fetch connection information from '
|
||||||
'backend: %(err)s') %
|
'backend: %(err)s') % {'err': err})
|
||||||
{'err': six.text_type(err)})
|
|
||||||
LOG.error(err_msg)
|
LOG.error(err_msg)
|
||||||
LOG.debug("Cleaning up failed connect initialization.")
|
LOG.debug("Cleaning up failed connect initialization.")
|
||||||
self.driver.remove_export_snapshot(ctxt.elevated(), snapshot)
|
self.driver.remove_export_snapshot(ctxt.elevated(), snapshot)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
ex_msg = (_('Error encountered during cleanup '
|
ex_msg = (_('Error encountered during cleanup '
|
||||||
'of a failed attach: %(ex)s') %
|
'of a failed attach: %(ex)s') % {'ex': ex})
|
||||||
{'ex': six.text_type(ex)})
|
|
||||||
LOG.error(ex_msg)
|
LOG.error(ex_msg)
|
||||||
raise exception.VolumeBackendAPIException(data=ex_msg)
|
raise exception.VolumeBackendAPIException(data=ex_msg)
|
||||||
raise exception.VolumeBackendAPIException(data=err_msg)
|
raise exception.VolumeBackendAPIException(data=err_msg)
|
||||||
|
@ -1953,7 +1950,7 @@ class VolumeManager(manager.CleanableManager,
|
||||||
force=force)
|
force=force)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
err_msg = (_('Terminate volume connection failed: %(err)s')
|
err_msg = (_('Terminate volume connection failed: %(err)s')
|
||||||
% {'err': six.text_type(err)})
|
% {'err': err})
|
||||||
LOG.exception(err_msg, resource=volume_ref)
|
LOG.exception(err_msg, resource=volume_ref)
|
||||||
raise exception.VolumeBackendAPIException(data=err_msg)
|
raise exception.VolumeBackendAPIException(data=err_msg)
|
||||||
LOG.info("Terminate volume connection completed successfully.",
|
LOG.info("Terminate volume connection completed successfully.",
|
||||||
|
@ -1969,7 +1966,7 @@ class VolumeManager(manager.CleanableManager,
|
||||||
force=force)
|
force=force)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
err_msg = (_('Terminate snapshot connection failed: %(err)s')
|
err_msg = (_('Terminate snapshot connection failed: %(err)s')
|
||||||
% {'err': six.text_type(err)})
|
% {'err': err})
|
||||||
LOG.exception(err_msg, resource=snapshot)
|
LOG.exception(err_msg, resource=snapshot)
|
||||||
raise exception.VolumeBackendAPIException(data=err_msg)
|
raise exception.VolumeBackendAPIException(data=err_msg)
|
||||||
LOG.info("Terminate snapshot connection completed successfully.",
|
LOG.info("Terminate snapshot connection completed successfully.",
|
||||||
|
@ -2053,7 +2050,7 @@ class VolumeManager(manager.CleanableManager,
|
||||||
root_access = True
|
root_access = True
|
||||||
|
|
||||||
if not connector.check_valid_device(vol_handle['path'], root_access):
|
if not connector.check_valid_device(vol_handle['path'], root_access):
|
||||||
if isinstance(vol_handle['path'], six.string_types):
|
if isinstance(vol_handle['path'], str):
|
||||||
raise exception.DeviceUnavailable(
|
raise exception.DeviceUnavailable(
|
||||||
path=vol_handle['path'],
|
path=vol_handle['path'],
|
||||||
reason=(_("Unable to access the backend storage via the "
|
reason=(_("Unable to access the backend storage via the "
|
||||||
|
@ -3467,7 +3464,7 @@ class VolumeManager(manager.CleanableManager,
|
||||||
if group:
|
if group:
|
||||||
group.status = fields.GroupStatus.ERROR
|
group.status = fields.GroupStatus.ERROR
|
||||||
group.save()
|
group.save()
|
||||||
raise exception.MetadataCopyFailure(reason=six.text_type(ex))
|
raise exception.MetadataCopyFailure(reason=str(ex))
|
||||||
|
|
||||||
self.db.volume_update(context, vol['id'], update)
|
self.db.volume_update(context, vol['id'], update)
|
||||||
|
|
||||||
|
@ -3935,7 +3932,7 @@ class VolumeManager(manager.CleanableManager,
|
||||||
snapshot.status = fields.SnapshotStatus.ERROR
|
snapshot.status = fields.SnapshotStatus.ERROR
|
||||||
snapshot.save()
|
snapshot.save()
|
||||||
raise exception.MetadataCopyFailure(
|
raise exception.MetadataCopyFailure(
|
||||||
reason=six.text_type(ex))
|
reason=str(ex))
|
||||||
|
|
||||||
snapshot.status = fields.SnapshotStatus.AVAILABLE
|
snapshot.status = fields.SnapshotStatus.AVAILABLE
|
||||||
snapshot.progress = '100%'
|
snapshot.progress = '100%'
|
||||||
|
@ -4498,10 +4495,10 @@ class VolumeManager(manager.CleanableManager,
|
||||||
try:
|
try:
|
||||||
self.driver.validate_connector(connector)
|
self.driver.validate_connector(connector)
|
||||||
except exception.InvalidConnectorException as err:
|
except exception.InvalidConnectorException as err:
|
||||||
raise exception.InvalidInput(reason=six.text_type(err))
|
raise exception.InvalidInput(reason=str(err))
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
err_msg = (_("Validate volume connection failed "
|
err_msg = (_("Validate volume connection failed "
|
||||||
"(error: %(err)s).") % {'err': six.text_type(err)})
|
"(error: %(err)s).") % {'err': err})
|
||||||
LOG.error(err_msg, resource=volume)
|
LOG.error(err_msg, resource=volume)
|
||||||
raise exception.VolumeBackendAPIException(data=err_msg)
|
raise exception.VolumeBackendAPIException(data=err_msg)
|
||||||
|
|
||||||
|
@ -4519,13 +4516,13 @@ class VolumeManager(manager.CleanableManager,
|
||||||
volume.save()
|
volume.save()
|
||||||
except exception.CinderException as ex:
|
except exception.CinderException as ex:
|
||||||
LOG.exception("Model update failed.", resource=volume)
|
LOG.exception("Model update failed.", resource=volume)
|
||||||
raise exception.ExportFailure(reason=six.text_type(ex))
|
raise exception.ExportFailure(reason=str(ex))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
conn_info = self.driver.initialize_connection(volume, connector)
|
conn_info = self.driver.initialize_connection(volume, connector)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
err_msg = (_("Driver initialize connection failed "
|
err_msg = (_("Driver initialize connection failed "
|
||||||
"(error: %(err)s).") % {'err': six.text_type(err)})
|
"(error: %(err)s).") % {'err': err})
|
||||||
LOG.exception(err_msg, resource=volume)
|
LOG.exception(err_msg, resource=volume)
|
||||||
self.driver.remove_export(ctxt.elevated(), volume)
|
self.driver.remove_export(ctxt.elevated(), volume)
|
||||||
raise exception.VolumeBackendAPIException(data=err_msg)
|
raise exception.VolumeBackendAPIException(data=err_msg)
|
||||||
|
@ -4641,7 +4638,7 @@ class VolumeManager(manager.CleanableManager,
|
||||||
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
err_msg = (_('Terminate volume connection failed: %(err)s')
|
err_msg = (_('Terminate volume connection failed: %(err)s')
|
||||||
% {'err': six.text_type(err)})
|
% {'err': err})
|
||||||
LOG.exception(err_msg, resource=volume)
|
LOG.exception(err_msg, resource=volume)
|
||||||
raise exception.VolumeBackendAPIException(data=err_msg)
|
raise exception.VolumeBackendAPIException(data=err_msg)
|
||||||
LOG.info("Terminate volume connection completed successfully.",
|
LOG.info("Terminate volume connection completed successfully.",
|
||||||
|
@ -4770,8 +4767,7 @@ class VolumeManager(manager.CleanableManager,
|
||||||
vol.status = 'error'
|
vol.status = 'error'
|
||||||
vol.replication_status = fields.ReplicationStatus.ERROR
|
vol.replication_status = fields.ReplicationStatus.ERROR
|
||||||
vol.save()
|
vol.save()
|
||||||
err_msg = _("Enable replication group failed: "
|
err_msg = _("Enable replication group failed: %s.") % ex
|
||||||
"%s.") % six.text_type(ex)
|
|
||||||
raise exception.ReplicationGroupError(reason=err_msg,
|
raise exception.ReplicationGroupError(reason=err_msg,
|
||||||
group_id=group.id)
|
group_id=group.id)
|
||||||
|
|
||||||
|
@ -4855,8 +4851,7 @@ class VolumeManager(manager.CleanableManager,
|
||||||
vol.status = 'error'
|
vol.status = 'error'
|
||||||
vol.replication_status = fields.ReplicationStatus.ERROR
|
vol.replication_status = fields.ReplicationStatus.ERROR
|
||||||
vol.save()
|
vol.save()
|
||||||
err_msg = _("Disable replication group failed: "
|
err_msg = _("Disable replication group failed: %s.") % ex
|
||||||
"%s.") % six.text_type(ex)
|
|
||||||
raise exception.ReplicationGroupError(reason=err_msg,
|
raise exception.ReplicationGroupError(reason=err_msg,
|
||||||
group_id=group.id)
|
group_id=group.id)
|
||||||
|
|
||||||
|
@ -4947,8 +4942,7 @@ class VolumeManager(manager.CleanableManager,
|
||||||
vol.status = 'error'
|
vol.status = 'error'
|
||||||
vol.replication_status = fields.ReplicationStatus.ERROR
|
vol.replication_status = fields.ReplicationStatus.ERROR
|
||||||
vol.save()
|
vol.save()
|
||||||
err_msg = _("Failover replication group failed: "
|
err_msg = _("Failover replication group failed: %s.") % ex
|
||||||
"%s.") % six.text_type(ex)
|
|
||||||
raise exception.ReplicationGroupError(reason=err_msg,
|
raise exception.ReplicationGroupError(reason=err_msg,
|
||||||
group_id=group.id)
|
group_id=group.id)
|
||||||
|
|
||||||
|
|
|
@ -13,13 +13,11 @@
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
import six
|
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class Target(object, metaclass=abc.ABCMeta):
|
||||||
class Target(object):
|
|
||||||
"""Target object for block storage devices.
|
"""Target object for block storage devices.
|
||||||
|
|
||||||
Base class for target object, where target
|
Base class for target object, where target
|
||||||
|
|
|
@ -17,7 +17,6 @@ from oslo_log import log as logging
|
||||||
from oslo_serialization import jsonutils as json
|
from oslo_serialization import jsonutils as json
|
||||||
from oslo_utils import excutils
|
from oslo_utils import excutils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import six
|
|
||||||
|
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.privsep import nvmcli
|
from cinder.privsep import nvmcli
|
||||||
|
@ -122,7 +121,7 @@ class NVMET(nvmeof.NVMeOF):
|
||||||
"namespaces": [
|
"namespaces": [
|
||||||
{
|
{
|
||||||
"device": {
|
"device": {
|
||||||
"nguid": six.text_type(uuidutils.generate_uuid()),
|
"nguid": str(uuidutils.generate_uuid()),
|
||||||
"path": volume_path,
|
"path": volume_path,
|
||||||
},
|
},
|
||||||
"enable": 1,
|
"enable": 1,
|
||||||
|
|
|
@ -43,8 +43,6 @@ from oslo_utils import netutils
|
||||||
from oslo_utils import strutils
|
from oslo_utils import strutils
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
from oslo_utils import units
|
from oslo_utils import units
|
||||||
import six
|
|
||||||
from six.moves import range
|
|
||||||
|
|
||||||
from cinder.brick.local_dev import lvm as brick_lvm
|
from cinder.brick.local_dev import lvm as brick_lvm
|
||||||
from cinder import context
|
from cinder import context
|
||||||
|
@ -550,11 +548,11 @@ def _transfer_data(src, dest, length, chunk_size):
|
||||||
|
|
||||||
def _copy_volume_with_file(src, dest, size_in_m):
|
def _copy_volume_with_file(src, dest, size_in_m):
|
||||||
src_handle = src
|
src_handle = src
|
||||||
if isinstance(src, six.string_types):
|
if isinstance(src, str):
|
||||||
src_handle = _open_volume_with_path(src, 'rb')
|
src_handle = _open_volume_with_path(src, 'rb')
|
||||||
|
|
||||||
dest_handle = dest
|
dest_handle = dest
|
||||||
if isinstance(dest, six.string_types):
|
if isinstance(dest, str):
|
||||||
dest_handle = _open_volume_with_path(dest, 'wb')
|
dest_handle = _open_volume_with_path(dest, 'wb')
|
||||||
|
|
||||||
if not src_handle:
|
if not src_handle:
|
||||||
|
@ -571,9 +569,9 @@ def _copy_volume_with_file(src, dest, size_in_m):
|
||||||
|
|
||||||
duration = max(1, timeutils.delta_seconds(start_time, timeutils.utcnow()))
|
duration = max(1, timeutils.delta_seconds(start_time, timeutils.utcnow()))
|
||||||
|
|
||||||
if isinstance(src, six.string_types):
|
if isinstance(src, str):
|
||||||
src_handle.close()
|
src_handle.close()
|
||||||
if isinstance(dest, six.string_types):
|
if isinstance(dest, str):
|
||||||
dest_handle.close()
|
dest_handle.close()
|
||||||
|
|
||||||
mbps = (size_in_m / duration)
|
mbps = (size_in_m / duration)
|
||||||
|
@ -598,8 +596,8 @@ def copy_volume(src, dest, size_in_m, blocksize, sync=False,
|
||||||
instead of file paths and, at present moment, throttling is unavailable.
|
instead of file paths and, at present moment, throttling is unavailable.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if (isinstance(src, six.string_types) and
|
if (isinstance(src, str) and
|
||||||
isinstance(dest, six.string_types)):
|
isinstance(dest, str)):
|
||||||
if not throttle:
|
if not throttle:
|
||||||
throttle = throttling.Throttle.get_default()
|
throttle = throttling.Throttle.get_default()
|
||||||
with throttle.subcommand(src, dest) as throttle_cmd:
|
with throttle.subcommand(src, dest) as throttle_cmd:
|
||||||
|
@ -823,7 +821,7 @@ def check_already_managed_volume(vol_id):
|
||||||
volume id exists, otherwise return False
|
volume id exists, otherwise return False
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return (vol_id and isinstance(vol_id, six.string_types) and
|
return (vol_id and isinstance(vol_id, str) and
|
||||||
uuid.UUID(vol_id, version=4) and
|
uuid.UUID(vol_id, version=4) and
|
||||||
objects.Volume.exists(context.get_admin_context(), vol_id))
|
objects.Volume.exists(context.get_admin_context(), vol_id))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
@ -1215,12 +1213,8 @@ def sanitize_host(host):
|
||||||
|
|
||||||
def sanitize_hostname(hostname):
|
def sanitize_hostname(hostname):
|
||||||
"""Return a hostname which conforms to RFC-952 and RFC-1123 specs."""
|
"""Return a hostname which conforms to RFC-952 and RFC-1123 specs."""
|
||||||
if six.PY3:
|
hostname = hostname.encode('latin-1', 'ignore')
|
||||||
hostname = hostname.encode('latin-1', 'ignore')
|
hostname = hostname.decode('latin-1')
|
||||||
hostname = hostname.decode('latin-1')
|
|
||||||
else:
|
|
||||||
if isinstance(hostname, six.text_type):
|
|
||||||
hostname = hostname.encode('latin-1', 'ignore')
|
|
||||||
|
|
||||||
hostname = re.sub(r'[ _]', '-', hostname)
|
hostname = re.sub(r'[ _]', '-', hostname)
|
||||||
hostname = re.sub(r'[^\w.-]+', '', hostname)
|
hostname = re.sub(r'[^\w.-]+', '', hostname)
|
||||||
|
|
Loading…
Reference in New Issue