forked from uncloud/uncloud
++network
This commit is contained in:
parent
1b5a3f6d2e
commit
b847260768
2 changed files with 17 additions and 2 deletions
|
@ -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()
|
||||
|
|
|
@ -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}
|
||||
|
||||
|
|
Loading…
Reference in a new issue