This commit is contained in:
mwiegand 2021-06-17 01:56:05 +02:00
parent a3caa8481e
commit 84e5176e07
2 changed files with 24 additions and 8 deletions

View file

@ -1,3 +1,6 @@
from ipaddress import ip_interface
@metadata_reactor.provides(
'interfaces',
)
@ -14,3 +17,20 @@ def interfaces(metadata):
},
}
}
@metadata_reactor.provides(
'interfaces/gateway4',
'interfaces/gateway6',
)
def guess_gateway(metadata):
if metadata.get('network/gateway4', None):
return {}
else:
return {
'network': {
'gateway4': str(
ip_interface(metadata.get('network/ipv4')).network[1]
),
}
}

View file

@ -9,14 +9,10 @@
'wireguard',
],
'metadata': {
'interfaces': {
'enp1s0f0': {
'ips': {
'10.0.0.2/24',
},
'gateway4': '10.0.0.1',
},
},
'network': {
'interface': 'enp1s0f0',
'ipv4': '10.0.0.2/24',
},
'gitea': {
'version': '1.14.2',
'sha256': '0d11d87ce60d5d98e22fc52f2c8c6ba2b54b14f9c26c767a46bf102c381ad128',