Attempt to fix the bug yet again
diff --git a/xos/services/vpn/admin.py b/xos/services/vpn/admin.py
index 522a504..4f792c4 100644
--- a/xos/services/vpn/admin.py
+++ b/xos/services/vpn/admin.py
@@ -100,10 +100,10 @@
self.instance.can_view_subnet = self.cleaned_data.get(
'can_view_subnet')
- if self.instance.script_name == None:
- self.instance.script_name = str(time.time()) + ".vpn"
+ if (not self.instance.script):
+ self.instance.script_name = "hello.vpn"
- if self.instance.server_key == None:
+ if (not self.instance.server_key):
self.instance.server_key = self.generate_VPN_key()
return super(VPNTenantForm, self).save(commit=commit)
diff --git a/xos/services/vpn/models.py b/xos/services/vpn/models.py
index c2d5d2b..cd7ca40 100644
--- a/xos/services/vpn/models.py
+++ b/xos/services/vpn/models.py
@@ -137,12 +137,13 @@
self.set_attribute("can_view_subnet", value)
@property
- def script_name(self):
- self.get_attribute("script_name", self.default_attributes['script_name'])
+ def script(self):
+ """string: The file name of the client script"""
+ self.get_attribute("script", self.default_attributes['script'])
- @script_name.setter
- def script_name(self, value):
- self.set_attribute("script_name", value)
+ @script.setter
+ def script(self, value):
+ self.set_attribute("script", value)
def model_policy_vpn_tenant(pk):
diff --git a/xos/synchronizers/vpn/steps/sync_vpntenant.py b/xos/synchronizers/vpn/steps/sync_vpntenant.py
index 177e8b4..3e9e343 100644
--- a/xos/synchronizers/vpn/steps/sync_vpntenant.py
+++ b/xos/synchronizers/vpn/steps/sync_vpntenant.py
@@ -22,8 +22,6 @@
if (not deleted):
objs = VPNTenant.get_tenant_objects().filter(
Q(enacted__lt=F('updated')) | Q(enacted=None), Q(lazy_blocked=False))
- for tenant in objs:
- self.create_client_script(tenant)
else:
objs = VPNTenant.get_deleted_tenant_objects()
@@ -37,7 +35,7 @@
"client_address": o.client_address}
def create_client_script(self, tenant):
- script = open("/opt/xos/core/static/vpn/" + str(tenant.script_name), 'w')
+ script = open("/opt/xos/core/static/vpn/" + str(tenant.script), 'w')
# write the key portion
script.write("printf \"")
for line in tenant.server_key.splitlines():
@@ -55,6 +53,10 @@
# close the script
script.close()
+ def run_playbook(self, o, fields):
+ self.create_client_script(o)
+ super(SyncVPNTenant, self).run_playbook(o, fields)
+
def generate_client_conf(self, tenant):
"""str: Generates the client configuration to use to connect to this VPN server.