From b8472607684a7ca9c73f86296144fe83a6d5e4f4 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 19 Jan 2020 09:16:29 +0100 Subject: [PATCH] ++network --- uncloud/hack/main.py | 13 +++++++++++++ uncloud/hack/net.py | 6 ++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/uncloud/hack/main.py b/uncloud/hack/main.py index d7a4714..4ccb74a 100644 --- a/uncloud/hack/main.py +++ b/uncloud/hack/main.py @@ -3,6 +3,8 @@ import argparse from uncloud.hack.vm import VM from uncloud.hack.config import Config from uncloud.hack.mac import MAC +from uncloud.hack.net import VXLANBridge, DNSRA + from uncloud import UncloudException arg_parser = argparse.ArgumentParser('hack', add_help=False) @@ -10,6 +12,8 @@ arg_parser = argparse.ArgumentParser('hack', add_help=False) arg_parser.add_argument('--create-vm', action='store_true') arg_parser.add_argument('--last-used-mac', action='store_true') arg_parser.add_argument('--get-new-mac', action='store_true') + +arg_parser.add_argument('--init-network', help="Initialise networking") arg_parser.add_argument('--management-network', help="IPv6 management network") arg_parser.add_argument('--run-dns-ra', action='store_true', help="Provide router advertisements and DNS resolution via dnsmasq") @@ -33,6 +37,15 @@ def main(arguments): if arguments['get_new_mac']: print(MAC(config).get_next()) + if arguments['init_networking!']: + if not arguments['management_network']: + raise UncloudException("Initialising the network requires an IPv6 network. You can use fd00::/64 for testing (non production!)") + vb = VXLANBridge(arguments['management_network']) + vb.setup() + if arguments['run_dns_ra']: if not arguments['management_network']: raise UncloudException("Providing DNS/RAs requires a /64 IPv6 network. You can use fd00::/64 for testing (non production!)") + + dnsra = DNSRA(arguments['management_network']) + dnsra.setup() diff --git a/uncloud/hack/net.py b/uncloud/hack/net.py index 0a7819b..11649b8 100644 --- a/uncloud/hack/net.py +++ b/uncloud/hack/net.py @@ -1,7 +1,10 @@ import subprocess +class ManagementBridge(VXLANBridge): + pass + class VXLANBridge(object): - def __init__(self, bridgedev=None, uplinkdev=None): + def __init__(self, vni, bridgedev=None, uplinkdev=None): self.management_vni = 1 cmd_create_vxlan = "ip -6 link add {vxlandev} type vxlan id {netid} dstport 4789 group ff05::{netid} dev {uplinkdev} ttl 5" @@ -11,7 +14,6 @@ class VXLANBridge(object): cmd_add_addr="ip addr add {ip} dev {bridgedev}" def setup_networking(dev=wlan0, v6net): - ip=2a0a:e5c1:111:888::48/64 vxlandev=vxlan${netid} bridgedev=br${netid}