Fix files to make test can pass linting check
Change-Id: Id13a108f20937b542733c5ec9fbf82ee8f004801
diff --git a/scripts/nbhelper.py b/scripts/nbhelper.py
index 8b540dd..d0aa8fa 100644
--- a/scripts/nbhelper.py
+++ b/scripts/nbhelper.py
@@ -174,14 +174,15 @@
target = None
if not name:
- target = next(
- filter(
- lambda m: m.data["device_role"]["name"] == "Router",
- self.devices + self.vms,
- )
- )
+ for machine in self.devices + self.vms:
+ if machine.data["device_role"]["name"] == "Router":
+ target = machine
+ break
else:
- target = next(filter(lambda m: m.name == name, self.devices + self.vms))
+ for machine in self.devices + self.vms:
+ if machine.name == name:
+ target = machine
+ break
return target.generate_netplan()
@@ -510,18 +511,12 @@
primary_ip = self.data.primary_ip.address if self.data.primary_ip else None
primary_if = self.interfaces_by_ip[primary_ip] if primary_ip else None
- physical_ifs = filter(
- lambda i: str(i.type) != "Virtual"
- and i != primary_if
- and i.mgmt_only == False,
- self.interfaces,
- )
self.netplan_config["ethernets"] = dict()
if self.data.device_role.name == "Router":
for address, interface in self.interfaces_by_ip.items():
- if interface.mgmt_only == True or str(interface.type) == "Virtual":
+ if interface.mgmt_only is True or str(interface.type) == "Virtual":
continue
self.netplan_config["ethernets"].setdefault(interface.name, {})
@@ -536,7 +531,12 @@
"dhcp4-overrides": {"route-metric": 100},
}
- for physical_if in physical_ifs:
+ for physical_if in filter(
+ lambda i: str(i.type) != "Virtual"
+ and i != primary_if
+ and i.mgmt_only is False,
+ self.interfaces,
+ ):
self.netplan_config["ethernets"][physical_if.name] = {
"dhcp4": "yes",
"dhcp4-overrides": {"route-metric": 200},
@@ -546,9 +546,7 @@
return None
# Get interfaces own by AssignedObject and is virtual (VLAN interface)
- virtual_ifs = filter(lambda i: str(i.type) == "Virtual", self.interfaces)
-
- for virtual_if in virtual_ifs:
+ for virtual_if in filter(lambda i: str(i.type) == "Virtual", self.interfaces):
if "vlans" not in self.netplan_config:
self.netplan_config["vlans"] = dict()
@@ -995,7 +993,7 @@
if mac_addr and mac_addr.strip(): # if exists and not blank
self.hosts.append(
- {"name": name, "ip_addr": target_ip, "mac_addr": mac_addr.lower(),}
+ {"name": name, "ip_addr": target_ip, "mac_addr": mac_addr.lower()}
)
# add dns servers