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) #description="Commands that are unfinished - use at own risk") 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") def main(arguments): print(arguments) config = Config(arguments) if arguments['create_vm']: print("Creating VM") vm = VM(config) vm.create() if arguments['last_used_mac']: m = MAC(config) print(m.last_used_mac()) 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()