bundlewrap/bundles/hetzner-cloud/metadata.py
mwiegand 4dd42db7f2 wip
2021-10-10 17:15:08 +02:00

27 lines
762 B
Python

from ipaddress import ip_network, ip_interface
@metadata_reactor.provides(
'systemd/units',
)
def network(metadata):
interface = ip_interface(metadata.get('network/internal/ipv4'))
network = ip_interface(f'{interface.ip}/24').network
gateway = network[1]
return {
'systemd': {
'units': {
'internal.network': {
f'Route#hetzner_gateway': {
'Destination': str(gateway),
'Scope': 'link',
},
f'Route#hetzner_network': {
'Destination': str(network),
'Gateway': str(gateway),
},
},
},
},
}