Add port selection to VPNTenant
diff --git a/xos/services/vpn/admin.py b/xos/services/vpn/admin.py
index 608f97e..8691a24 100644
--- a/xos/services/vpn/admin.py
+++ b/xos/services/vpn/admin.py
@@ -50,8 +50,8 @@
server_address (forms.GenericIPAddressField): The ip address on the VPN of this Tenant.
client_address (forms.GenericIPAddressField): The ip address on the VPN of the client.
is_persistent (forms.BooleanField): Determines if this Tenant keeps this connection alive through failures.
- can_view_subnet (forms.BooleanField): Determins if this Tenant makes it's subnet available to the client.
-
+ can_view_subnet (forms.BooleanField): Determines if this Tenant makes it's subnet available to the client.
+ port_number (forms.PositiveSmallIntegerField): The port to use for this Tenant.
"""
creator = forms.ModelChoiceField(queryset=User.objects.all())
server_network = forms.GenericIPAddressField(
@@ -59,6 +59,7 @@
vpn_subnet = forms.GenericIPAddressField(protocol="IPv4", required=True)
is_persistent = forms.BooleanField(required=False)
clients_can_see_each_other = forms.BooleanField(required=False)
+ port_number = forms.PositiveSmallIntegerField(required=True)
def __init__(self, *args, **kwargs):
super(VPNTenantForm, self).__init__(*args, **kwargs)
@@ -77,6 +78,7 @@
self.fields[
'clients_can_see_each_other'].initial = self.instance.clients_can_see_each_other
self.fields['is_persistent'].initial = self.instance.is_persistent
+ self.fields['port_number'].initial = self.instance.port_number
if (not self.instance) or (not self.instance.pk):
self.fields['creator'].initial = get_request().user
@@ -95,6 +97,7 @@
self.instance.server_network = self.cleaned_data.get('server_network')
self.instance.clients_can_see_each_other = self.cleaned_data.get(
'clients_can_see_each_other')
+ self.instance.port_number = self.cleaned_data.get('port_number')
if (not self.instance.script):
self.instance.script = str(time.time()) + ".vpn"
diff --git a/xos/services/vpn/models.py b/xos/services/vpn/models.py
index 65e04e7..33a4b3a 100644
--- a/xos/services/vpn/models.py
+++ b/xos/services/vpn/models.py
@@ -31,7 +31,8 @@
'clients_can_see_each_other': True,
'is_persistent': True,
'script': None,
- 'ca_crt': None}
+ 'ca_crt': None,
+ 'port': None}
def __init__(self, *args, **kwargs):
vpn_services = VPNService.get_service_objects().all()
@@ -137,6 +138,16 @@
def ca_crt(self, value):
self.set_attribute("ca_crt", value)
+ @property
+ def port_number(self):
+ """int: the integer representing the port number for this server"""
+ return self.get_attribute("port", self.default_attributes['port'])
+
+ @port_number.setter
+ def port_number(self, value):
+ self.set_attribute("port", value)
+
+
def model_policy_vpn_tenant(pk):
"""Manages the contain for the VPN Tenant."""