diff --git a/contrib/share_driver_hooks/zaqar_notification.py b/contrib/share_driver_hooks/zaqar_notification.py index 81e2e50ace..691a5d2b3e 100644 --- a/contrib/share_driver_hooks/zaqar_notification.py +++ b/contrib/share_driver_hooks/zaqar_notification.py @@ -78,7 +78,7 @@ class ZaqarNotification(hook.HookBase): def _execute_pre_hook(self, context, func_name, *args, **kwargs): LOG.debug("\n PRE zaqar notification has been called for " - "method '%s'.\n" % func_name) + "method '%s'.\n", func_name) if func_name == "deny_access": LOG.debug("\nSending notification about denied access.\n") data = self._access_changed_trigger( @@ -92,7 +92,7 @@ class ZaqarNotification(hook.HookBase): def _execute_post_hook(self, context, func_name, pre_hook_data, driver_action_results, *args, **kwargs): LOG.debug("\n POST zaqar notification has been called for " - "method '%s'.\n" % func_name) + "method '%s'.\n", func_name) if func_name == "allow_access": LOG.debug("\nSending notification about allowed access.\n") data = self._access_changed_trigger( @@ -115,7 +115,7 @@ class ZaqarNotification(hook.HookBase): } LOG.debug( "\n Sending message %(m)s to '%(q)s' queue using '%(u)s' user " - "and '%(p)s' project." % { + "and '%(p)s' project.", { 'm': message, 'q': queue_name, 'u': CONF.zaqar.zaqar_username, diff --git a/manila/api/openstack/wsgi.py b/manila/api/openstack/wsgi.py index 2f984f0535..24d2a2f77d 100644 --- a/manila/api/openstack/wsgi.py +++ b/manila/api/openstack/wsgi.py @@ -733,8 +733,8 @@ class Resource(wsgi.Application): def __call__(self, request): """WSGI method that controls (de)serialization and method dispatch.""" - LOG.info("%(method)s %(url)s" % {"method": request.method, - "url": request.url}) + LOG.info("%(method)s %(url)s", {"method": request.method, + "url": request.url}) if self.support_api_request_version: # Set the version of the API requested based on the header try: @@ -900,7 +900,7 @@ class Resource(wsgi.Application): # OK, it's an action; figure out which action... mtype = _MEDIA_TYPE_MAP.get(content_type) action_name = self.action_peek[mtype](body) - LOG.debug("Action body: %s" % body) + LOG.debug("Action body: %s", body) else: action_name = action diff --git a/manila/db/migrations/alembic/versions/3651e16d7c43_add_consistency_groups.py b/manila/db/migrations/alembic/versions/3651e16d7c43_add_consistency_groups.py index 381f29d128..f06465d80e 100644 --- a/manila/db/migrations/alembic/versions/3651e16d7c43_add_consistency_groups.py +++ b/manila/db/migrations/alembic/versions/3651e16d7c43_add_consistency_groups.py @@ -182,7 +182,7 @@ def downgrade(): 'shares', type_='foreignkey') except Exception: - LOG.exception("Error Dropping '%s' constraint." % + LOG.exception("Error Dropping '%s' constraint.", SHARES_CG_FK_CONSTRAINT_NAME) try: diff --git a/manila/db/migrations/alembic/versions/e1949a93157a_add_share_group_types_table.py b/manila/db/migrations/alembic/versions/e1949a93157a_add_share_group_types_table.py index 5916d46e59..e1228e8a97 100644 --- a/manila/db/migrations/alembic/versions/e1949a93157a_add_share_group_types_table.py +++ b/manila/db/migrations/alembic/versions/e1949a93157a_add_share_group_types_table.py @@ -141,5 +141,5 @@ def downgrade(): try: op.drop_table(table_name) except Exception: - LOG.error("%s table not dropped" % table_name) + LOG.error("%s table not dropped", table_name) raise diff --git a/manila/db/migrations/alembic/versions/e8ea58723178_remove_host_from_driver_private_data.py b/manila/db/migrations/alembic/versions/e8ea58723178_remove_host_from_driver_private_data.py index c7f7d5a6f7..4dd885cada 100644 --- a/manila/db/migrations/alembic/versions/e8ea58723178_remove_host_from_driver_private_data.py +++ b/manila/db/migrations/alembic/versions/e8ea58723178_remove_host_from_driver_private_data.py @@ -76,7 +76,7 @@ def downgrade(): ) LOG.info("Copying data from %(from_table)s to the migration " - "table %(migration_table)s" % { + "table %(migration_table)s", { 'from_table': TABLE_NAME, 'migration_table': migration_table_name }) @@ -94,13 +94,13 @@ def downgrade(): }) op.bulk_insert(migration_table, rows) - LOG.info("Dropping table %(from_table)s" % { + LOG.info("Dropping table %(from_table)s", { 'from_table': TABLE_NAME }) op.drop_table(TABLE_NAME) LOG.info("Rename the migration table %(migration_table)s to " - "the original table %(from_table)s" % { + "the original table %(from_table)s", { 'migration_table': migration_table_name, 'from_table': TABLE_NAME }) diff --git a/manila/message/api.py b/manila/message/api.py index 5f6ffabe63..1fe44ac06e 100644 --- a/manila/message/api.py +++ b/manila/message/api.py @@ -45,7 +45,7 @@ class API(base.Base): resource_id=None, exception=None, detail=None, level=message_levels.ERROR): """Create a message with the specified information.""" - LOG.info("Creating message record for request_id = %s" % + LOG.info("Creating message record for request_id = %s", context.request_id) # Updates expiry time for message as per message_ttl config. @@ -66,8 +66,8 @@ class API(base.Base): try: self.db.message_create(context, message_record) except Exception: - LOG.exception("Failed to create message record " - "for request_id %s" % context.request_id) + LOG.exception(("Failed to create message record " + "for request_id %s"), context.request_id) def get(self, context, id): """Return message with the specified message id.""" diff --git a/manila/scheduler/drivers/filter.py b/manila/scheduler/drivers/filter.py index e9ef4b210d..2f7cd57b00 100644 --- a/manila/scheduler/drivers/filter.py +++ b/manila/scheduler/drivers/filter.py @@ -306,7 +306,7 @@ class FilterScheduler(base.Scheduler): def schedule_create_share_group(self, context, share_group_id, request_spec, filter_properties): - LOG.info("Scheduling share group %s." % share_group_id) + LOG.info("Scheduling share group %s.", share_group_id) host = self._get_best_host_for_share_group(context, request_spec) if not host: @@ -314,7 +314,7 @@ class FilterScheduler(base.Scheduler): raise exception.NoValidHost(reason=msg) msg = "Chose host %(host)s for create_share_group %(group)s." - LOG.info(msg % {'host': host, 'group': share_group_id}) + LOG.info(msg, {'host': host, 'group': share_group_id}) updated_share_group = base.share_group_update_db( context, share_group_id, host) @@ -361,7 +361,7 @@ class FilterScheduler(base.Scheduler): if not hosts: return [] - LOG.debug("Filtered %s" % hosts) + LOG.debug("Filtered %s", hosts) # weighted_host = WeightedHost() ... the best host for the job. weighed_hosts = self.host_manager.get_weighed_hosts( @@ -396,7 +396,7 @@ class FilterScheduler(base.Scheduler): if not hosts: return [] - LOG.debug("Filtered %s" % hosts) + LOG.debug("Filtered %s", hosts) weighed_hosts = self.host_manager.get_weighed_hosts( hosts, diff --git a/manila/scheduler/filters/ignore_attempted_hosts.py b/manila/scheduler/filters/ignore_attempted_hosts.py index 1cd709ccc6..73abc8991c 100644 --- a/manila/scheduler/filters/ignore_attempted_hosts.py +++ b/manila/scheduler/filters/ignore_attempted_hosts.py @@ -51,7 +51,7 @@ class IgnoreAttemptedHostsFilter(base_host.BaseHostFilter): pass_msg = "passes" if passes else "fails" LOG.debug("Host %(host)s %(pass_msg)s. Previously tried hosts: " - "%(hosts)s" % {'host': host, - 'pass_msg': pass_msg, - 'hosts': hosts}) + "%(hosts)s", {'host': host, + 'pass_msg': pass_msg, + 'hosts': hosts}) return passes diff --git a/manila/scheduler/host_manager.py b/manila/scheduler/host_manager.py index b831ee28ee..1c7344ee39 100644 --- a/manila/scheduler/host_manager.py +++ b/manila/scheduler/host_manager.py @@ -562,7 +562,7 @@ class HostManager(object): self.service_states[host] = capability_copy LOG.debug("Received %(service_name)s service update from " - "%(host)s: %(cap)s" % + "%(host)s: %(cap)s", {'service_name': service_name, 'host': host, 'cap': capabilities}) @@ -578,7 +578,7 @@ class HostManager(object): # Warn about down services and remove them from host_state_map if not utils.service_is_up(service) or service['disabled']: - LOG.warning("Share service is down. (host: %s)." % host) + LOG.warning("Share service is down. (host: %s).", host) continue # Create and register host_state if not in host_state_map diff --git a/manila/service.py b/manila/service.py index 03786f7821..5fb521bf50 100644 --- a/manila/service.py +++ b/manila/service.py @@ -293,7 +293,7 @@ class WSGIService(service.ServiceBase): if self.workers is not None and self.workers < 1: LOG.warning( "Value of config option %(name)s_workers must be integer " - "greater than 1. Input value ignored." % {'name': name}) + "greater than 1. Input value ignored.", {'name': name}) # Reset workers to default self.workers = None self.server = wsgi.Server( diff --git a/manila/share/api.py b/manila/share/api.py index 879ac2bf68..1c00555f1f 100644 --- a/manila/share/api.py +++ b/manila/share/api.py @@ -1323,7 +1323,7 @@ class API(base.Base): constants.TASK_STATE_DATA_COPYING_IN_PROGRESS): data_rpc = data_rpcapi.DataAPI() LOG.info("Sending request to get share migration information" - " of share %s." % share['id']) + " of share %s.", share['id']) services = self.db.service_get_all_by_topic(context, 'manila-data') @@ -1423,7 +1423,7 @@ class API(base.Base): data_rpc = data_rpcapi.DataAPI() LOG.info("Sending request to cancel migration of " - "share %s." % share['id']) + "share %s.", share['id']) services = self.db.service_get_all_by_topic(context, 'manila-data') @@ -1873,8 +1873,8 @@ class API(base.Base): self.update(context, share, {'status': constants.STATUS_SHRINKING}) self.share_rpcapi.shrink_share(context, share, new_size) LOG.info("Shrink share (id=%(id)s) request issued successfully." - " New size: %(size)s" % {'id': share['id'], - 'size': new_size}) + " New size: %(size)s", {'id': share['id'], + 'size': new_size}) def snapshot_allow_access(self, context, snapshot, access_type, access_to): """Allow access to a share snapshot.""" diff --git a/manila/share/driver.py b/manila/share/driver.py index 775f99e985..c8776c6df1 100644 --- a/manila/share/driver.py +++ b/manila/share/driver.py @@ -1310,7 +1310,7 @@ class ShareDriver(object): except exception.ManilaException: msg = ('Could not delete share group snapshot member %(snap)s ' 'for share %(share)s.') - LOG.error(msg % { + LOG.error(msg, { 'snap': share_snapshot['id'], 'share': share_snapshot['share_id'], }) @@ -1402,7 +1402,7 @@ class ShareDriver(object): msg = ('Could not create share group snapshot. Failed ' 'to create share snapshot %(snap)s for ' 'share %(share)s.') - LOG.exception(msg % { + LOG.exception(msg, { 'snap': share_snapshot['id'], 'share': share_snapshot['share_id'] }) @@ -1466,7 +1466,7 @@ class ShareDriver(object): This value may be None. """ snapshot_members = snap_dict.get('share_group_snapshot_members', []) - LOG.debug('Deleting share group snapshot %s.' % snap_dict['id']) + LOG.debug('Deleting share group snapshot %s.', snap_dict['id']) for member in snapshot_members: share_snapshot = { 'snapshot_id': member['share_group_snapshot_id'], @@ -1482,7 +1482,7 @@ class ShareDriver(object): self.delete_snapshot( context, share_snapshot, share_server=share_server) - LOG.debug('Deleted share group snapshot %s.' % snap_dict['id']) + LOG.debug('Deleted share group snapshot %s.', snap_dict['id']) return None, None def _collate_share_group_snapshot_info(self, share_group_dict, diff --git a/manila/share/drivers/container/driver.py b/manila/share/drivers/container/driver.py index 29ec0fd3b5..a6be2b75a6 100644 --- a/manila/share/drivers/container/driver.py +++ b/manila/share/drivers/container/driver.py @@ -117,7 +117,7 @@ class ContainerShareDriver(driver.ShareDriver, driver.ExecuteMixin): super(ContainerShareDriver, self)._update_share_stats(data) def create_share(self, context, share, share_server=None): - LOG.debug("Create share on server '%s'." % share_server["id"]) + LOG.debug("Create share on server '%s'.", share_server["id"]) server_id = self._get_container_name(share_server["id"]) share_name = share.share_id self.container.execute( @@ -135,7 +135,7 @@ class ContainerShareDriver(driver.ShareDriver, driver.ExecuteMixin): @utils.synchronized('container_driver_delete_share_lock', external=True) def delete_share(self, context, share, share_server=None): - LOG.debug("Deleting share %(share)s on server '%(server)s'." % + LOG.debug("Deleting share %(share)s on server '%(server)s'.", {"server": share_server["id"], "share": share.share_id}) server_id = self._get_container_name(share_server["id"]) @@ -255,7 +255,7 @@ class ContainerShareDriver(driver.ShareDriver, driver.ExecuteMixin): self.configuration.container_ovs_bridge_name, host_veth, *(e_mac + e_id + e_status + e_mcid), run_as_root=True) LOG.debug("Now container %(id)s should be accessible from network " - "%(network)s and subnet %(subnet)s by address %(ip)s." % + "%(network)s and subnet %(subnet)s by address %(ip)s.", msg_helper) @utils.synchronized("container_driver_teardown_lock", external=True) @@ -305,7 +305,7 @@ class ContainerShareDriver(driver.ShareDriver, driver.ExecuteMixin): def _setup_server(self, network_info, metadata=None): msg = "Creating share server '%s'." server_id = self._get_container_name(network_info["server_id"]) - LOG.debug(msg % server_id) + LOG.debug(msg, server_id) veths_before = self._get_veth_state() try: diff --git a/manila/share/drivers/container/protocol_helper.py b/manila/share/drivers/container/protocol_helper.py index 04229af652..3a9aaa594c 100644 --- a/manila/share/drivers/container/protocol_helper.py +++ b/manila/share/drivers/container/protocol_helper.py @@ -110,7 +110,7 @@ class DockerCIFSHelper(object): existing_users = self._get_existing_users(server_id, share_name, access) except TypeError: - LOG.warning("Can't access smbd at share %s." % share_name) + LOG.warning("Can't access smbd at share %s.", share_name) return else: allowed_users = " ".join(sorted(set(existing_users.split()) - diff --git a/manila/share/drivers/container/storage_helper.py b/manila/share/drivers/container/storage_helper.py index 44866f335c..5db4a11086 100644 --- a/manila/share/drivers/container/storage_helper.py +++ b/manila/share/drivers/container/storage_helper.py @@ -94,7 +94,7 @@ class LVMHelper(driver.ExecuteMixin): self._execute("lvremove", "-f", "--autobackup", "n", to_remove, run_as_root=True) except exception.ProcessExecutionError as e: - LOG.warning("Failed to remove logical volume %s." % to_remove) + LOG.warning("Failed to remove logical volume %s.", to_remove) LOG.error(e) def extend_share(self, share, new_size, share_server=None): diff --git a/manila/share/drivers/generic.py b/manila/share/drivers/generic.py index 40885d3d0f..097a8b25cb 100644 --- a/manila/share/drivers/generic.py +++ b/manila/share/drivers/generic.py @@ -873,7 +873,7 @@ class GenericShareDriver(driver.ExecuteMixin, driver.ShareDriver): def _setup_server(self, network_info, metadata=None): msg = "Creating share server '%s'." - LOG.debug(msg % network_info['server_id']) + LOG.debug(msg, network_info['server_id']) server = self.service_instance_manager.set_up_service_instance( self.admin_context, network_info) for helper in self._helpers.values(): @@ -945,7 +945,7 @@ class GenericShareDriver(driver.ExecuteMixin, driver.ShareDriver): linked_volume_name = self._get_volume_name(share['id']) if share_volume['name'] != linked_volume_name: - LOG.debug('Manage: volume_id = %s' % share_volume['id']) + LOG.debug('Manage: volume_id = %s', share_volume['id']) self.volume_api.update(self.admin_context, share_volume['id'], {'name': linked_volume_name}) diff --git a/manila/share/drivers/glusterfs/common.py b/manila/share/drivers/glusterfs/common.py index fbd5c07fc0..008c4047bc 100644 --- a/manila/share/drivers/glusterfs/common.py +++ b/manila/share/drivers/glusterfs/common.py @@ -205,7 +205,7 @@ class GlusterManager(object): exc.exit_code in error_policy): return if logmsg: - LOG.error("%s: GlusterFS instrumentation failed." % + LOG.error("%s: GlusterFS instrumentation failed.", logmsg) raise exception.GlusterfsException( _("GlusterFS management command '%(cmd)s' failed " diff --git a/manila/share/drivers/helpers.py b/manila/share/drivers/helpers.py index 96452a5ebb..ff7a42d13b 100644 --- a/manila/share/drivers/helpers.py +++ b/manila/share/drivers/helpers.py @@ -266,9 +266,9 @@ class NFSHelper(NASHelperBase): LOG.warning( "Unsupported access level %(level)s or access type " "%(type)s, skipping removal of access rule to " - "%(to)s." % {'level': access['access_level'], - 'type': access['access_type'], - 'to': access['access_to']}) + "%(to)s.", {'level': access['access_level'], + 'type': access['access_type'], + 'to': access['access_to']}) continue self._ssh_exec(server, ['sudo', 'exportfs', '-u', ':'.join((access['access_to'], local_path))]) @@ -282,7 +282,7 @@ class NFSHelper(NASHelperBase): access['access_to']), out) if found_item is not None: LOG.warning("Access rule %(type)s:%(to)s already " - "exists for share %(name)s" % { + "exists for share %(name)s", { 'to': access['access_to'], 'type': access['access_type'], 'name': share_name diff --git a/manila/share/drivers/hitachi/hnas/ssh.py b/manila/share/drivers/hitachi/hnas/ssh.py index 38cd7ed211..cf34af44ca 100644 --- a/manila/share/drivers/hitachi/hnas/ssh.py +++ b/manila/share/drivers/hitachi/hnas/ssh.py @@ -313,7 +313,7 @@ class HNASSSHBackend(object): command = ['tree-clone-job-abort', job_id] self._execute(command) LOG.error("Timeout in snapshot creation from " - "source path %s." % src_path) + "source path %s.", src_path) msg = _("Share snapshot of source path %s " "was not created.") % src_path raise exception.HNASBackendException(msg=msg) diff --git a/manila/share/drivers/huawei/v3/helper.py b/manila/share/drivers/huawei/v3/helper.py index 5c3dc05365..afd2bebf3e 100644 --- a/manila/share/drivers/huawei/v3/helper.py +++ b/manila/share/drivers/huawei/v3/helper.py @@ -214,7 +214,7 @@ class RestHelper(object): utils.execute('chmod', '666', filepath, run_as_root=True) except Exception as err: - LOG.error('Bad response from change file: %s.' % err) + LOG.error('Bad response from change file: %s.', err) raise def create_share(self, share_name, fs_id, share_proto): diff --git a/manila/share/drivers/ibm/gpfs.py b/manila/share/drivers/ibm/gpfs.py index ba3711cc63..b5f4f38ad8 100644 --- a/manila/share/drivers/ibm/gpfs.py +++ b/manila/share/drivers/ibm/gpfs.py @@ -226,7 +226,7 @@ class GPFSShareDriver(driver.ExecuteMixin, driver.GaneshaMixin, # 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) and (ignore_exit_code is None or @@ -692,7 +692,7 @@ class GPFSShareDriver(driver.ExecuteMixin, driver.GaneshaMixin, LOG.exception(msg) raise exception.GPFSException(msg) LOG.info('Existing share %(shr)s has size %(size)s KB ' - 'which is below 1GiB, so extended it to 1GiB.' % + 'which is below 1GiB, so extended it to 1GiB.', {'shr': new_share_name, 'size': share_size}) share_size = 1 else: diff --git a/manila/share/drivers/lvm.py b/manila/share/drivers/lvm.py index a2d7e0b08c..45c11c18f0 100644 --- a/manila/share/drivers/lvm.py +++ b/manila/share/drivers/lvm.py @@ -121,7 +121,7 @@ class LVMMixin(driver.ExecuteMixin): if "not found" not in exc.stderr: LOG.exception("Error deleting volume") raise - LOG.warning("Volume not found: %s" % exc.stderr) + LOG.warning("Volume not found: %s", exc.stderr) def _create_snapshot(self, context, snapshot): """Creates a snapshot.""" diff --git a/manila/share/drivers/netapp/common.py b/manila/share/drivers/netapp/common.py index 3c17598144..0319525346 100644 --- a/manila/share/drivers/netapp/common.py +++ b/manila/share/drivers/netapp/common.py @@ -108,7 +108,7 @@ class NetAppDriver(object): fmt = {'storage_family': storage_family, 'driver_mode': driver_mode} LOG.info('Requested unified config: %(storage_family)s and ' - '%(driver_mode)s.' % fmt) + '%(driver_mode)s.', fmt) family_meta = NETAPP_UNIFIED_DRIVER_REGISTRY.get(storage_family) if family_meta is None: @@ -125,5 +125,5 @@ class NetAppDriver(object): kwargs['netapp_mode'] = 'proxy' driver = importutils.import_object(driver_loc, *args, **kwargs) LOG.info('NetApp driver of family %(storage_family)s and mode ' - '%(driver_mode)s loaded.' % fmt) + '%(driver_mode)s loaded.', fmt) return driver diff --git a/manila/share/drivers/netapp/dataontap/client/client_cmode.py b/manila/share/drivers/netapp/dataontap/client/client_cmode.py index e16b8e8d3a..58a1db806f 100644 --- a/manila/share/drivers/netapp/dataontap/client/client_cmode.py +++ b/manila/share/drivers/netapp/dataontap/client/client_cmode.py @@ -2649,7 +2649,7 @@ class NetAppCmodeClient(client_base.NetAppBaseClient): try: client.delete_nfs_export_policy(policy) except netapp_api.NaApiError: - LOG.debug('Could not delete export policy %s.' % policy) + LOG.debug('Could not delete export policy %s.', policy) @na_utils.trace def _get_deleted_nfs_export_policies(self): @@ -2717,7 +2717,7 @@ class NetAppCmodeClient(client_base.NetAppBaseClient): node_client.send_request('ems-autosupport-log', message_dict) LOG.debug('EMS executed successfully.') except netapp_api.NaApiError as e: - LOG.warning('Failed to invoke EMS. %s' % e) + LOG.warning('Failed to invoke EMS. %s', e) @na_utils.trace def get_aggregate(self, aggregate_name): @@ -2741,7 +2741,7 @@ class NetAppCmodeClient(client_base.NetAppBaseClient): desired_attributes=desired_attributes) except netapp_api.NaApiError: msg = _('Failed to get info for aggregate %s.') - LOG.exception(msg % aggregate_name) + LOG.exception(msg, aggregate_name) return {} if len(aggrs) < 1: @@ -2814,7 +2814,7 @@ class NetAppCmodeClient(client_base.NetAppBaseClient): result = self.send_iter_request('storage-disk-get-iter', api_args) except netapp_api.NaApiError: msg = _('Failed to get disk info for aggregate %s.') - LOG.exception(msg % aggregate_name) + LOG.exception(msg, aggregate_name) return disk_types attributes_list = result.get_child_by_name( diff --git a/manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py b/manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py index f914df2e46..ebb1d07336 100644 --- a/manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py +++ b/manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py @@ -173,7 +173,7 @@ class NetAppCmodeFileStorageLibrary(object): if 'nfs' not in self._licenses and 'cifs' not in self._licenses: msg = 'Neither NFS nor CIFS is licensed on %(backend)s' msg_args = {'backend': self._backend_name} - LOG.error(msg % msg_args) + LOG.error(msg, msg_args) return self._licenses @@ -1064,7 +1064,7 @@ class NetAppCmodeFileStorageLibrary(object): msg = _('Could not determine snapshot %(snap)s size from ' 'volume %(vol)s.') msg_args = {'snap': existing_snapshot_name, 'vol': share_name} - LOG.exception(msg % msg_args) + LOG.exception(msg, msg_args) raise exception.ShareNotFound(share_id=snapshot['share_id']) # Ensure there aren't any mirrors on this volume @@ -2139,7 +2139,7 @@ class NetAppCmodeFileStorageLibrary(object): math.ceil(float(backend_volume['size']) / units.Gi)) LOG.debug("Checking for a pre-existing QoS policy group that " - "is exclusive to the volume %s." % backend_share_name) + "is exclusive to the volume %s.", backend_share_name) # Does the volume have an exclusive QoS policy that we can rename? if backend_volume['qos-policy-group-name'] is not None: diff --git a/manila/share/drivers/netapp/dataontap/cluster_mode/lib_multi_svm.py b/manila/share/drivers/netapp/dataontap/cluster_mode/lib_multi_svm.py index e2f9509baf..2f715b0f18 100644 --- a/manila/share/drivers/netapp/dataontap/cluster_mode/lib_multi_svm.py +++ b/manila/share/drivers/netapp/dataontap/cluster_mode/lib_multi_svm.py @@ -247,7 +247,7 @@ class NetAppCmodeMultiSVMFileStorageLibrary( network_allocations = network_info.get('admin_network_allocations') if not network_allocations: - LOG.info('No admin network defined for Vserver %s.' % + LOG.info('No admin network defined for Vserver %s.', vserver_name) return diff --git a/manila/share/drivers/netapp/dataontap/cluster_mode/lib_single_svm.py b/manila/share/drivers/netapp/dataontap/cluster_mode/lib_single_svm.py index 7c3d556a42..aeaf25ad24 100644 --- a/manila/share/drivers/netapp/dataontap/cluster_mode/lib_single_svm.py +++ b/manila/share/drivers/netapp/dataontap/cluster_mode/lib_single_svm.py @@ -77,7 +77,7 @@ class NetAppCmodeSingleSVMFileStorageLibrary( msg_args = {'vserver': self._vserver, 'backend': self._backend_name} msg_args['creds'] = ('cluster' if self._have_cluster_creds else 'Vserver') - LOG.info(msg % msg_args) + LOG.info(msg, msg_args) (super(NetAppCmodeSingleSVMFileStorageLibrary, self). check_for_setup_error()) diff --git a/manila/share/drivers/netapp/dataontap/protocols/nfs_cmode.py b/manila/share/drivers/netapp/dataontap/protocols/nfs_cmode.py index c67927a5aa..81b855697f 100644 --- a/manila/share/drivers/netapp/dataontap/protocols/nfs_cmode.py +++ b/manila/share/drivers/netapp/dataontap/protocols/nfs_cmode.py @@ -89,14 +89,14 @@ class NetAppCmodeNFSHelper(base.NetAppBaseHelper): # Rename policy currently in force LOG.info('Renaming NFS export policy for share %(share)s to ' - '%(policy)s.' % + '%(policy)s.', {'share': share_name, 'policy': temp_old_export_policy_name}) self._client.rename_nfs_export_policy(export_policy_name, temp_old_export_policy_name) # Switch share to the new policy LOG.info('Setting NFS export policy for share %(share)s to ' - '%(policy)s.' % + '%(policy)s.', {'share': share_name, 'policy': temp_new_export_policy_name}) self._client.set_nfs_export_policy_for_volume( share_name, temp_new_export_policy_name) @@ -106,7 +106,7 @@ class NetAppCmodeNFSHelper(base.NetAppBaseHelper): # Rename new policy to its final name LOG.info('Renaming NFS export policy for share %(share)s to ' - '%(policy)s.' % + '%(policy)s.', {'share': share_name, 'policy': export_policy_name}) self._client.rename_nfs_export_policy(temp_new_export_policy_name, export_policy_name) diff --git a/manila/share/drivers/netapp/utils.py b/manila/share/drivers/netapp/utils.py index f7e315bf9d..1549efcafe 100644 --- a/manila/share/drivers/netapp/utils.py +++ b/manila/share/drivers/netapp/utils.py @@ -74,7 +74,7 @@ def setup_tracing(trace_flags_string): flags = trace_flags_string.split(',') flags = [flag.strip() for flag in flags] for invalid_flag in list(set(flags) - set(VALID_TRACE_FLAGS)): - LOG.warning('Invalid trace flag: %s' % invalid_flag) + LOG.warning('Invalid trace flag: %s', invalid_flag) TRACE_METHOD = 'method' in flags TRACE_API = 'api' in flags @@ -164,7 +164,7 @@ class OpenStackInfo(object): "'%{version}\t%{release}\t%{vendor}'", self.PACKAGE_NAME) if not out: - LOG.info('No rpm info found for %(pkg)s package.' % { + LOG.info('No rpm info found for %(pkg)s package.', { 'pkg': self.PACKAGE_NAME}) return False parts = out.split() @@ -173,7 +173,7 @@ class OpenStackInfo(object): self._vendor = ' '.join(parts[2::]) return True except Exception as e: - LOG.info('Could not run rpm command: %(msg)s.' % { + LOG.info('Could not run rpm command: %(msg)s.', { 'msg': e}) return False @@ -186,7 +186,7 @@ class OpenStackInfo(object): self.PACKAGE_NAME) if not out: LOG.info( - 'No dpkg-query info found for %(pkg)s package.' % { + 'No dpkg-query info found for %(pkg)s package.', { 'pkg': self.PACKAGE_NAME}) return False # Debian format: [epoch:]upstream_version[-debian_revision] @@ -204,7 +204,7 @@ class OpenStackInfo(object): self._vendor = _vendor return True except Exception as e: - LOG.info('Could not run dpkg-query command: %(msg)s.' % { + LOG.info('Could not run dpkg-query command: %(msg)s.', { 'msg': e}) return False diff --git a/manila/share/drivers/quobyte/jsonrpc.py b/manila/share/drivers/quobyte/jsonrpc.py index cfa031e68b..6b73ae2fc7 100644 --- a/manila/share/drivers/quobyte/jsonrpc.py +++ b/manila/share/drivers/quobyte/jsonrpc.py @@ -97,7 +97,7 @@ class JsonRpc(object): return self._checked_for_application_error(response) # If things did not work out provide error info - LOG.debug("Backend request resulted in error: %s" % result.text) + LOG.debug("Backend request resulted in error: %s", result.text) result.raise_for_status() def _checked_for_application_error(self, result): diff --git a/manila/share/drivers/quobyte/quobyte.py b/manila/share/drivers/quobyte/quobyte.py index e6339f1d8a..f6dd62896c 100644 --- a/manila/share/drivers/quobyte/quobyte.py +++ b/manila/share/drivers/quobyte/quobyte.py @@ -245,9 +245,9 @@ class QuobyteShareDriver(driver.ExecuteMixin, driver.ShareDriver,): self._get_project_name(context, share['project_id'])) if not volume_uuid: LOG.warning("No volume found for " - "share %(project_id)s/%(name)s" - % {"project_id": share['project_id'], - "name": share['name']}) + "share %(project_id)s/%(name)s", + {"project_id": share['project_id'], + "name": share['name']}) return if self.configuration.quobyte_delete_shares: @@ -274,7 +274,7 @@ class QuobyteShareDriver(driver.ExecuteMixin, driver.ShareDriver,): share['name'], self._get_project_name(context, share['project_id'])) - LOG.debug("Ensuring Quobyte share %s" % share['name']) + LOG.debug("Ensuring Quobyte share %s", share['name']) if not volume_uuid: raise (exception.ShareResourceNotFound( diff --git a/manila/share/drivers/service_instance.py b/manila/share/drivers/service_instance.py index e1630bb690..3a3b57b70d 100644 --- a/manila/share/drivers/service_instance.py +++ b/manila/share/drivers/service_instance.py @@ -642,7 +642,7 @@ class ServiceInstanceManager(object): break LOG.debug("Waiting for instance %(instance_id)s to be active. " - "Current status: %(instance_status)s." % + "Current status: %(instance_status)s.", dict(instance_id=instance_id, instance_status=instance_status)) time.sleep(1) @@ -960,7 +960,7 @@ class NeutronNetworkHelper(BaseNetworkhelper): except Exception as e: if 'does not exist' in six.text_type(e): LOG.warning( - "Device %s does not exist anymore." % device.name) + "Device %s does not exist anymore.", device.name) else: raise for addr in addr_list: diff --git a/manila/share/drivers/windows/windows_smb_helper.py b/manila/share/drivers/windows/windows_smb_helper.py index f54e8ec316..8cb910ee7a 100644 --- a/manila/share/drivers/windows/windows_smb_helper.py +++ b/manila/share/drivers/windows/windows_smb_helper.py @@ -209,9 +209,9 @@ class WindowsSMBHelper(helpers.CIFSHelperBase): LOG.warning( "Unsupported access level %(level)s or access type " "%(type)s, skipping removal of access rule to " - "%(to)s." % {'level': deleted_rule['access_level'], - 'type': deleted_rule['access_type'], - 'to': deleted_rule['access_to']}) + "%(to)s.", {'level': deleted_rule['access_level'], + 'type': deleted_rule['access_type'], + 'to': deleted_rule['access_to']}) continue self._revoke_share_access(server, share_name, deleted_rule['access_to']) diff --git a/manila/share/drivers/zfsonlinux/driver.py b/manila/share/drivers/zfsonlinux/driver.py index 3b7ce2d7e7..8a9141caf9 100644 --- a/manila/share/drivers/zfsonlinux/driver.py +++ b/manila/share/drivers/zfsonlinux/driver.py @@ -1550,5 +1550,5 @@ class ZFSonLinuxShareDriver(zfs_utils.ExecuteMixin, driver.ShareDriver): e) LOG.debug( - "Migration of share with ID '%s' has been canceled." % + "Migration of share with ID '%s' has been canceled.", source_share["id"]) diff --git a/manila/share/manager.py b/manila/share/manager.py index cec9a1a5b1..8d3c0ba551 100644 --- a/manila/share/manager.py +++ b/manila/share/manager.py @@ -1956,7 +1956,7 @@ class ShareManager(manager.SchedulerDependentManager): msg = _("The driver was unable to delete access rules " "for the replica: %s. Will attempt to delete " "the replica anyway.") - LOG.exception(msg % share_replica['id']) + LOG.exception(msg, share_replica['id']) exc_context.reraise = False try: @@ -3265,7 +3265,7 @@ class ShareManager(manager.SchedulerDependentManager): share_server = self._get_share_server(context, share_instance) LOG.debug("Received request to update access for share instance" - " %s." % share_instance_id) + " %s.", share_instance_id) self.access_helper.update_access_rules( context, diff --git a/manila/tests/fake_utils.py b/manila/tests/fake_utils.py index 1531819295..0c0002c8ed 100644 --- a/manila/tests/fake_utils.py +++ b/manila/tests/fake_utils.py @@ -77,7 +77,7 @@ def fake_execute(*cmd_parts, **kwargs): for fake_replier in _fake_execute_repliers: if re.match(fake_replier[0], cmd_str): reply_handler = fake_replier[1] - LOG.debug('Faked command matched %s' % fake_replier[0]) + LOG.debug('Faked command matched %s', fake_replier[0]) break if isinstance(reply_handler, six.string_types): diff --git a/manila/tests/message/test_api.py b/manila/tests/message/test_api.py index e1d61d8b71..a75c3aafe5 100644 --- a/manila/tests/message/test_api.py +++ b/manila/tests/message/test_api.py @@ -71,7 +71,8 @@ class MessageApiTest(test.TestCase): self.message_api.db.message_create.assert_called_once_with( self.ctxt, mock.ANY) exception_log.assert_called_once_with( - 'Failed to create message record for request_id fakerequestid') + 'Failed to create message record for request_id %s', + self.ctxt.request_id) def test_get(self): self.message_api.get(self.ctxt, 'fake_id') diff --git a/manila/tests/share/drivers/dummy.py b/manila/tests/share/drivers/dummy.py index 5d77bdc628..ec6c27c0a4 100644 --- a/manila/tests/share/drivers/dummy.py +++ b/manila/tests/share/drivers/dummy.py @@ -416,13 +416,13 @@ class DummyDriver(driver.ShareDriver): @slow_me_down def create_cgsnapshot(self, context, snap_dict, share_server=None): """Create a consistency group snapshot.""" - LOG.debug("Successfully created CG snapshot %s." % snap_dict["id"]) + LOG.debug("Successfully created CG snapshot %s.", snap_dict["id"]) return None, None @slow_me_down def delete_cgsnapshot(self, context, snap_dict, share_server=None): """Delete a consistency group snapshot.""" - LOG.debug("Successfully deleted CG snapshot %s." % snap_dict["id"]) + LOG.debug("Successfully deleted CG snapshot %s.", snap_dict["id"]) return None, None @slow_me_down @@ -545,7 +545,7 @@ class DummyDriver(driver.ShareDriver): """ LOG.debug( - "Migration of dummy share with ID '%s' has been started." % + "Migration of dummy share with ID '%s' has been started.", source_share["id"]) self.migration_progress[source_share['share_id']] = 0 @@ -561,9 +561,9 @@ class DummyDriver(driver.ShareDriver): self.migration_progress[source_share["id"]] += 50 LOG.debug( - "Migration of dummy share with ID '%s' is continuing, %s." % - (source_share["id"], - self.migration_progress[source_share["id"]])) + "Migration of dummy share with ID '%s' is continuing, %s.", + source_share["id"], + self.migration_progress[source_share["id"]]) return self.migration_progress[source_share["id"]] == 100 @@ -596,7 +596,7 @@ class DummyDriver(driver.ShareDriver): } ) LOG.debug( - "Migration of dummy share with ID '%s' has been completed." % + "Migration of dummy share with ID '%s' has been completed.", source_share_ref["id"]) self.migration_progress.pop(source_share_ref["id"], None) @@ -610,7 +610,7 @@ class DummyDriver(driver.ShareDriver): destination_share_server=None): """Is called to cancel driver migration.""" LOG.debug( - "Migration of dummy share with ID '%s' has been canceled." % + "Migration of dummy share with ID '%s' has been canceled.", source_share["id"]) self.migration_progress.pop(source_share["id"], None) diff --git a/manila/tests/share/drivers/quobyte/test_quobyte.py b/manila/tests/share/drivers/quobyte/test_quobyte.py index 8a04da8075..9d9df102cc 100644 --- a/manila/tests/share/drivers/quobyte/test_quobyte.py +++ b/manila/tests/share/drivers/quobyte/test_quobyte.py @@ -192,7 +192,8 @@ class QuobyteShareDriverTestCase(test.TestCase): self._driver.delete_share(self._context, self.share) mock_warning.assert_called_with( - 'No volume found for share fake_project_uuid/fakename') + 'No volume found for share %(project_id)s/%(name)s', + {'project_id': 'fake_project_uuid', 'name': 'fakename'}) def test_allow_access(self): def rpc_handler(name, *args): diff --git a/manila_tempest_tests/common/remote_client.py b/manila_tempest_tests/common/remote_client.py index 29f1b49863..45f85d85f7 100644 --- a/manila_tempest_tests/common/remote_client.py +++ b/manila_tempest_tests/common/remote_client.py @@ -80,7 +80,7 @@ class RemoteClient(object): # Shell options below add more clearness on failures, # path is extended for some non-cirros guest oses (centos7) cmd = CONF.validation.ssh_shell_prologue + " " + cmd - LOG.debug("Remote command: %s" % cmd) + LOG.debug("Remote command: %s", cmd) return self.ssh_client.exec_command(cmd) @debug_ssh diff --git a/manila_tempest_tests/tests/api/base.py b/manila_tempest_tests/tests/api/base.py index 65f1b30546..d190b63e2a 100644 --- a/manila_tempest_tests/tests/api/base.py +++ b/manila_tempest_tests/tests/api/base.py @@ -91,7 +91,7 @@ class handle_cleanup_exceptions(object): return False # Do not suppress error if any if exc_traceback: LOG.error("Suppressed cleanup error in Manila: " - "\n%s" % traceback.format_exc()) + "\n%s", traceback.format_exc()) return True # Suppress error if any @@ -925,7 +925,7 @@ class BaseSharesTest(test.BaseTestCase): client.wait_for_resource_deletion(replica_id=res_id) else: LOG.warning("Provided unsupported resource type for " - "cleanup '%s'. Skipping." % res["type"]) + "cleanup '%s'. Skipping.", res["type"]) res["deleted"] = True @classmethod diff --git a/manila_tempest_tests/tests/api/test_security_services.py b/manila_tempest_tests/tests/api/test_security_services.py index 2e287039d9..fd884f2b48 100644 --- a/manila_tempest_tests/tests/api/test_security_services.py +++ b/manila_tempest_tests/tests/api/test_security_services.py @@ -183,7 +183,7 @@ class SecurityServicesTest(base.BaseSharesTest, LOG.warning("Caught exception. It is expected in case backend " "fails having security-service with improper data " "that leads to share-server creation error. " - "%s" % six.text_type(e)) + "%s", six.text_type(e)) update_data = { "name": "name", diff --git a/manila_tempest_tests/tests/api/test_security_services_mapping_negative.py b/manila_tempest_tests/tests/api/test_security_services_mapping_negative.py index d60b458332..c63e7cefd1 100644 --- a/manila_tempest_tests/tests/api/test_security_services_mapping_negative.py +++ b/manila_tempest_tests/tests/api/test_security_services_mapping_negative.py @@ -115,7 +115,7 @@ class SecServicesMappingNegativeTest(base.BaseSharesTest): LOG.warning("Caught exception. It is expected in case backend " "fails having security-service with improper data " "that leads to share-server creation error. " - "%s" % six.text_type(e)) + "%s", six.text_type(e)) self.assertRaises(lib_exc.Forbidden, self.cl.remove_sec_service_from_share_network, diff --git a/manila_tempest_tests/tests/api/test_security_services_negative.py b/manila_tempest_tests/tests/api/test_security_services_negative.py index eb871a6625..cfa97bfbcf 100644 --- a/manila_tempest_tests/tests/api/test_security_services_negative.py +++ b/manila_tempest_tests/tests/api/test_security_services_negative.py @@ -101,7 +101,7 @@ class SecurityServicesNegativeTest(base.BaseSharesTest): LOG.warning("Caught exception. It is expected in case backend " "fails having security-service with improper data " "that leads to share-server creation error. " - "%s" % six.text_type(e)) + "%s", six.text_type(e)) self.assertRaises(lib_exc.Forbidden, self.shares_client.update_security_service, diff --git a/manila_tempest_tests/tests/scenario/manager_share.py b/manila_tempest_tests/tests/scenario/manager_share.py index 6c25785b93..1c671828d0 100644 --- a/manila_tempest_tests/tests/scenario/manager_share.py +++ b/manila_tempest_tests/tests/scenario/manager_share.py @@ -228,7 +228,7 @@ class ShareScenarioTest(manager.NetworkScenarioTest): try: linux_client.validate_authentication() except Exception: - LOG.exception('Initializing SSH connection to %s failed' % ip) + LOG.exception('Initializing SSH connection to %s failed', ip) self._log_console_output() raise diff --git a/manila_tempest_tests/tests/scenario/test_share_basic_ops.py b/manila_tempest_tests/tests/scenario/test_share_basic_ops.py index ea79ef22bc..7dba83b4cf 100644 --- a/manila_tempest_tests/tests/scenario/test_share_basic_ops.py +++ b/manila_tempest_tests/tests/scenario/test_share_basic_ops.py @@ -189,7 +189,7 @@ class ShareBasicOpsBase(manager.ShareScenarioTest): first_address = net_addresses.values()[0][0] ip = first_address['addr'] except Exception: - LOG.debug("Instance: %s" % instance) + LOG.debug("Instance: %s", instance) # In case on an error ip will be still none LOG.exception("Instance does not have a valid IP address." "Falling back to default") diff --git a/tox.ini b/tox.ini index df645c0b97..263ff8b73a 100644 --- a/tox.ini +++ b/tox.ini @@ -112,6 +112,11 @@ commands = alembic -c manila/db/migrations/alembic.ini revision -m ""{posargs} # Following checks are ignored on purpose: ignore = builtins = _ +# [H106] Don't put vim configuration in source files. +# [H203] Use assertIs(Not)None to check for None. +# [H904] Use ',' instead of '%', String interpolation should be delayed to be handled by the logging code, +# rather than being done at the point of the logging call.. +enable-extensions = H106,H203,H904 exclude = .git,.tox,.testrepository,.venv,build,cover,dist,doc,*egg,api-ref/build,*/source/conf.py [hacking]