Enable gating on H904 and fix existing violations
Change-Id: I246e5e13ef08383bb38fc896dfd68dd4bdd76c6d
This commit is contained in:
parent
497b6522ee
commit
fdaaa90203
3
tox.ini
3
tox.ini
@ -31,7 +31,6 @@ commands = {posargs}
|
||||
[flake8]
|
||||
# H302 import only modules.
|
||||
# H405 multi line docstring summary not separated with an empty line
|
||||
# H904 Wrap long lines in parentheses instead of a backslash
|
||||
ignore = H302,H405,H904
|
||||
ignore = H302,H405
|
||||
builtins = _
|
||||
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools
|
||||
|
@ -14,8 +14,7 @@
|
||||
import pecan
|
||||
|
||||
from tuskar.api.controllers.v1.overcloud import OvercloudsController
|
||||
from tuskar.api.controllers.v1.overcloud_roles \
|
||||
import OvercloudRolesController
|
||||
from tuskar.api.controllers.v1.overcloud_roles import OvercloudRolesController
|
||||
|
||||
|
||||
class Controller(object):
|
||||
|
@ -107,8 +107,8 @@ class Overcloud(Base):
|
||||
def from_db_model(cls, db_overcloud, skip_fields=None,
|
||||
mask_passwords=True):
|
||||
# General Data
|
||||
transfer_overcloud = super(Overcloud, cls)\
|
||||
.from_db_model(db_overcloud, skip_fields=['attributes', 'counts'])
|
||||
transfer_overcloud = super(Overcloud, cls).from_db_model(
|
||||
db_overcloud, skip_fields=['attributes', 'counts'])
|
||||
|
||||
# Attributes
|
||||
translated = {}
|
||||
|
@ -262,8 +262,7 @@ class OvercloudsController(rest.RestController):
|
||||
result = pecan.request.dbapi.create_overcloud(db_overcloud)
|
||||
|
||||
# Package for transfer back to the user
|
||||
saved_overcloud =\
|
||||
models.Overcloud.from_db_model(result)
|
||||
saved_overcloud = models.Overcloud.from_db_model(result)
|
||||
|
||||
return saved_overcloud
|
||||
|
||||
|
@ -52,8 +52,7 @@ class OvercloudRolesController(rest.RestController):
|
||||
result = pecan.request.dbapi.create_overcloud_role(db_role)
|
||||
|
||||
# Package for transfer back to the user
|
||||
saved_role =\
|
||||
models.OvercloudRole.from_db_model(result)
|
||||
saved_role = models.OvercloudRole.from_db_model(result)
|
||||
|
||||
return saved_role
|
||||
|
||||
|
@ -185,10 +185,12 @@ class Connection(api.Connection):
|
||||
"""
|
||||
|
||||
session = get_session()
|
||||
overclouds = session.query(models.Overcloud).\
|
||||
options(subqueryload(models.Overcloud.attributes)).\
|
||||
options(subqueryload(models.Overcloud.counts)).\
|
||||
overclouds = (
|
||||
session.query(models.Overcloud).
|
||||
options(subqueryload(models.Overcloud.attributes)).
|
||||
options(subqueryload(models.Overcloud.counts)).
|
||||
all()
|
||||
)
|
||||
session.close()
|
||||
return overclouds
|
||||
|
||||
@ -204,11 +206,13 @@ class Connection(api.Connection):
|
||||
|
||||
session = get_session()
|
||||
try:
|
||||
query = session.query(models.Overcloud).\
|
||||
options(subqueryload(models.Overcloud.attributes)).\
|
||||
options(subqueryload(models.Overcloud.counts)).\
|
||||
options(subqueryload('counts.overcloud_role')).\
|
||||
query = (
|
||||
session.query(models.Overcloud).
|
||||
options(subqueryload(models.Overcloud.attributes)).
|
||||
options(subqueryload(models.Overcloud.counts)).
|
||||
options(subqueryload('counts.overcloud_role')).
|
||||
filter_by(id=overcloud_id)
|
||||
)
|
||||
result = query.one()
|
||||
|
||||
except NoResultFound:
|
||||
@ -308,8 +312,8 @@ class Connection(api.Connection):
|
||||
def _update_overcloud_attributes(existing, session, updated):
|
||||
if updated.attributes is not None:
|
||||
existing_keys = [a.key for a in existing.attributes]
|
||||
existing_attributes_by_key = \
|
||||
dict((a.key, a) for a in existing.attributes)
|
||||
existing_attributes_by_key = (
|
||||
dict((a.key, a) for a in existing.attributes))
|
||||
|
||||
delete_keys = []
|
||||
for a in updated.attributes:
|
||||
@ -345,8 +349,8 @@ class Connection(api.Connection):
|
||||
if updated.counts is not None:
|
||||
existing_count_role_ids = [c.overcloud_role_id
|
||||
for c in existing.counts]
|
||||
existing_counts_by_role_id = \
|
||||
dict((c.overcloud_role_id, c) for c in existing.counts)
|
||||
existing_counts_by_role_id = (
|
||||
dict((c.overcloud_role_id, c) for c in existing.counts))
|
||||
|
||||
delete_role_ids = []
|
||||
for c in updated.counts:
|
||||
@ -358,8 +362,7 @@ class Connection(api.Connection):
|
||||
|
||||
# Updated
|
||||
if c.overcloud_role_id in existing_count_role_ids:
|
||||
updating = \
|
||||
existing_counts_by_role_id[c.overcloud_role_id]
|
||||
updating = existing_counts_by_role_id[c.overcloud_role_id]
|
||||
updating.num_nodes = c.num_nodes
|
||||
session.add(updating)
|
||||
continue
|
||||
|
@ -113,16 +113,18 @@ class OvercloudRoleCount(Base):
|
||||
id = Column(Integer, primary_key=True)
|
||||
|
||||
# Role being configured
|
||||
overcloud_role_id = \
|
||||
Column(Integer,
|
||||
ForeignKey('%s.id' % TABLE_OVERCLOUD_ROLE),
|
||||
nullable=False)
|
||||
overcloud_role_id = Column(
|
||||
Integer,
|
||||
ForeignKey('%s.id' % TABLE_OVERCLOUD_ROLE),
|
||||
nullable=False
|
||||
)
|
||||
|
||||
# Overcloud in which the role is being deployed
|
||||
overcloud_id = \
|
||||
Column(Integer,
|
||||
ForeignKey('%s.id' % TABLE_OVERCLOUD, ondelete='CASCADE'),
|
||||
nullable=False)
|
||||
overcloud_id = Column(
|
||||
Integer,
|
||||
ForeignKey('%s.id' % TABLE_OVERCLOUD, ondelete='CASCADE'),
|
||||
nullable=False
|
||||
)
|
||||
|
||||
# Number of nodes of this configuration that should be deployed
|
||||
num_nodes = Column(Integer, nullable=False)
|
||||
|
@ -37,8 +37,8 @@ class Template(object):
|
||||
self._outputs = [] # list of Output
|
||||
|
||||
def __str__(self):
|
||||
msg = 'Template: version=%(ver)s, description=%(desc)s, ' \
|
||||
'parameter_count=%(param)s, output_count=%(out)s'
|
||||
msg = ('Template: version=%(ver)s, description=%(desc)s, '
|
||||
'parameter_count=%(param)s, output_count=%(out)s')
|
||||
data = {
|
||||
'ver': self.version,
|
||||
'desc': _safe_strip(self.description),
|
||||
@ -84,9 +84,9 @@ class Template(object):
|
||||
|
||||
:type namespace: str
|
||||
"""
|
||||
self._parameters = \
|
||||
[p for p in self.parameters
|
||||
if not ns_utils.matches_template_namespace(namespace, p.name)]
|
||||
self._parameters = [
|
||||
p for p in self.parameters
|
||||
if not ns_utils.matches_template_namespace(namespace, p.name)]
|
||||
|
||||
def add_parameter_group(self, parameter_group):
|
||||
"""Adds a parameter group to the template.
|
||||
@ -146,9 +146,9 @@ class Template(object):
|
||||
|
||||
:type namespace: str
|
||||
"""
|
||||
self._outputs =\
|
||||
[o for o in self.outputs
|
||||
if not ns_utils.matches_template_namespace(namespace, o.name)]
|
||||
self._outputs = [
|
||||
o for o in self.outputs
|
||||
if not ns_utils.matches_template_namespace(namespace, o.name)]
|
||||
|
||||
|
||||
class ParameterGroup(object):
|
||||
@ -160,8 +160,8 @@ class ParameterGroup(object):
|
||||
self._parameter_names = set()
|
||||
|
||||
def __str__(self):
|
||||
msg = 'ParameterGroup: label=%(label)s, description=%(desc)s ' \
|
||||
'parameter_names=%(names)s'
|
||||
msg = ('ParameterGroup: label=%(label)s, description=%(desc)s '
|
||||
'parameter_names=%(names)s')
|
||||
data = {
|
||||
'label': self.label,
|
||||
'desc': self.description,
|
||||
@ -202,9 +202,9 @@ class Parameter(object):
|
||||
self._constraints = []
|
||||
|
||||
def __str__(self):
|
||||
msg = 'Parameter: name=%(name)s, type=%(type)s, ' \
|
||||
'description=%(desc)s, label=%(label)s, ' \
|
||||
'default=%(def)s, hidden=%(hidden)s'
|
||||
msg = ('Parameter: name=%(name)s, type=%(type)s, '
|
||||
'description=%(desc)s, label=%(label)s, '
|
||||
'default=%(def)s, hidden=%(hidden)s')
|
||||
data = {
|
||||
'name': self.name,
|
||||
'type': self.param_type,
|
||||
@ -244,8 +244,8 @@ class ParameterConstraint(object):
|
||||
self.description = description
|
||||
|
||||
def __str__(self):
|
||||
msg = 'Constraint: type=%(type)s, definition=%(def)s, ' \
|
||||
'description=%(desc)s'
|
||||
msg = ('Constraint: type=%(type)s, definition=%(def)s, '
|
||||
'description=%(desc)s')
|
||||
data = {
|
||||
'type': self.constraint_type,
|
||||
'def': self.definition,
|
||||
@ -338,8 +338,8 @@ class Environment(object):
|
||||
self._registry_entries = []
|
||||
|
||||
def __str__(self):
|
||||
msg = 'Environment: parameter_count=%(p_count)s, ' \
|
||||
'registry_count=%(r_count)s'
|
||||
msg = ('Environment: parameter_count=%(p_count)s, '
|
||||
'registry_count=%(r_count)s')
|
||||
data = {
|
||||
'p_count': len(self.parameters),
|
||||
'r_count': len(self.registry_entries),
|
||||
@ -374,9 +374,9 @@ class Environment(object):
|
||||
|
||||
:type namespace: str
|
||||
"""
|
||||
self._parameters =\
|
||||
[p for p in self._parameters
|
||||
if not ns_utils.matches_template_namespace(namespace, p.name)]
|
||||
self._parameters = [
|
||||
p for p in self._parameters
|
||||
if not ns_utils.matches_template_namespace(namespace, p.name)]
|
||||
|
||||
def find_parameter_by_name(self, name):
|
||||
"""Returns the parameter instance with the given name.
|
||||
|
@ -74,13 +74,13 @@ def parse_environment(content):
|
||||
|
||||
|
||||
def _parse_version(template, yaml_parsed):
|
||||
template.version = \
|
||||
yaml_parsed.get('heat_template_version', None) or template.version
|
||||
template.version = (
|
||||
yaml_parsed.get('heat_template_version', None) or template.version)
|
||||
|
||||
|
||||
def _parse_description(template, yaml_parsed):
|
||||
template.description = \
|
||||
yaml_parsed.get('description', None) or template.description
|
||||
template.description = (
|
||||
yaml_parsed.get('description', None) or template.description)
|
||||
|
||||
|
||||
def _parse_template_parameters(template, yaml_parsed):
|
||||
|
@ -36,8 +36,8 @@ class DeploymentPlan(object):
|
||||
def __init__(self, master_template=None, environment=None,
|
||||
description=None):
|
||||
super(DeploymentPlan, self).__init__()
|
||||
self.master_template = \
|
||||
master_template or Template(description=description)
|
||||
self.master_template = (
|
||||
master_template or Template(description=description))
|
||||
self.environment = environment or Environment()
|
||||
|
||||
def add_template(self, namespace, template, filename):
|
||||
|
@ -75,8 +75,8 @@ class DeploymentPlanTests(unittest.TestCase):
|
||||
self.assertEqual(2, len(p.environment.parameters))
|
||||
for env_param, template_param in zip(p.environment.parameters,
|
||||
t.parameters):
|
||||
expected_name =\
|
||||
ns_utils.apply_template_namespace('ns1', template_param.name)
|
||||
expected_name = (
|
||||
ns_utils.apply_template_namespace('ns1', template_param.name))
|
||||
self.assertEqual(env_param.name, expected_name)
|
||||
self.assertEqual(env_param.value, '')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user