bundles/routeros: this does not need to be a metadata reactor

This commit is contained in:
Franzi 2024-06-22 20:39:04 +02:00
parent d1f182607d
commit b72d82b894
Signed by: kunsi
GPG key ID: 12E3D2136B818350

View file

@ -2,36 +2,13 @@ import re
from json import load
from os.path import join
defaults = {
'icinga2_api': {
'routeros': {
'services': {
'TEMPERATURE': {
'check_command': 'snmp',
'vars.snmp_oid': '1.3.6.1.4.1.14988.1.1.3.11.0',
'vars.snmp_version': '2c',
'vars.snmp_community': 'public',
'vars.warn': '@750:799', # 1/10 °C
'vars.crit': '@800:9999',
},
},
},
},
}
@metadata_reactor.provides(
'routeros/ips',
'routeros/ports',
'routeros/vlans',
)
def get_ports_from_netbox_dump(metadata):
with open(join(repo.path, 'configs', 'netbox', f'{node.name}.json')) as f:
with open(join(repo.path, 'configs', 'netbox', f'{node.name}.json')) as f:
netbox = load(f)
ips = {}
ports = {}
vlans = {
ips = {}
ports = {}
vlans = {
v['name']: {
'id': v['vid'],
'delete': False,
@ -39,9 +16,9 @@ def get_ports_from_netbox_dump(metadata):
'untagged': set(),
}
for v in netbox['vlans']
}
}
for port, conf in netbox['interfaces'].items():
for port, conf in netbox['interfaces'].items():
for ip in conf['ips']:
ips[ip] = {'interface': port}
@ -104,13 +81,27 @@ def get_ports_from_netbox_dump(metadata):
if conf['ips']:
vlans[vlan]['tagged'].add('bridge')
return {
defaults = {
'icinga2_api': {
'routeros': {
'services': {
'TEMPERATURE': {
'check_command': 'snmp',
'vars.snmp_oid': '1.3.6.1.4.1.14988.1.1.3.11.0',
'vars.snmp_version': '2c',
'vars.snmp_community': 'public',
'vars.warn': '@750:799', # 1/10 °C
'vars.crit': '@800:9999',
},
},
},
},
'routeros': {
'ips': ips,
'ports': ports,
'vlans': vlans,
}
}
},
}
@metadata_reactor.provides('routeros/gateway')