From 74749bf07cdf6afed02fc45d0f6616d6ba939add Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 26 Dec 2020 14:45:28 +0100 Subject: [PATCH] fix templating --- uncloud_net/tasks.py | 11 +++-------- uncloud_net/views.py | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/uncloud_net/tasks.py b/uncloud_net/tasks.py index f6b8038..67cfa18 100644 --- a/uncloud_net/tasks.py +++ b/uncloud_net/tasks.py @@ -11,11 +11,6 @@ import uuid log = logging.getLogger(__name__) -@shared_task -def whereami(): - print(os.uname()) - return os.uname() - @shared_task def configure_wireguard_server_on_host(wg_name, config): """ @@ -25,16 +20,16 @@ def configure_wireguard_server_on_host(wg_name, config): """ # Write config - fname = f"/etc/wireguard/{{wg_name}}.conf" + fname = f"/etc/wireguard/{wg_name}.conf" with open(fname, "w") as fd: fd.write(config) # Ensure the device exists - subprocess.run(f"ip link show {{wg_name}} || sudo ip link add {{wg_name}} type wireguard", + subprocess.run(f"ip link show {wg_name} || sudo ip link add {{wg_name}} type wireguard", shell=True, check=True) # Ensure the config is correct - subprocess.run(f"sudo wg setconf {{wg_name}} {{fname}}", + subprocess.run(f"sudo wg setconf {wg_name} {fname}", shell=True, check=True) diff --git a/uncloud_net/views.py b/uncloud_net/views.py index 77ba952..7dadbf4 100644 --- a/uncloud_net/views.py +++ b/uncloud_net/views.py @@ -35,7 +35,7 @@ class WireGuardVPNViewSet(viewsets.ModelViewSet): public_key=serializer.validated_data['wireguard_public_key'], network_mask=serializer.validated_data['network_mask'] ) - configure_wireguard_server(vpn.vpnpool) + return Response(WireGuardVPNSerializer(vpn).data)