Merge "Bump pylint version and fix pylint issues"

This commit is contained in:
Zuul 2024-06-18 10:02:15 +00:00 committed by Gerrit Code Review
commit 0999857c47
5 changed files with 17 additions and 8 deletions

View File

@ -578,6 +578,10 @@ class ShareBackendException(ManilaException):
message = _("Share backend error: %(msg)s.") message = _("Share backend error: %(msg)s.")
class OperationNotSupportedByDriverMode(ManilaException):
message = _("The share driver mode does not support this operation.")
class RequirementMissing(ManilaException): class RequirementMissing(ManilaException):
message = _("Requirement %(req)s is not installed.") message = _("Requirement %(req)s is not installed.")

View File

@ -227,7 +227,7 @@ _vars = {}
def _def_parser(): def _def_parser():
# Enabling packrat parsing greatly speeds up the parsing. # Enabling packrat parsing greatly speeds up the parsing.
pyparsing.ParserElement.enablePackrat() pyparsing.ParserElement.enablePackrat() # pylint: disable = no-value-for-parameter # noqa:E501
alphas = pyparsing.alphas alphas = pyparsing.alphas
Combine = pyparsing.Combine Combine = pyparsing.Combine

View File

@ -137,6 +137,7 @@ class API(base.Base):
self.access_helper = access.ShareInstanceAccess(self.db, None) self.access_helper = access.ShareInstanceAccess(self.db, None)
coordination.LOCK_COORDINATOR.start() coordination.LOCK_COORDINATOR.start()
# pylint: disable = no-self-argument
def prevent_locked_action_on_share(arg): def prevent_locked_action_on_share(arg):
"""Decorator for preventing a locked method from executing on a share. """Decorator for preventing a locked method from executing on a share.
@ -471,6 +472,7 @@ class API(base.Base):
az_request_multiple_subnet_support_map = ( az_request_multiple_subnet_support_map = (
compatible_azs_multiple) compatible_azs_multiple)
share = None
try: try:
share = self.db.share_create(context, options, share = self.db.share_create(context, options,
create_share_instance=False) create_share_instance=False)
@ -478,7 +480,8 @@ class API(base.Base):
except Exception: except Exception:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
try: try:
self.db.share_delete(context, share['id']) if share:
self.db.share_delete(context, share['id'])
finally: finally:
QUOTAS.rollback( QUOTAS.rollback(
context, reservations, share_type_id=share_type_id) context, reservations, share_type_id=share_type_id)
@ -844,6 +847,7 @@ class API(base.Base):
else: else:
cast_rules_to_readonly = False cast_rules_to_readonly = False
share_replica = None
try: try:
request_spec, share_replica = ( request_spec, share_replica = (
self.create_share_instance_and_get_request_spec( self.create_share_instance_and_get_request_spec(
@ -862,9 +866,10 @@ class API(base.Base):
except Exception: except Exception:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
try: try:
self.db.share_replica_delete( if share_replica:
context, share_replica['id'], self.db.share_replica_delete(
need_to_update_usages=False) context, share_replica['id'],
need_to_update_usages=False)
finally: finally:
QUOTAS.rollback( QUOTAS.rollback(
context, reservations, share_type_id=share_type['id']) context, reservations, share_type_id=share_type['id'])
@ -1639,8 +1644,8 @@ class API(base.Base):
if metadata: if metadata:
options.update({"metadata": metadata}) options.update({"metadata": metadata})
snapshot = None
try: try:
snapshot = None
snapshot = self.db.share_snapshot_create(context, options) snapshot = self.db.share_snapshot_create(context, options)
QUOTAS.commit( QUOTAS.commit(
context, reservations, context, reservations,

View File

@ -5883,7 +5883,7 @@ class ShareManager(manager.SchedulerDependentManager):
if not self.driver.driver_handles_share_servers: if not self.driver.driver_handles_share_servers:
LOG.error('This operation is supported only on backends that ' LOG.error('This operation is supported only on backends that '
'handle share servers.') 'handle share servers.')
raise raise exception.OperationNotSupportedByDriverMode()
self._share_server_migration_start_driver( self._share_server_migration_start_driver(
context, share_server, dest_host, writable, nondisruptive, context, share_server, dest_host, writable, nondisruptive,

View File

@ -122,7 +122,7 @@ commands =
[testenv:pylint] [testenv:pylint]
deps = -r{toxinidir}/requirements.txt deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt -r{toxinidir}/test-requirements.txt
pylint==2.3.1 pylint==3.0.2
allowlist_externals = bash allowlist_externals = bash
commands = bash ./tools/coding-checks.sh --pylint {posargs} commands = bash ./tools/coding-checks.sh --pylint {posargs}