Browse Source

Add a hacking rule for string interpolation at logging

String interpolation should be delayed to be handled
by the logging code, rather than being done at the point
of the logging call.
See the oslo i18n guideline
* https://docs.openstack.org/oslo.i18n/latest/user/guidelines.html#adding-variables-to-log-messages
and
* https://github.com/openstack-dev/hacking/blob/master/hacking/checks/other.py#L39

Change-Id: I8a4f5f896865aebbff88ee894f0081e58cfce9ef
tags/5.0.0
coldmoment 2 years ago
parent
commit
ba8ad5e37f

+ 1
- 0
HACKING.rst View File

@@ -21,3 +21,4 @@ Magnum Specific Commandments
21 21
 - [M339] Don't use xrange()
22 22
 - [M340] Check for explicit import of the _ function.
23 23
 - [M352] LOG.warn is deprecated. Enforce use of LOG.warning.
24
+- [M353] String interpolation should be delayed at logging calls.

+ 1
- 1
magnum/api/app.py View File

@@ -59,7 +59,7 @@ def load_app():
59 59
 
60 60
     if not cfg_file:
61 61
         raise cfg.ConfigFilesNotFoundError([CONF.api.api_paste_config])
62
-    LOG.info("Full WSGI config used: %s" % cfg_file)
62
+    LOG.info("Full WSGI config used: %s", cfg_file)
63 63
     return deploy.loadapp("config:" + cfg_file)
64 64
 
65 65
 

+ 1
- 1
magnum/api/controllers/v1/bay.py View File

@@ -361,7 +361,7 @@ class BaysController(base.Controller):
361 361
             failed_resources = []
362 362
             LOG.warning("Failed to retrieve failed resources for "
363 363
                         "bay %(bay)s from Heat stack %(stack)s "
364
-                        "due to error: %(e)s" %
364
+                        "due to error: %(e)s",
365 365
                         {'bay': bay.uuid, 'stack': bay.stack_id, 'e': e},
366 366
                         exc_info=True)
367 367
 

+ 1
- 1
magnum/api/controllers/v1/cluster.py View File

@@ -334,7 +334,7 @@ class ClustersController(base.Controller):
334 334
             failed_resources = []
335 335
             LOG.warning("Failed to retrieve failed resources for "
336 336
                         "cluster %(cluster)s from Heat stack "
337
-                        "%(stack)s due to error: %(e)s" %
337
+                        "%(stack)s due to error: %(e)s",
338 338
                         {'cluster': cluster.uuid,
339 339
                          'stack': cluster.stack_id, 'e': e},
340 340
                         exc_info=True)

+ 3
- 3
magnum/cmd/api.py View File

@@ -72,17 +72,17 @@ def main():
72 72
     # Create the WSGI server and start it
73 73
     host, port = CONF.api.host, CONF.api.port
74 74
 
75
-    LOG.info('Starting server in PID %s' % os.getpid())
75
+    LOG.info('Starting server in PID %s', os.getpid())
76 76
     LOG.debug("Configuration:")
77 77
     CONF.log_opt_values(LOG, logging.DEBUG)
78 78
 
79
-    LOG.info('Serving on %(proto)s://%(host)s:%(port)s' %
79
+    LOG.info('Serving on %(proto)s://%(host)s:%(port)s',
80 80
              dict(proto="https" if use_ssl else "http", host=host, port=port))
81 81
 
82 82
     workers = CONF.api.workers
83 83
     if not workers:
84 84
         workers = processutils.get_worker_count()
85 85
     LOG.info('Server will handle each request in a new process up to'
86
-             ' %s concurrent processes' % workers)
86
+             ' %s concurrent processes', workers)
87 87
     serving.run_simple(host, port, app, processes=workers,
88 88
                        ssl_context=_get_ssl_configs(use_ssl))

+ 1
- 1
magnum/cmd/conductor.py View File

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

+ 1
- 1
magnum/common/exception.py View File

@@ -92,7 +92,7 @@ class MagnumException(Exception):
92 92
             # kwargs doesn't match a variable in the message
