Verified Commit 58cc9081 authored by Adrian Schollmeyer's avatar Adrian Schollmeyer
Browse files

generator/hosts: Add support for bridge interfaces and parent overrides

parent a7f8c252
......@@ -146,6 +146,10 @@ class Icinga2Host:
self.remote_check_method = method
def set_parent(self, parent):
self.parent = parent
def create_icinga2_config(self):
global j2_env
template = j2_env.get_template("generic-host.j2")
......@@ -340,6 +344,14 @@ class NetBoxParser:
parent = "bigsister"
if self.uplink_interface.connected_endpoint:
parent = self.uplink_interface.connected_endpoint.device.name
elif self.uplink_interface.type.value == "bridge":
bridge_members = self.netbox.dcim.interfaces.filter(
bridge_id = self.uplink_interface.id
)
for bridge_member in bridge_members:
if bridge_member.connected_endpoint:
parent = bridge_member.connected_endpoint.device.name
break
elif self.vm:
parent = self.vm.cluster.name
......@@ -549,6 +561,12 @@ class NetBoxParser:
self.host.add_procs_check(proc)
except KeyError:
pass
try:
if monitoring_config_context["parent"]:
self.host.set_parent(monitoring_config_context["parent"])
except KeyError:
pass
except KeyError as e:
pass # So there is no extra monitoring config. Who cares anyway?
......
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