Verified Commit 1a0a75d6 authored by Adrian Schollmeyer's avatar Adrian Schollmeyer
Browse files

generator/host: Refactor OS detection

parent 246c1ff0
......@@ -219,33 +219,23 @@ def create_icinga2_host_object_from_netbox(netbox, device_name):
continue
ssh_ports.append(p)
device_is_linux = False
os = None
if device.platform:
device_platform = device.platform.slug
for linux_platform in LINUX_PLATFORMS:
if device_platform == linux_platform:
device_is_linux = True
os = "Linux"
break
if device_is_linux:
host = Icinga2Host(
device_name,
"server",
parent,
primary_ip4,
primary_ip6,
ssh_port,
"Linux"
)
else:
host = Icinga2Host(
device_name,
"server",
parent,
primary_ip4,
primary_ip6,
ssh_port
)
host = Icinga2Host(
device_name,
"server",
parent,
primary_ip4,
primary_ip6,
ssh_port,
os
)
if device.device_role.slug == "vm-host":
host.host_class = "vm-host"
......
Supports Markdown
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