Browse Source

Replace string format arguments with function parameters

There are files containing string format arguments inside logging
messages. Using logging function parameters should be preferred.

Change-Id: Id558f66de13146f6ae76a7a69f49721b6c3d6257
Closes-Bug: #1321274
changes/04/282604/2
ting.wang 6 years ago
parent
commit
b9aa042293
  1. 12
      magnum/api/controllers/v1/container.py
  2. 6
      magnum/cmd/api.py
  3. 2
      magnum/cmd/conductor.py
  4. 8
      magnum/common/utils.py
  5. 4
      magnum/conductor/handlers/bay_conductor.py
  6. 8
      magnum/conductor/handlers/common/cert_manager.py
  7. 10
      magnum/conductor/handlers/docker_conductor.py
  8. 2
      magnum/conductor/handlers/x509keypair_conductor.py
  9. 2
      magnum/conductor/k8s_api.py
  10. 2
      magnum/conductor/monitors.py
  11. 4
      magnum/conductor/scale_manager.py
  12. 4
      magnum/service/periodic.py

12
magnum/api/controllers/v1/container.py

@ -177,7 +177,7 @@ class StartController(object):
container_uuid = api_utils.get_rpc_resource('Container',
container_ident).uuid
LOG.debug('Calling conductor.container_start with %s' %
LOG.debug('Calling conductor.container_start with %s',
container_uuid)
return pecan.request.rpcapi.container_start(container_uuid)
@ -190,7 +190,7 @@ class StopController(object):
% pecan.request.method))
container_uuid = api_utils.get_rpc_resource('Container',
container_ident).uuid
LOG.debug('Calling conductor.container_stop with %s' %
LOG.debug('Calling conductor.container_stop with %s',
container_uuid)
return pecan.request.rpcapi.container_stop(container_uuid)
@ -203,7 +203,7 @@ class RebootController(object):
% pecan.request.method))
container_uuid = api_utils.get_rpc_resource('Container',
container_ident).uuid
LOG.debug('Calling conductor.container_reboot with %s' %
LOG.debug('Calling conductor.container_reboot with %s',
container_uuid)
return pecan.request.rpcapi.container_reboot(container_uuid)
@ -216,7 +216,7 @@ class PauseController(object):
% pecan.request.method))
container_uuid = api_utils.get_rpc_resource('Container',
container_ident).uuid
LOG.debug('Calling conductor.container_pause with %s' %
LOG.debug('Calling conductor.container_pause with %s',
container_uuid)
return pecan.request.rpcapi.container_pause(container_uuid)
@ -229,7 +229,7 @@ class UnpauseController(object):
% pecan.request.method))
container_uuid = api_utils.get_rpc_resource('Container',
container_ident).uuid
LOG.debug('Calling conductor.container_unpause with %s' %
LOG.debug('Calling conductor.container_unpause with %s',
container_uuid)
return pecan.request.rpcapi.container_unpause(container_uuid)
@ -242,7 +242,7 @@ class LogsController(object):
% pecan.request.method))
container_uuid = api_utils.get_rpc_resource('Container',
container_ident).uuid
LOG.debug('Calling conductor.container_logs with %s' %
LOG.debug('Calling conductor.container_logs with %s',
container_uuid)
return pecan.request.rpcapi.container_logs(container_uuid)

6
magnum/cmd/api.py

@ -46,16 +46,16 @@ def main():
host, port = cfg.CONF.api.host, cfg.CONF.api.port
srv = simple_server.make_server(host, port, app)
LOG.info(_LI('Starting server in PID %s') % os.getpid())
LOG.info(_LI('Starting server in PID %s'), os.getpid())
LOG.debug("Configuration:")
cfg.CONF.log_opt_values(LOG, logging.DEBUG)
if host == '0.0.0.0':
LOG.info(_LI('serving on 0.0.0.0:%(port)s, '
'view at http://127.0.0.1:%(port)s') %
'view at http://127.0.0.1:%(port)s'),
dict(port=port))
else:
LOG.info(_LI('serving on http://%(host)s:%(port)s') %
LOG.info(_LI('serving on http://%(host)s:%(port)s'),
dict(host=host, port=port))
srv.serve_forever()

2
magnum/cmd/conductor.py

@ -44,7 +44,7 @@ def main():
gmr.TextGuruMeditation.setup_autorun(version)
LOG.info(_LI('Starting server in PID %s') % os.getpid())
LOG.info(_LI('Starting server in PID %s'), os.getpid())
LOG.debug("Configuration:")
cfg.CONF.log_opt_values(LOG, logging.DEBUG)

8
magnum/common/utils.py

@ -99,8 +99,8 @@ def execute(*cmd, **kwargs):
result = processutils.execute(*cmd, **kwargs)
LOG.debug('Execution completed, command line is "%s"',
' '.join(map(str, cmd)))
LOG.debug('Command stdout is: "%s"' % result[0])
LOG.debug('Command stderr is: "%s"' % result[1])
LOG.debug('Command stdout is: "%s"', result[0])
LOG.debug('Command stderr is: "%s"', result[1])
return result
@ -145,7 +145,7 @@ def ssh_connect(connection):
# send TCP keepalive packets every 20 seconds
ssh.get_transport().set_keepalive(20)
except Exception as e:
LOG.debug("SSH connect failed: %s" % e)
LOG.debug("SSH connect failed: %s", e)
raise exception.SSHConnectFailed(host=connection.get('host'))
return ssh
@ -320,7 +320,7 @@ def read_cached_file(filename, cache_info, reload_func=None):
"""
mtime = os.path.getmtime(filename)
if not cache_info or mtime != cache_info.get('mtime'):
LOG.debug("Reloading cached file %s" % filename)
LOG.debug("Reloading cached file %s", filename)
with open(filename) as fap:
cache_info['data'] = fap.read()
cache_info['mtime'] = mtime

4
magnum/conductor/handlers/bay_conductor.py

@ -208,12 +208,12 @@ class Handler(object):
osc.heat().stacks.delete(stack_id)
except exc.HTTPNotFound:
LOG.info(_LI('The stack %s was not be found during bay'
' deletion.') % stack_id)
' deletion.'), stack_id)
try:
cert_manager.delete_certificates_from_bay(bay)
bay.destroy()
except exception.BayNotFound:
LOG.info(_LI('The bay %s has been deleted by others.') % uuid)
LOG.info(_LI('The bay %s has been deleted by others.'), uuid)
return None
except Exception:
raise

8
magnum/conductor/handlers/common/cert_manager.py

@ -42,7 +42,7 @@ def _generate_ca_cert(issuer_name):
private_key_passphrase=ca_password,
name=issuer_name,
)
LOG.debug('CA cert is created: %s' % ca_cert_ref)
LOG.debug('CA cert is created: %s', ca_cert_ref)
return ca_cert_ref, ca_cert, ca_password
@ -68,7 +68,7 @@ def _generate_client_cert(issuer_name, ca_cert, ca_password):
private_key_passphrase=client_password,
name=CONDUCTOR_CLIENT_NAME,
)
LOG.debug('Magnum client cert is created: %s' % magnum_cert_ref)
LOG.debug('Magnum client cert is created: %s', magnum_cert_ref)
return magnum_cert_ref
@ -89,7 +89,7 @@ def generate_certificates_to_bay(bay):
"""
issuer_name = _get_issuer_name(bay)
LOG.debug('Start to generate certificates: %s' % issuer_name)
LOG.debug('Start to generate certificates: %s', issuer_name)
ca_cert_ref, ca_cert, ca_password = _generate_ca_cert(issuer_name)
magnum_cert_ref = _generate_client_cert(issuer_name, ca_cert, ca_password)
@ -159,4 +159,4 @@ def delete_certificates_from_bay(bay):
cert_manager.get_backend().CertManager.delete_cert(
cert_ref, resource_ref=bay.uuid)
except Exception:
LOG.warning(_LW("Deleting cert is failed: %s") % cert_ref)
LOG.warning(_LW("Deleting cert is failed: %s"), cert_ref)

10
magnum/conductor/handlers/docker_conductor.py

@ -95,7 +95,7 @@ class Handler(object):
@wrap_container_exception
def container_delete(self, context, container_uuid):
LOG.debug("container_delete %s" % container_uuid)
LOG.debug("container_delete %s", container_uuid)
with docker_utils.docker_for_container(context,
container_uuid) as docker:
docker_id = self._find_container_by_name(docker,
@ -106,7 +106,7 @@ class Handler(object):
@wrap_container_exception
def container_show(self, context, container_uuid):
LOG.debug("container_show %s" % container_uuid)
LOG.debug("container_show %s", container_uuid)
with docker_utils.docker_for_container(context,
container_uuid) as docker:
container = objects.Container.get_by_uuid(context, container_uuid)
@ -143,7 +143,7 @@ class Handler(object):
@wrap_container_exception
def _container_action(self, context, container_uuid, status, docker_func):
LOG.debug("%s container %s ..." % (docker_func, container_uuid))
LOG.debug("%s container %s ...", (docker_func, container_uuid))
with docker_utils.docker_for_container(context,
container_uuid) as docker:
docker_id = self._find_container_by_name(docker,
@ -179,7 +179,7 @@ class Handler(object):
@wrap_container_exception
def container_logs(self, context, container_uuid):
LOG.debug("container_logs %s" % container_uuid)
LOG.debug("container_logs %s", container_uuid)
with docker_utils.docker_for_container(context,
container_uuid) as docker:
docker_id = self._find_container_by_name(docker,
@ -188,7 +188,7 @@ class Handler(object):
@wrap_container_exception
def container_exec(self, context, container_uuid, command):
LOG.debug("container_exec %s command %s" %
LOG.debug("container_exec %s command %s",
(container_uuid, command))
with docker_utils.docker_for_container(context,
container_uuid) as docker:

2
magnum/conductor/handlers/x509keypair_conductor.py

@ -37,6 +37,6 @@ class Handler(object):
return x509keypair
def x509keypair_delete(self, context, uuid):
LOG.debug("Deleting x509keypair %s" % uuid)
LOG.debug("Deleting x509keypair %s", uuid)
x509keypair = objects.X509KeyPair.get_by_uuid(context, uuid)
x509keypair.destroy(context)

2
magnum/conductor/k8s_api.py

@ -38,7 +38,7 @@ class K8sAPI(apiv_api.ApivApi):
tmp.write(content)
tmp.flush()
except Exception as err:
LOG.error("Error while creating temp file: %s" % err)
LOG.error("Error while creating temp file: %s", err)
raise err
return tmp

2
magnum/conductor/monitors.py

@ -72,5 +72,5 @@ def create_monitor(context, bay):
coe_cls = importutils.import_class(COE_CLASS_PATH[bay.baymodel.coe])
return coe_cls(context, bay)
LOG.debug("Cannot create monitor with bay type '%s'" % bay.baymodel.coe)
LOG.debug("Cannot create monitor with bay type '%s'", bay.baymodel.coe)
return None

4
magnum/conductor/scale_manager.py

@ -53,7 +53,7 @@ class ScaleManager(object):
if host in hosts_no_container:
hosts_no_container.remove(host)
LOG.debug('List of hosts that has no container: %s' %
LOG.debug('List of hosts that has no container: %s',
str(hosts_no_container))
num_of_removal = self._get_num_of_removal()
@ -67,7 +67,7 @@ class ScaleManager(object):
'num_non_empty': num_of_removal - len(hosts_no_container)})
hosts_to_remove = hosts_no_container[0:num_of_removal]
LOG.info(_LI('Require removal of hosts: %s') % hosts_to_remove)
LOG.info(_LI('Require removal of hosts: %s'), hosts_to_remove)
return hosts_to_remove

4
magnum/service/periodic.py

@ -125,7 +125,7 @@ class MagnumPeriodicTasks(periodic_task.PeriodicTasks):
try:
bay.destroy()
except exception.BayNotFound:
LOG.info(_LI('The bay %s has been deleted by others.') % bay.uuid)
LOG.info(_LI('The bay %s has been deleted by others.'), bay.uuid)
else:
LOG.info(_LI("Bay with id %(id)s not found in heat "
"with stack id %(sid)s, with status_reason: "
@ -182,7 +182,7 @@ class MagnumPeriodicTasks(periodic_task.PeriodicTasks):
user_id=bay.user_id,
project_id=bay.project_id,
resource_id=bay.uuid)
LOG.debug("About to send notification: '%s'" % message)
LOG.debug("About to send notification: '%s'", message)
self.notifier.info(ctx, "magnum.bay.metrics.update",
message)

Loading…
Cancel
Save