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/tenant_validator.py b/scripts/tenant_validator.py
index 0ce504e..56c6ed7 100644
--- a/scripts/tenant_validator.py
+++ b/scripts/tenant_validator.py
@@ -8,15 +8,15 @@
from __future__ import absolute_import
+import argparse
+import logging
import re
import sys
-import yaml
-import logging
-import argparse
+
+import netaddr
import pynetbox
import requests
-import netaddr
-
+import yaml
logging.basicConfig()
logger = logging.getLogger("TenentValidator")
@@ -37,7 +37,7 @@
)
-class Configuration(object):
+class Configuration:
mapping_dict = {
logging.ERROR: logger.error,
@@ -67,7 +67,7 @@
return ("/".join(obj.url.split("/")[-4:-2]),)
-def validate_vlans(vlans=list()):
+def validate_vlans(vlans=None):
global misconfs
for vlan in vlans:
@@ -79,7 +79,7 @@
misconfs.append(Configuration(vlan, "VLAN tenant isn't set"))
-def validate_prefixes(prefixes=list()):
+def validate_prefixes(prefixes=None):
global misconfs
tenant_dict = dict()
@@ -154,7 +154,7 @@
dhcp_range = dhcp_addr[0].address
ip_addrs = netboxapi.ipam.ip_addresses.filter(parent=dhcp_range)
- ip_addrs = list(filter(lambda ip: ip != dhcp_addr[0], ip_addrs))
+ ip_addrs = ip_addrs.remove(dhcp_addr[0])
if ip_addrs:
misconfs.append(
Configuration(
@@ -165,7 +165,7 @@
)
-def validate_ip_addresses(ip_addresses=list()):
+def validate_ip_addresses(ip_addresses=None):
global misconfs
prefix_dict = dict()
@@ -187,7 +187,7 @@
)
-def validate_interfaces(interfaces=list()):
+def validate_interfaces(interfaces=None):
global misconfs
for interface in interfaces:
@@ -233,7 +233,7 @@
)
-def validate_vrfs(vrfs=list()):
+def validate_vrfs(vrfs=None):
global misconfs
for vrf in vrfs:
@@ -246,7 +246,7 @@
misconfs.append(Configuration(vrf, "VRF doesn't have tenant set"))
-def validate_machines(machines=list()):
+def validate_machines(machines=None):
global misconfs
tenant_info = dict()
@@ -298,7 +298,7 @@
)
-def validate_tenants(tenants=list()):
+def validate_tenants(tenants=None):
global misconfs
for tenant in tenants:
@@ -322,7 +322,7 @@
tenants = list(netboxapi.tenancy.tenants.filter(name=tenant_name))
if len(tenants) == 0:
- logger.critical("Tenant name %s wasn't found in Netbox" % tenant_name)
+ logger.critical("Tenant name %s wasn't found in Netbox", tenant_name)
sys.exit(1)
tenant_id = None if len(tenants) != 1 else tenants[0].id