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
This commit is contained in:
parent
c90963e289
commit
69bc1ea570
|
@ -106,7 +106,7 @@ class BaseTempestTest(base.BaseMagnumTest):
|
|||
except Exception:
|
||||
keypair_body = keypairs_client.create_keypair(
|
||||
name=config.Config.keypair_id)
|
||||
cls.LOG.debug("Keypair body: %s" % keypair_body)
|
||||
cls.LOG.debug("Keypair body: %s", keypair_body)
|
||||
keypair = keypair_body['keypair']['private_key']
|
||||
return (creds, keypair)
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ class BayClient(client.MagnumClient):
|
|||
lambda: self.does_bay_exist(bay_id), 10, 1800)
|
||||
except Exception:
|
||||
# In error state. Clean up the bay id if desired
|
||||
self.LOG.error('Bay %s entered an exception state.' % bay_id)
|
||||
self.LOG.error('Bay %s entered an exception state.', bay_id)
|
||||
if delete_on_error:
|
||||
self.LOG.error('We will attempt to delete bays now.')
|
||||
self.delete_bay(bay_id)
|
||||
|
@ -136,35 +136,35 @@ class BayClient(client.MagnumClient):
|
|||
resp, model = self.get_bay(bay_id)
|
||||
if model.status in ['CREATED', 'CREATE_COMPLETE',
|
||||
'ERROR', 'CREATE_FAILED']:
|
||||
self.LOG.info('Bay %s succeeded.' % bay_id)
|
||||
self.LOG.info('Bay %s succeeded.', bay_id)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
except exceptions.NotFound:
|
||||
self.LOG.warning('Bay %s is not found.' % bay_id)
|
||||
self.LOG.warning('Bay %s is not found.', bay_id)
|
||||
return False
|
||||
|
||||
def does_bay_exist(self, bay_id):
|
||||
try:
|
||||
resp, model = self.get_bay(bay_id)
|
||||
if model.status in ['CREATED', 'CREATE_COMPLETE']:
|
||||
self.LOG.info('Bay %s is created.' % bay_id)
|
||||
self.LOG.info('Bay %s is created.', bay_id)
|
||||
return True
|
||||
elif model.status in ['ERROR', 'CREATE_FAILED']:
|
||||
self.LOG.error('Bay %s is in fail state.' % bay_id)
|
||||
self.LOG.error('Bay %s is in fail state.', bay_id)
|
||||
raise exceptions.ServerFault(
|
||||
"Got into an error condition: %s for %s" %
|
||||
"Got into an error condition: %s for %s",
|
||||
(model.status, bay_id))
|
||||
else:
|
||||
return False
|
||||
except exceptions.NotFound:
|
||||
self.LOG.warning('Bay %s is not found.' % bay_id)
|
||||
self.LOG.warning('Bay %s is not found.', bay_id)
|
||||
return False
|
||||
|
||||
def does_bay_not_exist(self, bay_id):
|
||||
try:
|
||||
self.get_bay(bay_id)
|
||||
except exceptions.NotFound:
|
||||
self.LOG.warning('Bay %s is not found.' % bay_id)
|
||||
self.LOG.warning('Bay %s is not found.', bay_id)
|
||||
return True
|
||||
return False
|
||||
|
|
|
@ -121,7 +121,7 @@ class ClusterClient(client.MagnumClient):
|
|||
lambda: self.does_cluster_exist(cluster_id), 10, 1800)
|
||||
except Exception:
|
||||
# In error state. Clean up the cluster id if desired
|
||||
self.LOG.error('Cluster %s entered an exception state.' %
|
||||
self.LOG.error('Cluster %s entered an exception state.',
|
||||
cluster_id)
|
||||
if delete_on_error:
|
||||
self.LOG.error('We will attempt to delete clusters now.')
|
||||
|
@ -138,36 +138,36 @@ class ClusterClient(client.MagnumClient):
|
|||
resp, model = self.get_cluster(cluster_id)
|
||||
if model.status in ['CREATED', 'CREATE_COMPLETE',
|
||||
'ERROR', 'CREATE_FAILED']:
|
||||
self.LOG.info('Cluster %s succeeded.' % cluster_id)
|
||||
self.LOG.info('Cluster %s succeeded.', cluster_id)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
except exceptions.NotFound:
|
||||
self.LOG.warning('Cluster %s is not found.' % cluster_id)
|
||||
self.LOG.warning('Cluster %s is not found.', cluster_id)
|
||||
return False
|
||||
|
||||
def does_cluster_exist(self, cluster_id):
|
||||
try:
|
||||
resp, model = self.get_cluster(cluster_id)
|
||||
if model.status in ['CREATED', 'CREATE_COMPLETE']:
|
||||
self.LOG.info('Cluster %s is created.' % cluster_id)
|
||||
self.LOG.info('Cluster %s is created.', cluster_id)
|
||||
return True
|
||||
elif model.status in ['ERROR', 'CREATE_FAILED']:
|
||||
self.LOG.error('Cluster %s is in fail state.' %
|
||||
self.LOG.error('Cluster %s is in fail state.',
|
||||
cluster_id)
|
||||
raise exceptions.ServerFault(
|
||||
"Got into an error condition: %s for %s" %
|
||||
"Got into an error condition: %s for %s",
|
||||
(model.status, cluster_id))
|
||||
else:
|
||||
return False
|
||||
except exceptions.NotFound:
|
||||
self.LOG.warning('Cluster %s is not found.' % cluster_id)
|
||||
self.LOG.warning('Cluster %s is not found.', cluster_id)
|
||||
return False
|
||||
|
||||
def does_cluster_not_exist(self, cluster_id):
|
||||
try:
|
||||
self.get_cluster(cluster_id)
|
||||
except exceptions.NotFound:
|
||||
self.LOG.warning('Cluster %s is not found.' % cluster_id)
|
||||
self.LOG.warning('Cluster %s is not found.', cluster_id)
|
||||
return True
|
||||
return False
|
||||
|
|
|
@ -81,23 +81,23 @@ class BayTest(base.BaseTempestTest):
|
|||
super(BayTest, self).tearDown()
|
||||
|
||||
def _create_baymodel(self, baymodel_model):
|
||||
self.LOG.debug('We will create a baymodel for %s' % baymodel_model)
|
||||
self.LOG.debug('We will create a baymodel for %s', baymodel_model)
|
||||
resp, model = self.baymodel_client.post_baymodel(baymodel_model)
|
||||
return resp, model
|
||||
|
||||
def _delete_baymodel(self, baymodel_id):
|
||||
self.LOG.debug('We will delete a baymodel for %s' % baymodel_id)
|
||||
self.LOG.debug('We will delete a baymodel for %s', baymodel_id)
|
||||
resp, model = self.baymodel_client.delete_baymodel(baymodel_id)
|
||||
return resp, model
|
||||
|
||||
def _create_bay(self, bay_model, is_async=False):
|
||||
self.LOG.debug('We will create bay for %s' % bay_model)
|
||||
self.LOG.debug('We will create bay for %s', bay_model)
|
||||
headers = {'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'}
|
||||
if is_async:
|
||||
headers["OpenStack-API-Version"] = "container-infra 1.2"
|
||||
resp, model = self.bay_client.post_bay(bay_model, headers=headers)
|
||||
self.LOG.debug('Response: %s' % resp)
|
||||
self.LOG.debug('Response: %s', resp)
|
||||
if is_async:
|
||||
self.assertEqual(202, resp.status)
|
||||
else:
|
||||
|
@ -117,7 +117,7 @@ class BayTest(base.BaseTempestTest):
|
|||
return resp, model
|
||||
|
||||
def _delete_bay(self, bay_id):
|
||||
self.LOG.debug('We will delete a bay for %s' % bay_id)
|
||||
self.LOG.debug('We will delete a bay for %s', bay_id)
|
||||
resp, model = self.bay_client.delete_bay(bay_id)
|
||||
self.assertEqual(204, resp.status)
|
||||
self.bay_client.wait_for_bay_to_delete(bay_id)
|
||||
|
|
|
@ -86,21 +86,21 @@ class ClusterTest(base.BaseTempestTest):
|
|||
super(ClusterTest, self).tearDown()
|
||||
|
||||
def _create_cluster_template(self, cm_model):
|
||||
self.LOG.debug('We will create a clustertemplate for %s' % cm_model)
|
||||
self.LOG.debug('We will create a clustertemplate for %s', cm_model)
|
||||
resp, model = self.cluster_template_client.post_cluster_template(
|
||||
cm_model)
|
||||
return resp, model
|
||||
|
||||
def _delete_cluster_template(self, cm_id):
|
||||
self.LOG.debug('We will delete a clustertemplate for %s' % cm_id)
|
||||
self.LOG.debug('We will delete a clustertemplate for %s', cm_id)
|
||||
resp, model = self.cluster_template_client.delete_cluster_template(
|
||||
cm_id)
|
||||
return resp, model
|
||||
|
||||
def _create_cluster(self, cluster_model):
|
||||
self.LOG.debug('We will create cluster for %s' % cluster_model)
|
||||
self.LOG.debug('We will create cluster for %s', cluster_model)
|
||||
resp, model = self.cluster_client.post_cluster(cluster_model)
|
||||
self.LOG.debug('Response: %s' % resp)
|
||||
self.LOG.debug('Response: %s', resp)
|
||||
self.assertEqual(202, resp.status)
|
||||
self.assertIsNotNone(model.uuid)
|
||||
self.assertTrue(uuidutils.is_uuid_like(model.uuid))
|
||||
|
@ -118,7 +118,7 @@ class ClusterTest(base.BaseTempestTest):
|
|||
return resp, model
|
||||
|
||||
def _delete_cluster(self, cluster_id):
|
||||
self.LOG.debug('We will delete a cluster for %s' % cluster_id)
|
||||
self.LOG.debug('We will delete a cluster for %s', cluster_id)
|
||||
resp, model = self.cluster_client.delete_cluster(cluster_id)
|
||||
self.assertEqual(204, resp.status)
|
||||
self.cluster_client.wait_for_cluster_to_delete(cluster_id)
|
||||
|
@ -159,7 +159,7 @@ class ClusterTest(base.BaseTempestTest):
|
|||
# test ca show
|
||||
resp, cert_model = self.cert_client.get_cert(
|
||||
cluster_model.uuid, headers=HEADERS)
|
||||
self.LOG.debug("cert resp: %s" % resp)
|
||||
self.LOG.debug("cert resp: %s", resp)
|
||||
self.assertEqual(200, resp.status)
|
||||
self.assertEqual(cert_model.cluster_uuid, cluster_model.uuid)
|
||||
self.assertIsNotNone(cert_model.pem)
|
||||
|
@ -186,7 +186,7 @@ Q0uA0aVog3f5iJxCa3Hp5gxbJQ6zV6kJ0TEsuaaOhEko9sdpCoPOnRBm2i/XRD2D
|
|||
csr_data=csr_sample)
|
||||
resp, cert_model = self.cert_client.post_cert(cert_data_model,
|
||||
headers=HEADERS)
|
||||
self.LOG.debug("cert resp: %s" % resp)
|
||||
self.LOG.debug("cert resp: %s", resp)
|
||||
self.assertEqual(201, resp.status)
|
||||
self.assertEqual(cert_model.cluster_uuid, cluster_model.uuid)
|
||||
self.assertIsNotNone(cert_model.pem)
|
||||
|
|
|
@ -66,8 +66,8 @@ class BaseMagnumTest(base.BaseTestCase):
|
|||
log_name = prefix + "-" + func_name
|
||||
for node_address in nodes_address:
|
||||
try:
|
||||
cls.LOG.debug("running %s" % full_location)
|
||||
cls.LOG.debug("keypair: %s" % keypair)
|
||||
cls.LOG.debug("running %s", full_location)
|
||||
cls.LOG.debug("keypair: %s", keypair)
|
||||
subprocess.check_call([
|
||||
full_location,
|
||||
node_address,
|
||||
|
|
Loading…
Reference in New Issue