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/pxeconfig.py b/scripts/pxeconfig.py
index 97aedab..fe9e1a7 100644
--- a/scripts/pxeconfig.py
+++ b/scripts/pxeconfig.py
@@ -11,7 +11,6 @@
from __future__ import absolute_import
import nbhelper
-
from ruamel import yaml
# main function that calls other functions
@@ -28,24 +27,25 @@
}
args = nbhelper.initialize(extra_args)
- tenant = nbhelper.NBTenant()
+ tenant = nbhelper.Tenant()
yaml_out = {}
pxeboot_hosts = []
- prefixes = nbhelper.NBPrefix.all_prefixes()
- devices = nbhelper.NBDevice.all_objects()
-
- for dev_id, device in devices.items():
+ for device in tenant.get_devices():
# only pxeboot for servers
- if device.data["device_role"]["slug"] == "server":
+ if device.data.device_role.slug in ["server", "router"]:
pxe_dev = {}
- pxe_dev["serial"] = device.data["serial"]
pxe_dev["hostname"] = device.data["name"]
pxe_dev["domain"] = args.domain_extension
- pxe_dev["mac_address"] = device.primary_iface()["mac_address"].lower()
+
+ if device.data["serial"]:
+ pxe_dev["serial"] = device.data["serial"]
+
+ if device.primary_iface["mac_address"]:
+ pxe_dev["mac_address"] = device.primary_iface["mac_address"].lower()
pxeboot_hosts.append(pxe_dev)