Commit 34d9fbcd authored by Morten Brekkevold's avatar Morten Brekkevold
Browse files

Silence many messages about devices that aren't in production, according to Kind

parent 3c5b21ce
......@@ -184,21 +184,28 @@ def clean_data(kind_data):
invalid_names = {device for device in kind_devices
if not device_name_is_okay(}
if invalid_names:
if production_devices_by_name(invalid_names):
LOG.error("Ignorerer følgende utstyr som ikke har gyldige navn i Kind:"
"\n%s", sorted(invalid_names, key=attrgetter('name')))
"\n%s", production_devices_by_name(invalid_names))
for device in invalid_names:
device.ignore_insert = True
no_nettinstallasjon = {device for device in kind_devices
if not}
if no_nettinstallasjon:
if not and not device.ignore_insert}
if production_devices_by_name(no_nettinstallasjon):
LOG.error("Ignorerer følgende utstyr som ikke har nettinstallasjon "
"satt i Kind:\n%s",
sorted(no_nettinstallasjon, key=attrgetter('name')))
return { device for device in kind_devices
if device not in (invalid_names | no_nettinstallasjon)}
def production_devices_by_name(kind_devices):
return sorted((dev for dev in kind_devices if dev.is_in_production()),
def device_name_is_okay(name):
return '.' in name and ' ' not in name
......@@ -230,9 +237,9 @@ def lookup_addresses(kind_devices):
kind_device.loopback = addrs[0]
if with_missing_dns:
if production_devices_by_name(with_missing_dns):
LOG.error("Ignorerer utstyr som mangler DNS-innslag:\n%s",
def lookup_dns(names):
......@@ -453,12 +460,13 @@ def can_be_deleted(netbox):
class KindDevice(object):
def __init__(self, id, name, serial, room, type):
def __init__(self, id, name, serial, room, type, status=None): = id = name
self.serial = serial = room
self.type = type
self.status = status
self.loopback = None
self.ipaddrs = set()
......@@ -473,6 +481,7 @@ class KindDevice(object):
record.get('serienummer', None),
record.get('nettinstallasjon', None),
record.get('type', None),
status=record.get('status_tekst', None),
def __repr__(self):
......@@ -491,6 +500,9 @@ class KindDevice(object):
return KIND_UTSTYR_URL.format(
def is_in_production(self):
return self.status == "Installert"
if __name__ == '__main__':
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment