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