93 93
             # log the issue and the kwargs
94 94
             LOG.exception('Exception in string format operation, '
95
-                          'kwargs: %s' % kwargs)
95
+                          'kwargs: %s', kwargs)
96 96
             try:
97 97
                 if CONF.fatal_exception_format_errors:
98 98
                     raise

+ 2
- 2
magnum/common/keystone.py View File

@@ -102,8 +102,8 @@ class KeystoneClientV3(object):
102 102
         LOG.warning('Auth plugin and its options for service user '
103 103
                     'must be provided in [%(new)s] section. '
104 104
                     'Using values from [%(old)s] section is '
105
-                    'deprecated.' % {'new': ksconf.CFG_GROUP,
106
-                                     'old': ksconf.CFG_LEGACY_GROUP})
105
+                    'deprecated.', {'new': ksconf.CFG_GROUP,
106
+                                    'old': ksconf.CFG_LEGACY_GROUP})
107 107
 
108 108
         conf = getattr(CONF, ksconf.CFG_LEGACY_GROUP)
109 109
 

+ 1
- 1
magnum/common/urlfetch.py View File

@@ -38,7 +38,7 @@ def get(url, allowed_schemes=('http', 'https')):
38 38
     the allowed_schemes argument.
39 39
     Raise an IOError if getting the data fails.
