[vpn] implement creating vpns

This commit is contained in:
Nico Schottelius 2020-12-13 17:59:35 +01:00
commit cd19c47fdb
6 changed files with 130 additions and 55 deletions

View file

@ -4,7 +4,10 @@ from django.db.models import Count, F
from .models import *
def get_suitable_pool(subnetwork_mask):
# def get_num_used_networks(pool):
# return pool.wireguardvpn_set.count()
def get_suitable_pools(subnetwork_mask):
"""
Find suitable pools for a certain network size.
@ -42,3 +45,16 @@ def allowed_vpn_network_reservation_size():
# Need to return set of tuples, see
# https://docs.djangoproject.com/en/3.1/ref/models/fields/#field-choices
return set([ (pool.subnetwork_mask, pool.subnetwork_mask) for pool in pools ])
#def get_next_vpnnetwork(pool):
# get all associated networks
# look for the lowest free number
# return that
# select last used one
# try to increment by one -> get new network
# if that fails search through the existing vpns for the first unused number
#