diff --git a/requirements.txt b/requirements.txt index 2394073..d5e6a78 100644 --- a/requirements.txt +++ b/requirements.txt @@ -26,3 +26,4 @@ vat-validator # Tasks celery +redis diff --git a/uncloud/settings.py b/uncloud/settings.py index 2e1db55..cd60354 100644 --- a/uncloud/settings.py +++ b/uncloud/settings.py @@ -199,6 +199,16 @@ AUTH_LDAP_USER_SEARCH = LDAPSearch("dc=example,dc=com", # where to create customers LDAP_CUSTOMER_DN="ou=customer,dc=example,dc=com" +CELERY_TASK_ROUTES = { + '*': { + 'queue': 'vpn1' + } +} + +CELERY_BROKER_URL = 'redis://bridge.place7.ungleich.ch:6379/0' +CELERY_RESULT_BACKEND = 'redis://bridge.place7.ungleich.ch:6379/0' + +# CELERY_TASK_CREATE_MISSING_QUEUES = False # Overwrite settings with local settings, if existing try: diff --git a/uncloud_net/tasks.py b/uncloud_net/tasks.py index ca2a05d..60c1e7d 100644 --- a/uncloud_net/tasks.py +++ b/uncloud_net/tasks.py @@ -1,6 +1,13 @@ from celery import shared_task from .models import * +import os + +@shared_task +def whereami(): + print(os.uname()) + return os.uname() + @shared_task def configure_wireguard_server(vpnpool): print(f"Configuring {vpnpool.vpn_server_hostname}") @@ -36,31 +43,3 @@ AllowedIPs = {peer_network} wireguard_config.extend(peers) return "\n".join(wireguard_config) - - - def configure_wireguard_vpnserver(self): - """ - This method is designed to run as a celery task and should - not be called directly from the web - """ - - # subprocess, ssh - - pass - - - - def num_maximum_networks(self): - """ - sample: - network_size = 40 - subnetwork_size = 48 - maximum_networks = 2^(48-40) - - 2nd sample: - network_size = 8 - subnetwork_size = 24 - maximum_networks = 2^(24-8) - """ - - return 2**(self.subnetwork_mask - self.network_mask)