++routing tests

This commit is contained in:
Nico Schottelius 2020-12-20 12:54:02 +01:00
parent 2e6c72c093
commit 1922a0d92d
2 changed files with 14 additions and 16 deletions

View file

@ -200,15 +200,15 @@ AUTH_LDAP_USER_SEARCH = LDAPSearch("dc=example,dc=com",
# where to create customers
LDAP_CUSTOMER_DN="ou=customer,dc=example,dc=com"
def route_task(name, args, kwargs, options, task=None, **kw):
print(f"{name} - {args} - {kwargs}")
# if name == 'myapp.tasks.compress_video':
return {'queue': 'vpn1' }
# 'exchange_type': 'topic',
# 'routing_key': 'video.compress'}
# def route_task(name, args, kwargs, options, task=None, **kw):
# print(f"{name} - {args} - {kwargs}")
# # if name == 'myapp.tasks.compress_video':
# return {'queue': 'vpn1' }
# # 'exchange_type': 'topic',
# # 'routing_key': 'video.compress'}
CELERY_TASK_ROUTES = (route_task,)
# CELERY_TASK_ROUTES = (route_task,)
# CELERY_TASK_ROUTES = {
# '*': {
@ -220,7 +220,9 @@ CELERY_TASK_ROUTES = (route_task,)
CELERY_BROKER_URL = 'redis://:uncloud.example.com:6379/0'
CELERY_RESULT_BACKEND = 'redis://:uncloud.example.com:6379/0'
CELERY_TASK_ROUTES = ( [ (re.compile(r'.*\.cdist\..*'), { 'queue': 'cdist' }), ], )
CELERY_TASK_ROUTES = {
re.compile(r'cdist.*'): { 'queue': 'cdist' }
}
# CELERY_TASK_CREATE_MISSING_QUEUES = False

View file

@ -19,14 +19,9 @@ def configure_wireguard_server(wireguardvpnpool):
config = wireguardvpnpool.wireguard_config
server = wireguardvpnpool.vpn_server_hostname
print(f"Configuring VPN server {server}")
#res = cdist_configure_wireguard_server.delay(config, server)
res = cdist_configure_wireguard_server.apply_async((config, server), queue='cdist')
print(f"res={res}")
res2= res.get()
print(f"res2={res2}")
print(f"Configuring VPN server {server} (async)")
# cdist_configure_wireguard_server.apply_async((config, server), queue='cdist')
cdist_configure_wireguard_server.apply_async((config, server))
@shared_task
def cdist_configure_wireguard_server(config, server):
@ -39,6 +34,7 @@ def cdist_configure_wireguard_server(config, server):
fname = f"/home/app/.cdist/type/__ungleich_wireguard/files/{server}"
print(os.uname())
print(f"Configuring VPN server {server} (on cdist host)")
with open(fname, "w") as fd:
fd.write(config)