40 40
     """
41
-    LOG.info('Fetching data from %s' % url)
41
+    LOG.info('Fetching data from %s', url)
42 42
 
43 43
     components = urllib.parse.urlparse(url)
44 44
 

+ 6
- 6
magnum/common/utils.py View File

@@ -85,10 +85,10 @@ def execute(*cmd, **kwargs):
85 85
     if kwargs.get('run_as_root') and 'root_helper' not in kwargs:
86 86
         kwargs['root_helper'] = _get_root_helper()
87 87
     result = processutils.execute(*cmd, **kwargs)
88
-    LOG.debug('Execution completed, command line is "%s"' %
88
+    LOG.debug('Execution completed, command line is "%s"',
89 89
               ' '.join(map(str, cmd)))
90
-    LOG.debug('Command stdout is: "%s"' % result[0])
91
-    LOG.debug('Command stderr is: "%s"' % result[1])
90
+    LOG.debug('Command stdout is: "%s"', result[0])
91
+    LOG.debug('Command stderr is: "%s"', result[1])
92 92
     return result
93 93
 
94 94
 
@@ -125,7 +125,7 @@ def tempdir(**kwargs):
125 125
         try:
126 126
             shutil.rmtree(tmpdir)
127 127
         except OSError as e:
128
-            LOG.error('Could not remove tmpdir: %s' % e)
128
+            LOG.error('Could not remove tmpdir: %s', e)
129 129
 
130 130
 
131 131
 def rmtree_without_raise(path):
@@ -133,7 +133,7 @@ def rmtree_without_raise(path):
133 133
         if os.path.isdir(path):
134 134
             shutil.rmtree(path)
135 135
     except OSError as e:
136
-        LOG.warning("Failed to remove dir %(path)s, error: %(e)s" %
136
+        LOG.warning("Failed to remove dir %(path)s, error: %(e)s",
137 137
                     {'path': path, 'e': e})
138 138
 
139 139
 
@@ -148,7 +148,7 @@ def safe_rstrip(value, chars=None):
148 148
     if not isinstance(value, six.string_types):
149 149
         LOG.warning("Failed to remove trailing character. "
150 150
                     "Returning original object. "
151
-                    "Supplied object is not a string: %s," % value)
151
+                    "Supplied object is not a string: %s,", value)
152 152
         return value
153 153
 
154 154
     return value.rstrip(chars) or value

+ 2
- 2
magnum/conductor/handlers/cluster_conductor.py View File

@@ -151,14 +151,14 @@ class Handler(object):
151 151
             cluster.status_reason = None
152 152
         except exc.HTTPNotFound:
153 153
             LOG.info('The cluster %s was not found during cluster'
154
-                     ' deletion.' % cluster.id)
154
+                     ' deletion.', cluster.id)
155 155
             try:
156 156
                 trust_manager.delete_trustee_and_trust(osc, context, cluster)
157 157
                 cert_manager.delete_certificates_from_cluster(cluster,
158 158
                                                               context=context)
159 159
                 cluster.destroy()
160 160
             except exception.ClusterNotFound:
161
-                LOG.info('The cluster %s has been deleted by others.' %
161
+                LOG.info('The cluster %s has been deleted by others.',
162 162
                          uuid)
163 163
             conductor_utils.notify_about_cluster_operation(
164 164
                 context, taxonomy.ACTION_DELETE, taxonomy.OUTCOME_SUCCESS)

+ 5
- 5
magnum/conductor/handlers/common/cert_manager.py View File

@@ -43,7 +43,7 @@ def _generate_ca_cert(issuer_name, context=None):
43 43
         name=issuer_name,
44 44
         context=context,
45 45
     )
46
-    LOG.debug('CA cert is created: %s' % ca_cert_ref)
46
+    LOG.debug('CA cert is created: %s', ca_cert_ref)
47 47
     return ca_cert_ref, ca_cert, ca_password
48 48
 
49 49
 
@@ -70,7 +70,7 @@ def _generate_client_cert(issuer_name, ca_cert, ca_password, context=None):
70 70
         name=CONDUCTOR_CLIENT_NAME,
71 71
         context=context
72 72
     )
73
-    LOG.debug('Magnum client cert is created: %s' % magnum_cert_ref)
73
+    LOG.debug('Magnum client cert is created: %s', magnum_cert_ref)
74 74
     return magnum_cert_ref
75 75
 
76 76
 
@@ -92,7 +92,7 @@ def generate_certificates_to_cluster(cluster, context=None):
92 92
     try:
93 93
         issuer_name = _get_issuer_name(cluster)
94 94
 
95
-        LOG.debug('Start to generate certificates: %s' % issuer_name)
95
+        LOG.debug('Start to generate certificates: %s', issuer_name)
96 96
 
97 97
         ca_cert_ref, ca_cert, ca_password = _generate_ca_cert(issuer_name,
98 98
                                                               context=context)
@@ -104,7 +104,7 @@ def generate_certificates_to_cluster(cluster, context=None):
104 104
         cluster.ca_cert_ref = ca_cert_ref
105 105
         cluster.magnum_cert_ref = magnum_cert_ref
106 106
     except Exception:
107
-        LOG.exception('Failed to generate certificates for Cluster: %s' %
107
+        LOG.exception('Failed to generate certificates for Cluster: %s',
108 108
                       cluster.uuid)
109 109
         raise exception.CertificatesToClusterFailed(cluster_uuid=cluster.uuid)
110 110
 
@@ -174,5 +174,5 @@ def delete_certificates_from_cluster(cluster, context=None):
174 174
                 cert_manager.get_backend().CertManager.delete_cert(
175 175
                     cert_ref, resource_ref=cluster.uuid, context=context)
176 176
         except Exception:
177
-            LOG.warning("Deleting certs is failed for Cluster %s" %
177
+            LOG.warning("Deleting certs is failed for Cluster %s",
178 178
                         cluster.uuid)

+ 1
- 1
magnum/conductor/handlers/common/trust_manager.py View File

@@ -37,7 +37,7 @@ def create_trustee_and_trust(osc, cluster):
37 37
 
38 38
     except Exception:
39 39
         LOG.exception(
40
-            'Failed to create trustee and trust for Cluster: %s' %
40
+            'Failed to create trustee and trust for Cluster: %s',
41 41
             cluster.uuid)
42 42
         raise exception.TrusteeOrTrustToClusterFailed(
43 43
             cluster_uuid=cluster.uuid)

+ 1
- 1
magnum/conductor/k8s_api.py View File

@@ -37,7 +37,7 @@ class K8sAPI(core_v1_api.CoreV1Api):
37 37
             tmp.write(content)
38 38
             tmp.flush()
39 39
         except Exception as err:
40
-            LOG.error("Error while creating temp file: %s" % err)
40
+            LOG.error("Error while creating temp file: %s", err)
41 41
             raise
42 42
         return tmp
43 43
 

+ 2
- 2
magnum/conductor/scale_manager.py View File

@@ -67,13 +67,13 @@ class ScaleManager(object):
67 67
             LOG.warning(
68 68
                 "About to remove %(num_removal)d nodes, which is larger than "
69 69
                 "the number of empty nodes (%(num_empty)d). %(num_non_empty)d "
70
-                "non-empty nodes will be removed." % {
70
+                "non-empty nodes will be removed.", {
71 71
                     'num_removal': num_of_removal,
72 72
                     'num_empty': len(hosts_no_container),
73 73
                     'num_non_empty': num_of_removal - len(hosts_no_container)})
74 74
 
75 75
         hosts_to_remove = hosts_no_container[0:num_of_removal]
76
-        LOG.info('Require removal of hosts: %s' % hosts_to_remove)
76
+        LOG.info('Require removal of hosts: %s', hosts_to_remove)
77 77
 
78 78
         return hosts_to_remove
79 79
 

+ 6
- 6
magnum/drivers/heat/driver.py View File

@@ -190,8 +190,8 @@ class HeatPoller(object):
190 190
             self._cluster_failed(stack)
191 191
 
192 192
     def _delete_complete(self):
193
-        LOG.info('Cluster has been deleted, stack_id: %s'
194
-                 % self.cluster.stack_id)
193
+        LOG.info('Cluster has been deleted, stack_id: %s',
194
+                 self.cluster.stack_id)
195 195
         try:
196 196
             trust_manager.delete_trustee_and_trust(self.openstack_client,
197 197
                                                    self.context,
@@ -199,8 +199,8 @@ class HeatPoller(object):
199 199
             cert_manager.delete_certificates_from_cluster(self.cluster,
200 200
                                                           context=self.context)
201 201
         except exception.ClusterNotFound:
202
-            LOG.info('The cluster %s has been deleted by others.'
203
-                     % self.cluster.uuid)
202
+            LOG.info('The cluster %s has been deleted by others.',
203
+                     self.cluster.uuid)
204 204
 
205 205
     def _sync_cluster_status(self, stack):
206 206
         self.cluster.status = stack.stack_status
@@ -233,7 +233,7 @@ class HeatPoller(object):
233 233
     def _cluster_failed(self, stack):
234 234
         LOG.error('Cluster error, stack status: %(cluster_status)s, '
235 235
                   'stack_id: %(stack_id)s, '
236
-                  'reason: %(reason)s' %
236
+                  'reason: %(reason)s',
237 237
                   {'cluster_status': stack.stack_status,
238 238
                    'stack_id': self.cluster.stack_id,
239 239
                    'reason': self.cluster.status_reason})
@@ -253,6 +253,6 @@ class HeatPoller(object):
253 253
         self.cluster.save()
254 254
         LOG.info("Cluster with id %(id)s has been set to "
255 255
                  "%(status)s due to stack with id %(sid)s "
256
-                 "not found in Heat." %
256
+                 "not found in Heat.",
257 257
                  {'id': self.cluster.id, 'status': self.cluster.status,
258 258
                   'sid': self.cluster.stack_id})

+ 1
- 1
magnum/drivers/heat/template_def.py View File

@@ -100,7 +100,7 @@ class OutputMapping(object):
100 100
             if output['output_key'] == self.heat_output:
101 101
                 return output['output_value']
102 102
 
103
-        LOG.warning('stack does not have output_key %s' % self.heat_output)
103
+        LOG.warning('stack does not have output_key %s', self.heat_output)
104 104
         return None
105 105
 
106 106
 

+ 1
- 1
magnum/drivers/swarm_fedora_atomic_v1/monitor.py View File

@@ -51,7 +51,7 @@ class SwarmMonitor(monitors.MonitorBase):
51 51
                     container = docker.inspect_container(container['Id'])
52 52
                 except Exception as e:
53 53
                     LOG.warning("Ignore error [%(e)s] when inspecting "
54
-                                "container %(container_id)s." %
54
+                                "container %(container_id)s.",
55 55
                                 {'e': e, 'container_id': container['Id']},
56 56
                                 exc_info=True)
57 57
                 containers.append(container)

+ 3
- 3
magnum/service/periodic.py View File

@@ -135,7 +135,7 @@ class MagnumPeriodicTasks(periodic_task.PeriodicTasks):
135 135
 
136 136
         except Exception as e:
137 137
             LOG.warning(
138
-                "Ignore error [%s] when syncing up cluster status." %
138
+                "Ignore error [%s] when syncing up cluster status.",
139 139
                 e, exc_info=True)
140 140
 
141 141
     @periodic_task.periodic_task(run_immediately=True)
@@ -157,7 +157,7 @@ class MagnumPeriodicTasks(periodic_task.PeriodicTasks):
157 157
             except Exception as e:
158 158
                 LOG.warning(
159 159
                     "Skip pulling data from cluster %(cluster)s due to "
160
-                    "error: %(e)s" %
160
+                    "error: %(e)s",
161 161
                     {'e': e, 'cluster': cluster.uuid}, exc_info=True)
162 162
                 continue
163 163
 
@@ -172,7 +172,7 @@ class MagnumPeriodicTasks(periodic_task.PeriodicTasks):
172 172
                     metrics.append(metric)
173 173
                 except Exception as e:
174 174
                     LOG.warning("Skip adding metric %(name)s due to "
175
-                                "error: %(e)s" %
175
+                                "error: %(e)s",
176 176
                                 {'e': e, 'name': name}, exc_info=True)
177 177
 
178 178
             message = dict(metrics=metrics,

+ 1
- 1
magnum/tests/functional/api/base.py View File

@@ -106,7 +106,7 @@ class BaseTempestTest(base.BaseMagnumTest):
106 106
         except Exception:
107 107
             keypair_body = keypairs_client.create_keypair(
108 108
                 name=config.Config.keypair_id)
109
-            cls.LOG.debug("Keypair body: %s" % keypair_body)
109
+            cls.LOG.debug("Keypair body: %s", keypair_body)
110 110
             keypair = keypair_body['keypair']['private_key']
111 111
         return (creds, keypair)
112 112
 

+ 8
- 8
magnum/tests/functional/api/v1/clients/bay_client.py View File

@@ -120,7 +120,7 @@ class BayClient(client.MagnumClient):
120 120
                 lambda: self.does_bay_exist(bay_id), 10, 1800)
121 121
         except Exception:
122 122
             # In error state.  Clean up the bay id if desired
123
-            self.LOG.error('Bay %s entered an exception state.' % bay_id)
123
+            self.LOG.error('Bay %s entered an exception state.', bay_id)
124 124
             if delete_on_error:
125 125
                 self.LOG.error('We will attempt to delete bays now.')
126 126
                 self.delete_bay(bay_id)
@@ -136,35 +136,35 @@ class BayClient(client.MagnumClient):
136 136
             resp, model = self.get_bay(bay_id)
137 137
             if model.status in ['CREATED', 'CREATE_COMPLETE',
138 138
                                 'ERROR', 'CREATE_FAILED']:
139
-                self.LOG.info('Bay %s succeeded.' % bay_id)
139
+                self.LOG.info('Bay %s succeeded.', bay_id)
140 140
                 return True
141 141
             else:
142 142
                 return False
143 143
         except exceptions.NotFound:
144
-            self.LOG.warning('Bay %s is not found.' % bay_id)
144
+            self.LOG.warning('Bay %s is not found.', bay_id)
145 145
             return False
146 146
 
147 147
     def does_bay_exist(self, bay_id):
148 148
         try:
149 149
             resp, model = self.get_bay(bay_id)
150 150
             if model.status in ['CREATED', 'CREATE_COMPLETE']:
151
-                self.LOG.info('Bay %s is created.' % bay_id)
151
+                self.LOG.info('Bay %s is created.', bay_id)
152 152
                 return True
153 153
             elif model.status in ['ERROR', 'CREATE_FAILED']:
154
-                self.LOG.error('Bay %s is in fail state.' % bay_id)
154
+                self.LOG.error('Bay %s is in fail state.', bay_id)
155 155
                 raise exceptions.ServerFault(
156
-                    "Got into an error condition: %s for %s" %
156
+                    "Got into an error condition: %s for %s",
157 157
                     (model.status, bay_id))
158 158
             else:
159 159
                 return False
160 160
         except exceptions.NotFound:
161
-            self.LOG.warning('Bay %s is not found.' % bay_id)
161
+            self.LOG.warning('Bay %s is not found.', bay_id)
162 162
             return False
163 163
 
164 164
     def does_bay_not_exist(self, bay_id):
165 165
         try:
166 166
             self.get_bay(bay_id)
167 167
         except exceptions.NotFound:
168
-            self.LOG.warning('Bay %s is not found.' % bay_id)
168
+            self.LOG.warning('Bay %s is not found.', bay_id)
169 169
             return True
170 170
         return False

+ 8
- 8
magnum/tests/functional/api/v1/clients/cluster_client.py View File

@@ -121,7 +121,7 @@ class ClusterClient(client.MagnumClient):
121 121
                 lambda: self.does_cluster_exist(cluster_id), 10, 1800)
122 122
         except Exception:
123 123
             # In error state.  Clean up the cluster id if desired
124
-            self.LOG.error('Cluster %s entered an exception state.' %
124
+            self.LOG.error('Cluster %s entered an exception state.',
125 125
                            cluster_id)
126 126
             if delete_on_error:
127 127
                 self.LOG.error('We will attempt to delete clusters now.')
@@ -138,36 +138,36 @@ class ClusterClient(client.MagnumClient):
138 138
             resp, model = self.get_cluster(cluster_id)
139 139
             if model.status in ['CREATED', 'CREATE_COMPLETE',
140 140
                                 'ERROR', 'CREATE_FAILED']:
141
-                self.LOG.info('Cluster %s succeeded.' % cluster_id)
141
+                self.LOG.info('Cluster %s succeeded.', cluster_id)
142 142
                 return True
143 143
             else:
144 144
                 return False
145 145
         except exceptions.NotFound:
146
-            self.LOG.warning('Cluster %s is not found.' % cluster_id)
146
+            self.LOG.warning('Cluster %s is not found.', cluster_id)
147 147
             return False
148 148
 
149 149
     def does_cluster_exist(self, cluster_id):
150 150
         try:
151 151
             resp, model = self.get_cluster(cluster_id)
152 152
             if model.status in ['CREATED', 'CREATE_COMPLETE']:
153
-                self.LOG.info('Cluster %s is created.' % cluster_id)
153
+                self.LOG.info('Cluster %s is created.', cluster_id)
154 154
                 return True
155 155
             elif model.status in ['ERROR', 'CREATE_FAILED']:
156
-                self.LOG.error('Cluster %s is in fail state.' %
156
+                self.LOG.error('Cluster %s is in fail state.',
157 157
                                cluster_id)
158 158
                 raise exceptions.ServerFault(
159
-                    "Got into an error condition: %s for %s" %
159
+                    "Got into an error condition: %s for %s",
160 160
                     (model.status, cluster_id))
161 161
             else:
162 162
                 return False
163 163
         except exceptions.NotFound:
164
-            self.LOG.warning('Cluster %s is not found.' % cluster_id)
164
+            self.LOG.warning('Cluster %s is not found.', cluster_id)
165 165
             return False
166 166
 
167 167
     def does_cluster_not_exist(self, cluster_id):
168 168
         try:
169 169
             self.get_cluster(cluster_id)
170 170
         except exceptions.NotFound:
171
-            self.LOG.warning('Cluster %s is not found.' % cluster_id)
171
+            self.LOG.warning('Cluster %s is not found.', cluster_id)
172 172
             return True
173 173
         return False

+ 5
- 5
magnum/tests/functional/api/v1/test_bay.py View File

@@ -81,23 +81,23 @@ class BayTest(base.BaseTempestTest):
81 81
             super(BayTest, self).tearDown()
82 82
 
83 83
     def _create_baymodel(self, baymodel_model):
84
-        self.LOG.debug('We will create a baymodel for %s' % baymodel_model)
84
+        self.LOG.debug('We will create a baymodel for %s', baymodel_model)
85 85
         resp, model = self.baymodel_client.post_baymodel(baymodel_model)
86 86
         return resp, model
87 87
 
88 88
     def _delete_baymodel(self, baymodel_id):
89
-        self.LOG.debug('We will delete a baymodel for %s' % baymodel_id)
89
+        self.LOG.debug('We will delete a baymodel for %s', baymodel_id)
90 90
         resp, model = self.baymodel_client.delete_baymodel(baymodel_id)
91 91
         return resp, model
92 92
 
93 93
     def _create_bay(self, bay_model, is_async=False):
94
-        self.LOG.debug('We will create bay for %s' % bay_model)
94
+        self.LOG.debug('We will create bay for %s', bay_model)
95 95
         headers = {'Content-Type': 'application/json',
96 96
                    'Accept': 'application/json'}
97 97
         if is_async:
98 98
             headers["OpenStack-API-Version"] = "container-infra 1.2"
99 99
         resp, model = self.bay_client.post_bay(bay_model, headers=headers)
100
-        self.LOG.debug('Response: %s' % resp)
100
+        self.LOG.debug('Response: %s', resp)
101 101
         if is_async:
102 102
             self.assertEqual(202, resp.status)
103 103
         else:
@@ -117,7 +117,7 @@ class BayTest(base.BaseTempestTest):
117 117
         return resp, model
118 118
 
119 119
     def _delete_bay(self, bay_id):
120
-        self.LOG.debug('We will delete a bay for %s' % bay_id)
120
+        self.LOG.debug('We will delete a bay for %s', bay_id)
121 121
         resp, model = self.bay_client.delete_bay(bay_id)
122 122
         self.assertEqual(204, resp.status)
123 123
         self.bay_client.wait_for_bay_to_delete(bay_id)

+ 7
- 7
magnum/tests/functional/api/v1/test_cluster.py View File

@@ -86,21 +86,21 @@ class ClusterTest(base.BaseTempestTest):
86 86
             super(ClusterTest, self).tearDown()
87 87
 
88 88
     def _create_cluster_template(self, cm_model):
89
-        self.LOG.debug('We will create a clustertemplate for %s' % cm_model)
89
+        self.LOG.debug('We will create a clustertemplate for %s', cm_model)
90 90
         resp, model = self.cluster_template_client.post_cluster_template(
91 91
             cm_model)
92 92
         return resp, model
93 93
 
94 94
     def _delete_cluster_template(self, cm_id):
95
-        self.LOG.debug('We will delete a clustertemplate for %s' % cm_id)
95
+        self.LOG.debug('We will delete a clustertemplate for %s', cm_id)
96 96
         resp, model = self.cluster_template_client.delete_cluster_template(
97 97
             cm_id)
98 98
         return resp, model
99 99
 
100 100
     def _create_cluster(self, cluster_model):
101
-        self.LOG.debug('We will create cluster for %s' % cluster_model)
101
+        self.LOG.debug('We will create cluster for %s', cluster_model)
102 102
         resp, model = self.cluster_client.post_cluster(cluster_model)
103
-        self.LOG.debug('Response: %s' % resp)
103
+        self.LOG.debug('Response: %s', resp)
104 104
         self.assertEqual(202, resp.status)
105 105
         self.assertIsNotNone(model.uuid)
106 106
         self.assertTrue(uuidutils.is_uuid_like(model.uuid))
@@ -118,7 +118,7 @@ class ClusterTest(base.BaseTempestTest):
118 118
         return resp, model
119 119
 
120 120
     def _delete_cluster(self, cluster_id):
121
-        self.LOG.debug('We will delete a cluster for %s' % cluster_id)
121
+        self.LOG.debug('We will delete a cluster for %s', cluster_id)
122 122
         resp, model = self.cluster_client.delete_cluster(cluster_id)
123 123
         self.assertEqual(204, resp.status)
124 124
         self.cluster_client.wait_for_cluster_to_delete(cluster_id)
@@ -159,7 +159,7 @@ class ClusterTest(base.BaseTempestTest):
159 159
         # test ca show
160 160
         resp, cert_model = self.cert_client.get_cert(
161 161
             cluster_model.uuid, headers=HEADERS)
162
-        self.LOG.debug("cert resp: %s" % resp)
162
+        self.LOG.debug("cert resp: %s", resp)
163 163
         self.assertEqual(200, resp.status)
164 164
         self.assertEqual(cert_model.cluster_uuid, cluster_model.uuid)
165 165
         self.assertIsNotNone(cert_model.pem)
@@ -186,7 +186,7 @@ Q0uA0aVog3f5iJxCa3Hp5gxbJQ6zV6kJ0TEsuaaOhEko9sdpCoPOnRBm2i/XRD2D
186 186
                                             csr_data=csr_sample)
187 187
         resp, cert_model = self.cert_client.post_cert(cert_data_model,
188 188
                                                       headers=HEADERS)
189
-        self.LOG.debug("cert resp: %s" % resp)
189
+        self.LOG.debug("cert resp: %s", resp)
190 190
         self.assertEqual(201, resp.status)
191 191
         self.assertEqual(cert_model.cluster_uuid, cluster_model.uuid)
192 192
         self.assertIsNotNone(cert_model.pem)

+ 2
- 2
magnum/tests/functional/common/base.py View File

@@ -66,8 +66,8 @@ class BaseMagnumTest(base.BaseTestCase):
66 66
                     log_name = prefix + "-" + func_name
67 67
                     for node_address in nodes_address:
68 68
                         try:
69
-                            cls.LOG.debug("running %s" % full_location)
70
-                            cls.LOG.debug("keypair: %s" % keypair)
69
+                            cls.LOG.debug("running %s", full_location)
70
+                            cls.LOG.debug("keypair: %s", keypair)
71 71
                             subprocess.check_call([
72 72
                                 full_location,
73 73
                                 node_address,

+ 2
- 2
magnum/tests/functional/python_client_base.py View File

@@ -133,7 +133,7 @@ class BaseMagnumClient(base.BaseMagnumTest):
133 133
 
134 134
         def _check_status():
135 135
             status = cls.cs.clusters.get(cluster.uuid).status
136
-            cls.LOG.debug("Cluster status is %s" % status)
136
+            cls.LOG.debug("Cluster status is %s", status)
137 137
             if status in wait_status:
138 138
                 return False
139 139
             elif status in finish_status:
@@ -312,7 +312,7 @@ extendedKeyUsage = clientAuth
312 312
             nodes = self._get_nodes_from_stack()
313 313
             if not [x for x in nodes if x]:
314 314
                 self.LOG.info("the list of nodes from stack is empty")
315
-        self.LOG.info("Nodes are: %s" % nodes)
315
+        self.LOG.info("Nodes are: %s", nodes)
316 316
         return nodes
317 317
 
318 318
     def _get_nodes_from_cluster(self):

+ 2
- 1
tox.ini View File

@@ -133,7 +133,8 @@ commands =
133 133
 [flake8]
134 134
 # H106 Don’t put vim configuration in source files
135 135
 # H203 Use assertIs(Not)None to check for None
136
-enable-extensions = H106,H203
136
+# H904 Delay string interpolations at logging calls
137
+enable-extensions = H106,H203,H904
137 138
 exclude = .venv,.git,.tox,dist,*lib/python*,*egg,build,tools,releasenotes
138 139
 
139 140
 [hacking]

Loading…
Cancel
Save