Handle ports a little better
diff --git a/xos/services/vpn/admin.py b/xos/services/vpn/admin.py
index 5ee792d..d2de5d1 100644
--- a/xos/services/vpn/admin.py
+++ b/xos/services/vpn/admin.py
@@ -186,10 +186,13 @@
for tenant in self.cleaned_data['failover_servers']:
self.instance.failover_servers.append(tenant)
- self.instance.protocol = self.cleaned_data.get("protocol")
- self.instance.port_number = (
- self.instance.provider_service.get_next_available_port(
- self.instance.protocol))
+ # Do not aquire a new port number if the protocol hasn't changed
+ if ((not self.instance.protocol) or
+ (self.instance.protocol != self.cleaned_data.get("protocol"))):
+ self.instance.protocol = self.cleaned_data.get("protocol")
+ self.instance.port_number = (
+ self.instance.provider_service.get_next_available_port(
+ self.instance.protocol))
self.instance.use_ca_from[:] = []
self.instance.use_ca_from.append(self.cleaned_data.get('use_ca_from'))