uncloud-mravi/uncloud_django_based/uncloud/uncloud_net/management/commands/vpn.py
Nico Schottelius 938f0a3390 update to work on different computer
Signed-off-by: Nico Schottelius <nico@nico-notebook.schottelius.org>
2020-04-07 19:45:16 +02:00

44 lines
1.1 KiB
Python

import sys
from datetime import datetime
from django.core.management.base import BaseCommand
from django.contrib.auth import get_user_model
from opennebula.models import VM as VMModel
from uncloud_vm.models import VMHost, VMProduct, VMNetworkCard, VMDiskImageProduct, VMDiskProduct, VMCluster
import logging
log = logging.getLogger(__name__)
wireguard_template="""
[Interface]
ListenPort = 51820
PrivateKey = {privatekey}
# Nico, 2019-01-23, Switzerland
#[Peer]
#PublicKey = kL1S/Ipq6NkFf1MAsNRou4b9VoUsnnb4ZxgiBrH0zA8=
#AllowedIPs = 2a0a:e5c1:101::/48
"""
class Command(BaseCommand):
help = 'General uncloud commands'
def add_arguments(self, parser):
parser.add_argument('--hostname', action='store_true', help='Name of this VPN Host',
required=True)
def handle(self, *args, **options):
# for net
if options['bootstrap']:
self.bootstrap()
self.create_vpn_config(options['hostname'])
def create_vpn_config(self, hostname):
for pool in VPNPool.objects.filter(vpn_hostname
default_cluster = VPNNetwork.objects.get_or_create(name="default")
# local_host =