uncloud-mravi/uncloud_django_based/uncloud/uncloud_net/models.py

53 lines
1.6 KiB
Python
Raw Normal View History

import uuid
from django.db import models
from django.contrib.auth import get_user_model
from django.core.validators import MinValueValidator, MaxValueValidator
from uncloud_pay.models import Product, RecurringPeriod
from uncloud.models import UncloudModel, UncloudStatus
2020-04-06 20:30:01 +00:00
class MACAdress(models.Model):
default_prefix = 0x420000000000
class VPNPool(UncloudModel):
"""
Network address pools from which VPNs can be created
"""
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
network = models.GenericIPAddressField(unique=True)
network_size = models.IntegerField(validators=[MinValueValidator(0),
MaxValueValidator(128)])
subnetwork_size = models.IntegerField(validators=[MinValueValidator(0),
MaxValueValidator(128)])
2020-04-06 20:30:01 +00:00
vpn_hostname = models.CharField(max_length=256)
wireguard_private_key = models.CharField(max_length=48)
class VPNNetworkReservation(UncloudModel):
"""
This class tracks the used VPN networks. It will be deleted, when the product is cancelled.
"""
vpnpool = models.ForeignKey(VPNPool,
on_delete=models.CASCADE)
address = models.GenericIPAddressField(primary_key=True)
class VPNNetwork(Product):
"""
A selected network. Used for tracking reservations / used networks
"""
network = models.ForeignKey(VPNNetworkReservation,
on_delete=models.CASCADE,
editable=False)
2020-04-06 20:30:01 +00:00
wireguard_public_key = models.CharField(max_length=48)