Address PEP8 Failures in Drydock
Flake8 version recently updated to include new PEP8 rules. Some of the codebase is not compliant with the new rules. Change-Id: I0f5b3d41ee54ff0d9ffa05f733f98c7e34f0f258 Signed-off-by: Alexander Hughes <Alexander.Hughes@pm.me>
This commit is contained in:
parent
80c82d8957
commit
1755930331
@ -207,8 +207,8 @@ class DesignsPartsResource(StatefulResource):
|
||||
|
||||
part_catalog.extend([{
|
||||
'kind': 'NetworkLink',
|
||||
'key': l.get_id()
|
||||
} for l in design.network_links])
|
||||
'key': link.get_id()
|
||||
} for link in design.network_links])
|
||||
|
||||
part_catalog.extend([{
|
||||
'kind': 'HostProfile',
|
||||
|
@ -444,13 +444,13 @@ class CreateNetworkTemplate(BaseMaasAction):
|
||||
domains = maas_domain.Domains(self.maas_client)
|
||||
domains.refresh()
|
||||
|
||||
for l in design_links:
|
||||
if l.metalabels is not None:
|
||||
for design_link in design_links:
|
||||
if design_link.metalabels is not None:
|
||||
# TODO(sh8121att): move metalabels into config
|
||||
if 'noconfig' in l.metalabels:
|
||||
if 'noconfig' in design_link.metalabels:
|
||||
self.logger.info(
|
||||
"NetworkLink %s marked 'noconfig', skipping configuration including allowed networks."
|
||||
% (l.name))
|
||||
% (design_link.name))
|
||||
continue
|
||||
|
||||
fabrics_found = set()
|
||||
@ -460,17 +460,17 @@ class CreateNetworkTemplate(BaseMaasAction):
|
||||
# our design. This means all self-discovered networks that are matched
|
||||
# to a link need to all be part of the same fabric. Otherwise there is no
|
||||
# way to reconcile the discovered topology with the designed topology
|
||||
for net_name in l.allowed_networks:
|
||||
for net_name in design_link.allowed_networks:
|
||||
n = site_design.get_network(net_name)
|
||||
|
||||
if n is None:
|
||||
msg = "Network %s allowed on link %s, but not defined." % (
|
||||
net_name, l.name)
|
||||
net_name, design_link.name)
|
||||
self.logger.warning(msg)
|
||||
self.task.add_status_msg(
|
||||
msg=msg,
|
||||
error=True,
|
||||
ctx=l.name,
|
||||
ctx=design_link.name,
|
||||
ctx_type='network_link')
|
||||
continue
|
||||
|
||||
@ -480,22 +480,22 @@ class CreateNetworkTemplate(BaseMaasAction):
|
||||
fabrics_found.add(maas_net.fabric)
|
||||
|
||||
if len(fabrics_found) > 1:
|
||||
msg = "MaaS self-discovered network incompatible with NetworkLink %s" % l.name
|
||||
msg = "MaaS self-discovered network incompatible with NetworkLink %s" % design_link.name
|
||||
self.logger.warning(msg)
|
||||
self.task.add_status_msg(
|
||||
msg=msg, error=True, ctx=l.name, ctx_type='network_link')
|
||||
msg=msg, error=True, ctx=design_link.name, ctx_type='network_link')
|
||||
continue
|
||||
elif len(fabrics_found) == 1:
|
||||
link_fabric_id = fabrics_found.pop()
|
||||
link_fabric = fabrics.select(link_fabric_id)
|
||||
link_fabric.name = l.name
|
||||
link_fabric.name = design_link.name
|
||||
link_fabric.update()
|
||||
else:
|
||||
link_fabric = fabrics.singleton({'name': l.name})
|
||||
link_fabric = fabrics.singleton({'name': design_link.name})
|
||||
|
||||
if link_fabric is None:
|
||||
link_fabric = maas_fabric.Fabric(
|
||||
self.maas_client, name=l.name)
|
||||
self.maas_client, name=design_link.name)
|
||||
link_fabric = fabrics.add(link_fabric)
|
||||
|
||||
# Ensure that the MTU of the untagged VLAN on the fabric
|
||||
@ -504,14 +504,14 @@ class CreateNetworkTemplate(BaseMaasAction):
|
||||
vlan_list = maas_vlan.Vlans(
|
||||
self.maas_client, fabric_id=link_fabric.resource_id)
|
||||
vlan_list.refresh()
|
||||
msg = "Updating native VLAN MTU = %d on network link %s" % (l.mtu,
|
||||
l.name)
|
||||
msg = "Updating native VLAN MTU = %d on network link %s" % (design_link.mtu,
|
||||
design_link.name)
|
||||
self.logger.debug(msg)
|
||||
self.task.add_status_msg(
|
||||
msg=msg, error=False, ctx=l.name, ctx_type='network_link')
|
||||
msg=msg, error=False, ctx=design_link.name, ctx_type='network_link')
|
||||
vlan = vlan_list.singleton({'vid': 0})
|
||||
if vlan:
|
||||
vlan.mtu = l.mtu
|
||||
vlan.mtu = design_link.mtu
|
||||
vlan.update()
|
||||
else:
|
||||
self.logger.warning("Unable to find native VLAN on fabric %s."
|
||||
@ -519,7 +519,7 @@ class CreateNetworkTemplate(BaseMaasAction):
|
||||
|
||||
# Now that we have the fabrics sorted out, check
|
||||
# that VLAN tags and subnet attributes are correct
|
||||
for net_name in l.allowed_networks:
|
||||
for net_name in design_link.allowed_networks:
|
||||
n = site_design.get_network(net_name)
|
||||
design_networks.append(n)
|
||||
|
||||
@ -551,7 +551,7 @@ class CreateNetworkTemplate(BaseMaasAction):
|
||||
|
||||
fabric_list = maas_fabric.Fabrics(self.maas_client)
|
||||
fabric_list.refresh()
|
||||
fabric = fabric_list.singleton({'name': l.name})
|
||||
fabric = fabric_list.singleton({'name': design_link.name})
|
||||
|
||||
if fabric is not None:
|
||||
vlan_list = maas_vlan.Vlans(
|
||||
@ -620,7 +620,7 @@ class CreateNetworkTemplate(BaseMaasAction):
|
||||
ctx_type='network')
|
||||
else:
|
||||
msg = "Fabric %s should be created, but cannot locate it." % (
|
||||
l.name)
|
||||
design_link.name)
|
||||
self.logger.error(msg)
|
||||
self.task.add_status_msg(
|
||||
msg=msg,
|
||||
|
@ -102,8 +102,8 @@ class Interface(model_base.ResourceBase):
|
||||
|
||||
:param subnet_id: MaaS resource id of the subnet
|
||||
"""
|
||||
for l in self.links:
|
||||
if l.get('subnet_id', None) == subnet_id:
|
||||
for link in self.links:
|
||||
if link.get('subnet_id', None) == subnet_id:
|
||||
return True
|
||||
|
||||
return False
|
||||
@ -125,14 +125,14 @@ class Interface(model_base.ResourceBase):
|
||||
(resp.status_code, resp.text))
|
||||
|
||||
def unlink_subnet(self, subnet_id):
|
||||
for l in self.links:
|
||||
if l.get('subnet_id', None) == subnet_id:
|
||||
for link in self.links:
|
||||
if link.get('subnet_id', None) == subnet_id:
|
||||
url = self.interpolate_url()
|
||||
|
||||
resp = self.api_client.post(
|
||||
url,
|
||||
op='unlink_subnet',
|
||||
files={'id': l.get('resource_id')})
|
||||
files={'id': link.get('resource_id')})
|
||||
|
||||
if not resp.ok:
|
||||
raise errors.DriverError("Error unlinking subnet")
|
||||
@ -229,8 +229,8 @@ class Interface(model_base.ResourceBase):
|
||||
|
||||
:return: true if this interface should respond to the IP, false otherwise
|
||||
"""
|
||||
for l in getattr(self, 'links', []):
|
||||
if l.get('ip_address', None) == ip_address:
|
||||
for link in getattr(self, 'links', []):
|
||||
if link.get('ip_address', None) == ip_address:
|
||||
return True
|
||||
|
||||
return False
|
||||
@ -273,13 +273,13 @@ class Interface(model_base.ResourceBase):
|
||||
|
||||
link_list = []
|
||||
if isinstance(refined_dict.get('links', None), list):
|
||||
for l in refined_dict['links']:
|
||||
if isinstance(l, dict):
|
||||
link = {'resource_id': l['id'], 'mode': l['mode']}
|
||||
for link in refined_dict['links']:
|
||||
if isinstance(link, dict):
|
||||
link = {'resource_id': link['id'], 'mode': link['mode']}
|
||||
|
||||
if l.get('subnet', None) is not None:
|
||||
link['subnet_id'] = l['subnet']['id']
|
||||
link['ip_address'] = l.get('ip_address', None)
|
||||
if link.get('subnet', None) is not None:
|
||||
link['subnet_id'] = link['subnet']['id']
|
||||
link['ip_address'] = link.get('ip_address', None)
|
||||
|
||||
link_list.append(link)
|
||||
|
||||
|
@ -417,7 +417,7 @@ class Machine(model_base.ResourceBase):
|
||||
return True
|
||||
|
||||
raise errors.DriverError(
|
||||
"Failed updating power parameters MAAS url %s - return code %s\n%s"
|
||||
"Failed updating power parameters MAAS url %s - return code %s\n"
|
||||
% (url, resp.status_code.resp.text))
|
||||
|
||||
def reset_power_parameters(self):
|
||||
@ -440,7 +440,7 @@ class Machine(model_base.ResourceBase):
|
||||
return True
|
||||
|
||||
raise errors.DriverError(
|
||||
"Failed updating power parameters MAAS url {} - return code {}\n{}"
|
||||
"Failed updating power parameters MAAS url {} - return code {}\n"
|
||||
.format(url, resp.status_code.resp.text))
|
||||
|
||||
def update_identity(self, n, domain="local"):
|
||||
|
@ -222,9 +222,9 @@ class SiteDesign(base.DrydockPersistentObject, base.DrydockObject):
|
||||
|
||||
def get_network_link(self, link_key):
|
||||
if self.network_links:
|
||||
for l in self.network_links:
|
||||
if l.get_id() == link_key:
|
||||
return l
|
||||
for network_link in self.network_links:
|
||||
if network_link.get_id() == link_key:
|
||||
return network_link
|
||||
|
||||
raise errors.DesignError(
|
||||
"NetworkLink %s not found in design state" % link_key)
|
||||
|
@ -544,8 +544,8 @@ class Orchestrator(object):
|
||||
"""
|
||||
results = set()
|
||||
if len(lists) > 1:
|
||||
for l in lists:
|
||||
results = results.union(set(l))
|
||||
for current_list in lists:
|
||||
results = results.union(set(current_list))
|
||||
return list(results)
|
||||
elif len(lists) == 1:
|
||||
return list(set(lists[0]))
|
||||
|
@ -42,10 +42,10 @@ class HostnameValidity(Validators):
|
||||
|
||||
for n in node_list:
|
||||
domain_labels = n.get_fqdn(site_design).split('.')
|
||||
for l in domain_labels:
|
||||
if not valid_label.fullmatch(l):
|
||||
for domain_label in domain_labels:
|
||||
if not valid_label.fullmatch(domain_label):
|
||||
msg = "FQDN %s is invalid - label '%s' is invalid." % (
|
||||
n.get_fqdn(site_design), l)
|
||||
n.get_fqdn(site_design), domain_label)
|
||||
self.report_error(
|
||||
msg, [n.doc_ref],
|
||||
"RFC 1035 requires each label in a DNS name to be <= 63 characters and contain "
|
||||
|
@ -81,5 +81,5 @@ class TestNodeResultLinks(object):
|
||||
|
||||
assert len(links_list) > 0
|
||||
|
||||
for l in links_list:
|
||||
assert str(task.task_id) in l
|
||||
for link in links_list:
|
||||
assert str(task.task_id) in link
|
||||
|
Loading…
x
Reference in New Issue
Block a user