From 84e5176e0759d1bab77ec6d5a360bbb82a3ce33e Mon Sep 17 00:00:00 2001 From: mwiegand Date: Thu, 17 Jun 2021 01:56:05 +0200 Subject: [PATCH] wip --- bundles/network/metadata.py | 20 ++++++++++++++++++++ nodes/home.server.py | 12 ++++-------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/bundles/network/metadata.py b/bundles/network/metadata.py index 3eb82b8..abf2a02 100644 --- a/bundles/network/metadata.py +++ b/bundles/network/metadata.py @@ -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] + ), + } + } diff --git a/nodes/home.server.py b/nodes/home.server.py index 007cdea..8a76ff5 100644 --- a/nodes/home.server.py +++ b/nodes/home.server.py @@ -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',