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
465d3c0e3c
commit
ba8ad5e37f
|
@ -21,3 +21,4 @@ Magnum Specific Commandments
|
||||||
- [M339] Don't use xrange()
|
- [M339] Don't use xrange()
|
||||||
- [M340] Check for explicit import of the _ function.
|
- [M340] Check for explicit import of the _ function.
|
||||||
- [M352] LOG.warn is deprecated. Enforce use of LOG.warning.
|
- [M352] LOG.warn is deprecated. Enforce use of LOG.warning.
|
||||||
|
- [M353] String interpolation should be delayed at logging calls.
|
||||||
|
|
|
@ -59,7 +59,7 @@ def load_app():
|
||||||
|
|
||||||
if not cfg_file:
|
if not cfg_file:
|
||||||
raise cfg.ConfigFilesNotFoundError([CONF.api.api_paste_config])
|
raise cfg.ConfigFilesNotFoundError([CONF.api.api_paste_config])
|
||||||
LOG.info("Full WSGI config used: %s" % cfg_file)
|
LOG.info("Full WSGI config used: %s", cfg_file)
|
||||||
return deploy.loadapp("config:" + cfg_file)
|
return deploy.loadapp("config:" + cfg_file)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -361,7 +361,7 @@ class BaysController(base.Controller):
|
||||||
failed_resources = []
|
failed_resources = []
|
||||||
LOG.warning("Failed to retrieve failed resources for "
|
LOG.warning("Failed to retrieve failed resources for "
|
||||||
"bay %(bay)s from Heat stack %(stack)s "
|
"bay %(bay)s from Heat stack %(stack)s "
|
||||||
"due to error: %(e)s" %
|
"due to error: %(e)s",
|
||||||
{'bay': bay.uuid, 'stack': bay.stack_id, 'e': e},
|
{'bay': bay.uuid, 'stack': bay.stack_id, 'e': e},
|
||||||
exc_info=True)
|
exc_info=True)
|
||||||
|
|
||||||
|
|
|
@ -334,7 +334,7 @@ class ClustersController(base.Controller):
|
||||||
failed_resources = []
|
failed_resources = []
|
||||||
LOG.warning("Failed to retrieve failed resources for "
|
LOG.warning("Failed to retrieve failed resources for "
|
||||||
"cluster %(cluster)s from Heat stack "
|
"cluster %(cluster)s from Heat stack "
|
||||||
"%(stack)s due to error: %(e)s" %
|
"%(stack)s due to error: %(e)s",
|
||||||
{'cluster': cluster.uuid,
|
{'cluster': cluster.uuid,
|
||||||
'stack': cluster.stack_id, 'e': e},
|
'stack': cluster.stack_id, 'e': e},
|
||||||
exc_info=True)
|
exc_info=True)
|
||||||
|
|
|
@ -72,17 +72,17 @@ def main():
|
||||||
# Create the WSGI server and start it
|
# Create the WSGI server and start it
|
||||||
host, port = CONF.api.host, CONF.api.port
|
host, port = CONF.api.host, CONF.api.port
|
||||||
|
|
||||||
LOG.info('Starting server in PID %s' % os.getpid())
|
LOG.info('Starting server in PID %s', os.getpid())
|
||||||
LOG.debug("Configuration:")
|
LOG.debug("Configuration:")
|
||||||
CONF.log_opt_values(LOG, logging.DEBUG)
|
CONF.log_opt_values(LOG, logging.DEBUG)
|
||||||
|
|
||||||
LOG.info('Serving on %(proto)s://%(host)s:%(port)s' %
|
LOG.info('Serving on %(proto)s://%(host)s:%(port)s',
|
||||||
dict(proto="https" if use_ssl else "http", host=host, port=port))
|
dict(proto="https" if use_ssl else "http", host=host, port=port))
|
||||||
|
|
||||||
workers = CONF.api.workers
|
workers = CONF.api.workers
|
||||||
if not workers:
|
if not workers:
|
||||||
workers = processutils.get_worker_count()
|
workers = processutils.get_worker_count()
|
||||||
LOG.info('Server will handle each request in a new process up to'
|
LOG.info('Server will handle each request in a new process up to'
|
||||||
' %s concurrent processes' % workers)
|
' %s concurrent processes', workers)
|
||||||
serving.run_simple(host, port, app, processes=workers,
|
serving.run_simple(host, port, app, processes=workers,
|
||||||
ssl_context=_get_ssl_configs(use_ssl))
|
ssl_context=_get_ssl_configs(use_ssl))
|
||||||
|
|
|
@ -41,7 +41,7 @@ def main():
|
||||||
|
|
||||||
gmr.TextGuruMeditation.setup_autorun(version)
|
gmr.TextGuruMeditation.setup_autorun(version)
|
||||||
|
|
||||||
LOG.info('Starting server in PID %s' % os.getpid())
|
LOG.info('Starting server in PID %s', os.getpid())
|
||||||
LOG.debug("Configuration:")
|
LOG.debug("Configuration:")
|
||||||
CONF.log_opt_values(LOG, logging.DEBUG)
|
CONF.log_opt_values(LOG, logging.DEBUG)
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ class MagnumException(Exception):
|
||||||
# kwargs doesn't match a variable in the message
|
# kwargs doesn't match a variable in the message
|
||||||
# log the issue and the kwargs
|
# log the issue and the kwargs
|
||||||
LOG.exception('Exception in string format operation, '
|
LOG.exception('Exception in string format operation, '
|
||||||
'kwargs: %s' % kwargs)
|
'kwargs: %s', kwargs)
|
||||||
try:
|
try:
|
||||||
if CONF.fatal_exception_format_errors:
|
if CONF.fatal_exception_format_errors:
|
||||||
raise
|
raise
|
||||||
|
|
|
@ -102,8 +102,8 @@ class KeystoneClientV3(object):
|
||||||
LOG.warning('Auth plugin and its options for service user '
|
LOG.warning('Auth plugin and its options for service user '
|
||||||
'must be provided in [%(new)s] section. '
|
'must be provided in [%(new)s] section. '
|
||||||
'Using values from [%(old)s] section is '
|
'Using values from [%(old)s] section is '
|
||||||
'deprecated.' % {'new': ksconf.CFG_GROUP,
|
'deprecated.', {'new': ksconf.CFG_GROUP,
|
||||||
'old': ksconf.CFG_LEGACY_GROUP})
|
'old': ksconf.CFG_LEGACY_GROUP})
|
||||||
|
|
||||||
conf = getattr(CONF, ksconf.CFG_LEGACY_GROUP)
|
conf = getattr(CONF, ksconf.CFG_LEGACY_GROUP)
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ def get(url, allowed_schemes=('http', 'https')):
|
||||||
the allowed_schemes argument.
|
the allowed_schemes argument.
|
||||||
Raise an IOError if getting the data fails.
|
Raise an IOError if getting the data fails.
|
||||||
"""
|
"""
|
||||||
LOG.info('Fetching data from %s' % url)
|
LOG.info('Fetching data from %s', url)
|
||||||
|
|
||||||
components = urllib.parse.urlparse(url)
|
components = urllib.parse.urlparse(url)
|
||||||
|
|
||||||
|
|
|
@ -85,10 +85,10 @@ def execute(*cmd, **kwargs):
|
||||||
if kwargs.get('run_as_root') and 'root_helper' not in kwargs:
|
if kwargs.get('run_as_root') and 'root_helper' not in kwargs:
|
||||||
kwargs['root_helper'] = _get_root_helper()
|
kwargs['root_helper'] = _get_root_helper()
|
||||||
result = processutils.execute(*cmd, **kwargs)
|
result = processutils.execute(*cmd, **kwargs)
|
||||||
LOG.debug('Execution completed, command line is "%s"' %
|
LOG.debug('Execution completed, command line is "%s"',
|
||||||
' '.join(map(str, cmd)))
|
' '.join(map(str, cmd)))
|
||||||
LOG.debug('Command stdout is: "%s"' % result[0])
|
LOG.debug('Command stdout is: "%s"', result[0])
|
||||||
LOG.debug('Command stderr is: "%s"' % result[1])
|
LOG.debug('Command stderr is: "%s"', result[1])
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ def tempdir(**kwargs):
|
||||||
try:
|
try:
|
||||||
shutil.rmtree(tmpdir)
|
shutil.rmtree(tmpdir)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
LOG.error('Could not remove tmpdir: %s' % e)
|
LOG.error('Could not remove tmpdir: %s', e)
|
||||||
|
|
||||||
|
|
||||||
def rmtree_without_raise(path):
|
def rmtree_without_raise(path):
|
||||||
|
@ -133,7 +133,7 @@ def rmtree_without_raise(path):
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
LOG.warning("Failed to remove dir %(path)s, error: %(e)s" %
|
LOG.warning("Failed to remove dir %(path)s, error: %(e)s",
|
||||||
{'path': path, 'e': e})
|
{'path': path, 'e': e})
|
||||||
|
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ def safe_rstrip(value, chars=None):
|
||||||
if not isinstance(value, six.string_types):
|
if not isinstance(value, six.string_types):
|
||||||
LOG.warning("Failed to remove trailing character. "
|
LOG.warning("Failed to remove trailing character. "
|
||||||
"Returning original object. "
|
"Returning original object. "
|
||||||
"Supplied object is not a string: %s," % value)
|
"Supplied object is not a string: %s,", value)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
return value.rstrip(chars) or value
|
return value.rstrip(chars) or value
|
||||||
|
|
|
@ -151,14 +151,14 @@ class Handler(object):
|
||||||
cluster.status_reason = None
|
cluster.status_reason = None
|
||||||
except exc.HTTPNotFound:
|
except exc.HTTPNotFound:
|
||||||
LOG.info('The cluster %s was not found during cluster'
|
LOG.info('The cluster %s was not found during cluster'
|
||||||
' deletion.' % cluster.id)
|
' deletion.', cluster.id)
|
||||||
try:
|
try:
|
||||||
trust_manager.delete_trustee_and_trust(osc, context, cluster)
|
trust_manager.delete_trustee_and_trust(osc, context, cluster)
|
||||||
cert_manager.delete_certificates_from_cluster(cluster,
|
cert_manager.delete_certificates_from_cluster(cluster,
|
||||||
context=context)
|
context=context)
|
||||||
cluster.destroy()
|
cluster.destroy()
|
||||||
except exception.ClusterNotFound:
|
except exception.ClusterNotFound:
|
||||||
LOG.info('The cluster %s has been deleted by others.' %
|
LOG.info('The cluster %s has been deleted by others.',
|
||||||
uuid)
|
uuid)
|
||||||
conductor_utils.notify_about_cluster_operation(
|
conductor_utils.notify_about_cluster_operation(
|
||||||
context, taxonomy.ACTION_DELETE, taxonomy.OUTCOME_SUCCESS)
|
context, taxonomy.ACTION_DELETE, taxonomy.OUTCOME_SUCCESS)
|
||||||
|
|
|
@ -43,7 +43,7 @@ def _generate_ca_cert(issuer_name, context=None):
|
||||||
name=issuer_name,
|
name=issuer_name,
|
||||||
context=context,
|
context=context,
|
||||||
)
|
)
|
||||||
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
|
return ca_cert_ref, ca_cert, ca_password
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ def _generate_client_cert(issuer_name, ca_cert, ca_password, context=None):
|
||||||
name=CONDUCTOR_CLIENT_NAME,
|
name=CONDUCTOR_CLIENT_NAME,
|
||||||
context=context
|
context=context
|
||||||
)
|
)
|
||||||
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
|
return magnum_cert_ref
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ def generate_certificates_to_cluster(cluster, context=None):
|
||||||
try:
|
try:
|
||||||
issuer_name = _get_issuer_name(cluster)
|
issuer_name = _get_issuer_name(cluster)
|
||||||
|
|
||||||
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,
|
ca_cert_ref, ca_cert, ca_password = _generate_ca_cert(issuer_name,
|
||||||
context=context)
|
context=context)
|
||||||
|
@ -104,7 +104,7 @@ def generate_certificates_to_cluster(cluster, context=None):
|
||||||
cluster.ca_cert_ref = ca_cert_ref
|
cluster.ca_cert_ref = ca_cert_ref
|
||||||
cluster.magnum_cert_ref = magnum_cert_ref
|
cluster.magnum_cert_ref = magnum_cert_ref
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.exception('Failed to generate certificates for Cluster: %s' %
|
LOG.exception('Failed to generate certificates for Cluster: %s',
|
||||||
cluster.uuid)
|
cluster.uuid)
|
||||||
raise exception.CertificatesToClusterFailed(cluster_uuid=cluster.uuid)
|
raise exception.CertificatesToClusterFailed(cluster_uuid=cluster.uuid)
|
||||||
|
|
||||||
|
@ -174,5 +174,5 @@ def delete_certificates_from_cluster(cluster, context=None):
|
||||||
cert_manager.get_backend().CertManager.delete_cert(
|
cert_manager.get_backend().CertManager.delete_cert(
|
||||||
cert_ref, resource_ref=cluster.uuid, context=context)
|
cert_ref, resource_ref=cluster.uuid, context=context)
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.warning("Deleting certs is failed for Cluster %s" %
|
LOG.warning("Deleting certs is failed for Cluster %s",
|
||||||
cluster.uuid)
|
cluster.uuid)
|
||||||
|
|
|
@ -37,7 +37,7 @@ def create_trustee_and_trust(osc, cluster):
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.exception(
|
LOG.exception(
|
||||||
'Failed to create trustee and trust for Cluster: %s' %
|
'Failed to create trustee and trust for Cluster: %s',
|
||||||
cluster.uuid)
|
cluster.uuid)
|
||||||
raise exception.TrusteeOrTrustToClusterFailed(
|
raise exception.TrusteeOrTrustToClusterFailed(
|
||||||
cluster_uuid=cluster.uuid)
|
cluster_uuid=cluster.uuid)
|
||||||
|
|
|
@ -37,7 +37,7 @@ class K8sAPI(core_v1_api.CoreV1Api):
|
||||||
tmp.write(content)
|
tmp.write(content)
|
||||||
tmp.flush()
|
tmp.flush()
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
LOG.error("Error while creating temp file: %s" % err)
|
LOG.error("Error while creating temp file: %s", err)
|
||||||
raise
|
raise
|
||||||
return tmp
|
return tmp
|
||||||
|
|
||||||
|
|
|
@ -67,13 +67,13 @@ class ScaleManager(object):
|
||||||
LOG.warning(
|
LOG.warning(
|
||||||
"About to remove %(num_removal)d nodes, which is larger than "
|
"About to remove %(num_removal)d nodes, which is larger than "
|
||||||
"the number of empty nodes (%(num_empty)d). %(num_non_empty)d "
|
"the number of empty nodes (%(num_empty)d). %(num_non_empty)d "
|
||||||
"non-empty nodes will be removed." % {
|
"non-empty nodes will be removed.", {
|
||||||
'num_removal': num_of_removal,
|
'num_removal': num_of_removal,
|
||||||
'num_empty': len(hosts_no_container),
|
'num_empty': len(hosts_no_container),
|
||||||
'num_non_empty': num_of_removal - len(hosts_no_container)})
|
'num_non_empty': num_of_removal - len(hosts_no_container)})
|
||||||
|
|
||||||
hosts_to_remove = hosts_no_container[0:num_of_removal]
|
hosts_to_remove = hosts_no_container[0:num_of_removal]
|
||||||
LOG.info('Require removal of hosts: %s' % hosts_to_remove)
|
LOG.info('Require removal of hosts: %s', hosts_to_remove)
|
||||||
|
|
||||||
return hosts_to_remove
|
return hosts_to_remove
|
||||||
|
|
||||||
|
|
|
@ -190,8 +190,8 @@ class HeatPoller(object):
|
||||||
self._cluster_failed(stack)
|
self._cluster_failed(stack)
|
||||||
|
|
||||||
def _delete_complete(self):
|
def _delete_complete(self):
|
||||||
LOG.info('Cluster has been deleted, stack_id: %s'
|
LOG.info('Cluster has been deleted, stack_id: %s',
|
||||||
% self.cluster.stack_id)
|
self.cluster.stack_id)
|
||||||
try:
|
try:
|
||||||
trust_manager.delete_trustee_and_trust(self.openstack_client,
|
trust_manager.delete_trustee_and_trust(self.openstack_client,
|
||||||
self.context,
|
self.context,
|
||||||
|
@ -199,8 +199,8 @@ class HeatPoller(object):
|
||||||
cert_manager.delete_certificates_from_cluster(self.cluster,
|
cert_manager.delete_certificates_from_cluster(self.cluster,
|
||||||
context=self.context)
|
context=self.context)
|
||||||
except exception.ClusterNotFound:
|
except exception.ClusterNotFound:
|
||||||
LOG.info('The cluster %s has been deleted by others.'
|
LOG.info('The cluster %s has been deleted by others.',
|
||||||
% self.cluster.uuid)
|
self.cluster.uuid)
|
||||||
|
|
||||||
def _sync_cluster_status(self, stack):
|
def _sync_cluster_status(self, stack):
|
||||||
self.cluster.status = stack.stack_status
|
self.cluster.status = stack.stack_status
|
||||||
|
@ -233,7 +233,7 @@ class HeatPoller(object):
|
||||||
def _cluster_failed(self, stack):
|
def _cluster_failed(self, stack):
|
||||||
LOG.error('Cluster error, stack status: %(cluster_status)s, '
|
LOG.error('Cluster error, stack status: %(cluster_status)s, '
|
||||||
'stack_id: %(stack_id)s, '
|
'stack_id: %(stack_id)s, '
|
||||||
'reason: %(reason)s' %
|
'reason: %(reason)s',
|
||||||
{'cluster_status': stack.stack_status,
|
{'cluster_status': stack.stack_status,
|
||||||
'stack_id': self.cluster.stack_id,
|
'stack_id': self.cluster.stack_id,
|
||||||
'reason': self.cluster.status_reason})
|
'reason': self.cluster.status_reason})
|
||||||
|
@ -253,6 +253,6 @@ class HeatPoller(object):
|
||||||
self.cluster.save()
|
self.cluster.save()
|
||||||
LOG.info("Cluster with id %(id)s has been set to "
|
LOG.info("Cluster with id %(id)s has been set to "
|
||||||
"%(status)s due to stack with id %(sid)s "
|
"%(status)s due to stack with id %(sid)s "
|
||||||
"not found in Heat." %
|
"not found in Heat.",
|
||||||
{'id': self.cluster.id, 'status': self.cluster.status,
|
{'id': self.cluster.id, 'status': self.cluster.status,
|
||||||
'sid': self.cluster.stack_id})
|
'sid': self.cluster.stack_id})
|
||||||
|
|
|
@ -100,7 +100,7 @@ class OutputMapping(object):
|
||||||
if output['output_key'] == self.heat_output:
|
if output['output_key'] == self.heat_output:
|
||||||
return output['output_value']
|
return output['output_value']
|
||||||
|
|
||||||
LOG.warning('stack does not have output_key %s' % self.heat_output)
|
LOG.warning('stack does not have output_key %s', self.heat_output)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ class SwarmMonitor(monitors.MonitorBase):
|
||||||
container = docker.inspect_container(container['Id'])
|
container = docker.inspect_container(container['Id'])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.warning("Ignore error [%(e)s] when inspecting "
|
LOG.warning("Ignore error [%(e)s] when inspecting "
|
||||||
"container %(container_id)s." %
|
"container %(container_id)s.",
|
||||||
{'e': e, 'container_id': container['Id']},
|
{'e': e, 'container_id': container['Id']},
|
||||||
exc_info=True)
|
exc_info=True)
|
||||||
containers.append(container)
|
containers.append(container)
|
||||||
|
|
|
@ -135,7 +135,7 @@ class MagnumPeriodicTasks(periodic_task.PeriodicTasks):
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.warning(
|
LOG.warning(
|
||||||
"Ignore error [%s] when syncing up cluster status." %
|
"Ignore error [%s] when syncing up cluster status.",
|
||||||
e, exc_info=True)
|
e, exc_info=True)
|
||||||
|
|
||||||
@periodic_task.periodic_task(run_immediately=True)
|
@periodic_task.periodic_task(run_immediately=True)
|
||||||
|
@ -157,7 +157,7 @@ class MagnumPeriodicTasks(periodic_task.PeriodicTasks):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.warning(
|
LOG.warning(
|
||||||
"Skip pulling data from cluster %(cluster)s due to "
|
"Skip pulling data from cluster %(cluster)s due to "
|
||||||
"error: %(e)s" %
|
"error: %(e)s",
|
||||||
{'e': e, 'cluster': cluster.uuid}, exc_info=True)
|
{'e': e, 'cluster': cluster.uuid}, exc_info=True)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ class MagnumPeriodicTasks(periodic_task.PeriodicTasks):
|
||||||
metrics.append(metric)
|
metrics.append(metric)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.warning("Skip adding metric %(name)s due to "
|
LOG.warning("Skip adding metric %(name)s due to "
|
||||||
"error: %(e)s" %
|
"error: %(e)s",
|
||||||
{'e': e, 'name': name}, exc_info=True)
|
{'e': e, 'name': name}, exc_info=True)
|
||||||
|
|
||||||
message = dict(metrics=metrics,
|
message = dict(metrics=metrics,
|
||||||
|
|
|
@ -106,7 +106,7 @@ class BaseTempestTest(base.BaseMagnumTest):
|
||||||
except Exception:
|
except Exception:
|
||||||
keypair_body = keypairs_client.create_keypair(
|
keypair_body = keypairs_client.create_keypair(
|
||||||
name=config.Config.keypair_id)
|
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']
|
keypair = keypair_body['keypair']['private_key']
|
||||||
return (creds, keypair)
|
return (creds, keypair)
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ class BayClient(client.MagnumClient):
|
||||||
lambda: self.does_bay_exist(bay_id), 10, 1800)
|
lambda: self.does_bay_exist(bay_id), 10, 1800)
|
||||||
except Exception:
|
except Exception:
|
||||||
# In error state. Clean up the bay id if desired
|
# 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:
|
if delete_on_error:
|
||||||
self.LOG.error('We will attempt to delete bays now.')
|
self.LOG.error('We will attempt to delete bays now.')
|
||||||
self.delete_bay(bay_id)
|
self.delete_bay(bay_id)
|
||||||
|
@ -136,35 +136,35 @@ class BayClient(client.MagnumClient):
|
||||||
resp, model = self.get_bay(bay_id)
|
resp, model = self.get_bay(bay_id)
|
||||||
if model.status in ['CREATED', 'CREATE_COMPLETE',
|
if model.status in ['CREATED', 'CREATE_COMPLETE',
|
||||||
'ERROR', 'CREATE_FAILED']:
|
'ERROR', 'CREATE_FAILED']:
|
||||||
self.LOG.info('Bay %s succeeded.' % bay_id)
|
self.LOG.info('Bay %s succeeded.', bay_id)
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
except exceptions.NotFound:
|
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
|
return False
|
||||||
|
|
||||||
def does_bay_exist(self, bay_id):
|
def does_bay_exist(self, bay_id):
|
||||||
try:
|
try:
|
||||||
resp, model = self.get_bay(bay_id)
|
resp, model = self.get_bay(bay_id)
|
||||||
if model.status in ['CREATED', 'CREATE_COMPLETE']:
|
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
|
return True
|
||||||
elif model.status in ['ERROR', 'CREATE_FAILED']:
|
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(
|
raise exceptions.ServerFault(
|
||||||
"Got into an error condition: %s for %s" %
|
"Got into an error condition: %s for %s",
|
||||||
(model.status, bay_id))
|
(model.status, bay_id))
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
except exceptions.NotFound:
|
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
|
return False
|
||||||
|
|
||||||
def does_bay_not_exist(self, bay_id):
|
def does_bay_not_exist(self, bay_id):
|
||||||
try:
|
try:
|
||||||
self.get_bay(bay_id)
|
self.get_bay(bay_id)
|
||||||
except exceptions.NotFound:
|
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 True
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -121,7 +121,7 @@ class ClusterClient(client.MagnumClient):
|
||||||
lambda: self.does_cluster_exist(cluster_id), 10, 1800)
|
lambda: self.does_cluster_exist(cluster_id), 10, 1800)
|
||||||
except Exception:
|
except Exception:
|
||||||
# In error state. Clean up the cluster id if desired
|
# 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)
|
cluster_id)
|
||||||
if delete_on_error:
|
if delete_on_error:
|
||||||
self.LOG.error('We will attempt to delete clusters now.')
|
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)
|
resp, model = self.get_cluster(cluster_id)
|
||||||
if model.status in ['CREATED', 'CREATE_COMPLETE',
|
if model.status in ['CREATED', 'CREATE_COMPLETE',
|
||||||
'ERROR', 'CREATE_FAILED']:
|
'ERROR', 'CREATE_FAILED']:
|
||||||
self.LOG.info('Cluster %s succeeded.' % cluster_id)
|
self.LOG.info('Cluster %s succeeded.', cluster_id)
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
except exceptions.NotFound:
|
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
|
return False
|
||||||
|
|
||||||
def does_cluster_exist(self, cluster_id):
|
def does_cluster_exist(self, cluster_id):
|
||||||
try:
|
try:
|
||||||
resp, model = self.get_cluster(cluster_id)
|
resp, model = self.get_cluster(cluster_id)
|
||||||
if model.status in ['CREATED', 'CREATE_COMPLETE']:
|
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
|
return True
|
||||||
elif model.status in ['ERROR', 'CREATE_FAILED']:
|
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)
|
cluster_id)
|
||||||
raise exceptions.ServerFault(
|
raise exceptions.ServerFault(
|
||||||
"Got into an error condition: %s for %s" %
|
"Got into an error condition: %s for %s",
|
||||||
(model.status, cluster_id))
|
(model.status, cluster_id))
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
except exceptions.NotFound:
|
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
|
return False
|
||||||
|
|
||||||
def does_cluster_not_exist(self, cluster_id):
|
def does_cluster_not_exist(self, cluster_id):
|
||||||
try:
|
try:
|
||||||
self.get_cluster(cluster_id)
|
self.get_cluster(cluster_id)
|
||||||
except exceptions.NotFound:
|
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 True
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -81,23 +81,23 @@ class BayTest(base.BaseTempestTest):
|
||||||
super(BayTest, self).tearDown()
|
super(BayTest, self).tearDown()
|
||||||
|
|
||||||
def _create_baymodel(self, baymodel_model):
|
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)
|
resp, model = self.baymodel_client.post_baymodel(baymodel_model)
|
||||||
return resp, model
|
return resp, model
|
||||||
|
|
||||||
def _delete_baymodel(self, baymodel_id):
|
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)
|
resp, model = self.baymodel_client.delete_baymodel(baymodel_id)
|
||||||
return resp, model
|
return resp, model
|
||||||
|
|
||||||
def _create_bay(self, bay_model, is_async=False):
|
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',
|
headers = {'Content-Type': 'application/json',
|
||||||
'Accept': 'application/json'}
|
'Accept': 'application/json'}
|
||||||
if is_async:
|
if is_async:
|
||||||
headers["OpenStack-API-Version"] = "container-infra 1.2"
|
headers["OpenStack-API-Version"] = "container-infra 1.2"
|
||||||
resp, model = self.bay_client.post_bay(bay_model, headers=headers)
|
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:
|
if is_async:
|
||||||
self.assertEqual(202, resp.status)
|
self.assertEqual(202, resp.status)
|
||||||
else:
|
else:
|
||||||
|
@ -117,7 +117,7 @@ class BayTest(base.BaseTempestTest):
|
||||||
return resp, model
|
return resp, model
|
||||||
|
|
||||||
def _delete_bay(self, bay_id):
|
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)
|
resp, model = self.bay_client.delete_bay(bay_id)
|
||||||
self.assertEqual(204, resp.status)
|
self.assertEqual(204, resp.status)
|
||||||
self.bay_client.wait_for_bay_to_delete(bay_id)
|
self.bay_client.wait_for_bay_to_delete(bay_id)
|
||||||
|
|
|
@ -86,21 +86,21 @@ class ClusterTest(base.BaseTempestTest):
|
||||||
super(ClusterTest, self).tearDown()
|
super(ClusterTest, self).tearDown()
|
||||||
|
|
||||||
def _create_cluster_template(self, cm_model):
|
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(
|
resp, model = self.cluster_template_client.post_cluster_template(
|
||||||
cm_model)
|
cm_model)
|
||||||
return resp, model
|
return resp, model
|
||||||
|
|
||||||
def _delete_cluster_template(self, cm_id):
|
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(
|
resp, model = self.cluster_template_client.delete_cluster_template(
|
||||||
cm_id)
|
cm_id)
|
||||||
return resp, model
|
return resp, model
|
||||||
|
|
||||||
def _create_cluster(self, cluster_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)
|
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.assertEqual(202, resp.status)
|
||||||
self.assertIsNotNone(model.uuid)
|
self.assertIsNotNone(model.uuid)
|
||||||
self.assertTrue(uuidutils.is_uuid_like(model.uuid))
|
self.assertTrue(uuidutils.is_uuid_like(model.uuid))
|
||||||
|
@ -118,7 +118,7 @@ class ClusterTest(base.BaseTempestTest):
|
||||||
return resp, model
|
return resp, model
|
||||||
|
|
||||||
def _delete_cluster(self, cluster_id):
|
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)
|
resp, model = self.cluster_client.delete_cluster(cluster_id)
|
||||||
self.assertEqual(204, resp.status)
|
self.assertEqual(204, resp.status)
|
||||||
self.cluster_client.wait_for_cluster_to_delete(cluster_id)
|
self.cluster_client.wait_for_cluster_to_delete(cluster_id)
|
||||||
|
@ -159,7 +159,7 @@ class ClusterTest(base.BaseTempestTest):
|
||||||
# test ca show
|
# test ca show
|
||||||
resp, cert_model = self.cert_client.get_cert(
|
resp, cert_model = self.cert_client.get_cert(
|
||||||
cluster_model.uuid, headers=HEADERS)
|
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(200, resp.status)
|
||||||
self.assertEqual(cert_model.cluster_uuid, cluster_model.uuid)
|
self.assertEqual(cert_model.cluster_uuid, cluster_model.uuid)
|
||||||
self.assertIsNotNone(cert_model.pem)
|
self.assertIsNotNone(cert_model.pem)
|
||||||
|
@ -186,7 +186,7 @@ Q0uA0aVog3f5iJxCa3Hp5gxbJQ6zV6kJ0TEsuaaOhEko9sdpCoPOnRBm2i/XRD2D
|
||||||
csr_data=csr_sample)
|
csr_data=csr_sample)
|
||||||
resp, cert_model = self.cert_client.post_cert(cert_data_model,
|
resp, cert_model = self.cert_client.post_cert(cert_data_model,
|
||||||
headers=HEADERS)
|
headers=HEADERS)
|
||||||
self.LOG.debug("cert resp: %s" % resp)
|
self.LOG.debug("cert resp: %s", resp)
|
||||||
self.assertEqual(201, resp.status)
|
self.assertEqual(201, resp.status)
|
||||||
self.assertEqual(cert_model.cluster_uuid, cluster_model.uuid)
|
self.assertEqual(cert_model.cluster_uuid, cluster_model.uuid)
|
||||||
self.assertIsNotNone(cert_model.pem)
|
self.assertIsNotNone(cert_model.pem)
|
||||||
|
|
|
@ -66,8 +66,8 @@ class BaseMagnumTest(base.BaseTestCase):
|
||||||
log_name = prefix + "-" + func_name
|
log_name = prefix + "-" + func_name
|
||||||
for node_address in nodes_address:
|
for node_address in nodes_address:
|
||||||
try:
|
try:
|
||||||
cls.LOG.debug("running %s" % full_location)
|
cls.LOG.debug("running %s", full_location)
|
||||||
cls.LOG.debug("keypair: %s" % keypair)
|
cls.LOG.debug("keypair: %s", keypair)
|
||||||
subprocess.check_call([
|
subprocess.check_call([
|
||||||
full_location,
|
full_location,
|
||||||
node_address,
|
node_address,
|
||||||
|
|
|
@ -133,7 +133,7 @@ class BaseMagnumClient(base.BaseMagnumTest):
|
||||||
|
|
||||||
def _check_status():
|
def _check_status():
|
||||||
status = cls.cs.clusters.get(cluster.uuid).status
|
status = cls.cs.clusters.get(cluster.uuid).status
|
||||||
cls.LOG.debug("Cluster status is %s" % status)
|
cls.LOG.debug("Cluster status is %s", status)
|
||||||
if status in wait_status:
|
if status in wait_status:
|
||||||
return False
|
return False
|
||||||
elif status in finish_status:
|
elif status in finish_status:
|
||||||
|
@ -312,7 +312,7 @@ extendedKeyUsage = clientAuth
|
||||||
nodes = self._get_nodes_from_stack()
|
nodes = self._get_nodes_from_stack()
|
||||||
if not [x for x in nodes if x]:
|
if not [x for x in nodes if x]:
|
||||||
self.LOG.info("the list of nodes from stack is empty")
|
self.LOG.info("the list of nodes from stack is empty")
|
||||||
self.LOG.info("Nodes are: %s" % nodes)
|
self.LOG.info("Nodes are: %s", nodes)
|
||||||
return nodes
|
return nodes
|
||||||
|
|
||||||
def _get_nodes_from_cluster(self):
|
def _get_nodes_from_cluster(self):
|
||||||
|
|
3
tox.ini
3
tox.ini
|
@ -133,7 +133,8 @@ commands =
|
||||||
[flake8]
|
[flake8]
|
||||||
# H106 Don’t put vim configuration in source files
|
# H106 Don’t put vim configuration in source files
|
||||||
# H203 Use assertIs(Not)None to check for None
|
# H203 Use assertIs(Not)None to check for None
|
||||||
enable-extensions = H106,H203
|
# H904 Delay string interpolations at logging calls
|
||||||
|
enable-extensions = H106,H203,H904
|
||||||
exclude = .venv,.git,.tox,dist,*lib/python*,*egg,build,tools,releasenotes
|
exclude = .venv,.git,.tox,dist,*lib/python*,*egg,build,tools,releasenotes
|
||||||
|
|
||||||
[hacking]
|
[hacking]
|
||||||
|
|
Loading…
Reference in New Issue