diff --git a/compass/db/api/machine.py b/compass/db/api/machine.py index 9a8d3eac..5e724f5a 100644 --- a/compass/db/api/machine.py +++ b/compass/db/api/machine.py @@ -228,7 +228,10 @@ def poweron_machine( ) celery_client.celery.send_task( 'compass.tasks.poweron_machine', - (machine_id,) + (machine_id,), + queue=user.email, + exchange=user.email, + routing_key=user.email ) return { 'status': 'poweron %s action sent' % machine.mac, @@ -255,7 +258,10 @@ def poweroff_machine( ) celery_client.celery.send_task( 'compass.tasks.poweroff_machine', - (machine_id,) + (machine_id,), + queue=user.email, + exchange=user.email, + routing_key=user.email ) return { 'status': 'poweroff %s action sent' % machine.mac, @@ -282,7 +288,10 @@ def reset_machine( ) celery_client.celery.send_task( 'compass.tasks.reset_machine', - (machine_id,) + (machine_id,), + queue=user.email, + exchange=user.email, + routing_key=user.email ) return { 'status': 'reset %s action sent' % machine.mac, diff --git a/compass/db/api/switch.py b/compass/db/api/switch.py index 4c7c8e59..f3e27ebc 100644 --- a/compass/db/api/switch.py +++ b/compass/db/api/switch.py @@ -838,7 +838,10 @@ def poll_switch(switch_id, user=None, session=None, **kwargs): switch = _get_switch(switch_id, session=session) celery_client.celery.send_task( 'compass.tasks.pollswitch', - (user.email, switch.ip, switch.credentials) + (user.email, switch.ip, switch.credentials), + queue=user.email, + exchange=user.email, + routing_key=user.email ) return { 'status': 'action %s sent' % kwargs, diff --git a/conf/celeryconfig b/conf/celeryconfig index f4911279..f23858ba 100644 --- a/conf/celeryconfig +++ b/conf/celeryconfig @@ -7,3 +7,6 @@ BROKER_URL = "amqp://guest:guest@localhost:5672//" CELERY_IMPORTS=("compass.tasks.tasks",) CELERY_ACCEPT_CONTENT = ['pickle', 'json', 'msgpack', 'yaml'] C_FORCE_ROOT = 1 +CELERY_DEFAULT_QUEUE = 'admin@huawei.com' +CELERY_DEFAULT_EXCHANGE = 'admin@huawei.com' +CELERY_DEFAULT_ROUTING_KEY = 'admin@huawei.com'