Updates to scripts after refactor
- Run black to reformat all the scripts
- Update makefile test targets, pylint, and fix some of the issues found
- Update pxeconfig script for refactored nbhelper
- Add start of inventory script
Change-Id: I5f426ac2da840dc72f07f8a6844e199e47d49135
diff --git a/scripts/nbhelper/tenant.py b/scripts/nbhelper/tenant.py
index 4d529a7..a4d4048 100644
--- a/scripts/nbhelper/tenant.py
+++ b/scripts/nbhelper/tenant.py
@@ -6,7 +6,9 @@
# tenant.py
# The tenant abstract object of Netbox Object - Tenant
-from .utils import logger, netboxapi
+import sys
+
+from .utils import logger
from .device import Device, VirtualMachine
from .network import Prefix
@@ -58,9 +60,9 @@
"""
for machine in self.devices + self.vms:
- if name and machine.name == name:
- return machine
- elif machine.data["device_role"]["name"] == "Router":
+ if (name and machine.name == name) or machine.data["device_role"][
+ "name"
+ ] == "Router":
return machine
ret_msg = (
@@ -71,10 +73,12 @@
logger.error(ret_msg, name)
sys.exit(1)
- def get_devices(self, device_types=["server", "router"]):
+ def get_devices(self, device_types=None):
"""
Get all devices (Router + Server) belong to this Tenant
"""
+ if not device_types:
+ device_types = ["server", "router"]
if not device_types:
return self.devices + self.vms