From 22c28a21e4362726deb3324cd33c6ec041020978 Mon Sep 17 00:00:00 2001 From: chigang Date: Fri, 1 Jul 2016 01:45:38 +0000 Subject: [PATCH] Revert "Separate tasks for users by sending them to different queues." This reverts commit 70425d96c2df4352322c3b6bfabdf8686e3d4391. Change-Id: Ic280153a0c9e05d531a34ac6ac09178ec9dd71c3 --- compass/db/api/cluster.py | 41 +++++++-------------------- compass/db/api/health_check_report.py | 5 +--- compass/db/api/host.py | 25 ++++------------ 3 files changed, 16 insertions(+), 55 deletions(-) diff --git a/compass/db/api/cluster.py b/compass/db/api/cluster.py index c3e4e044..9fc00402 100644 --- a/compass/db/api/cluster.py +++ b/compass/db/api/cluster.py @@ -480,10 +480,7 @@ def del_cluster( for clusterhost in cluster.clusterhosts ], delete_underlying_host - ), - queue=user.email, - exchange=user.email, - routing_key=user.email + ) ) return { 'status': 'delete action is sent', @@ -1186,10 +1183,7 @@ def _del_cluster_host( ( user.email, clusterhost.cluster_id, clusterhost.host_id, delete_underlying_host - ), - queue=user.email, - exchange=user.email, - routing_key=user.email + ) ) return { 'status': 'delete action sent', @@ -1860,10 +1854,7 @@ def deploy_cluster( ( user.email, cluster_id, [clusterhost.host_id for clusterhost in clusterhosts] - ), - queue=user.email, - exchange=user.email, - routing_key=user.email + ) ) return { 'status': 'deploy action sent', @@ -1927,10 +1918,7 @@ def redeploy_cluster( 'compass.tasks.redeploy_cluster', ( user.email, cluster_id - ), - queue=user.email, - exchange=user.email, - routing_key=user.email + ) ) return { 'status': 'redeploy action sent', @@ -1957,10 +1945,7 @@ def patch_cluster(cluster_id, user=None, session=None, **kwargs): 'compass.tasks.patch_cluster', ( user.email, cluster_id, - ), - queue=user.email, - exchange=user.email, - routing_key=user.email + ) ) return { 'status': 'patch action sent', @@ -2061,7 +2046,7 @@ def update_cluster_host_state( def _update_clusterhost_state( clusterhost, from_database_only=False, - session=None, user=None, **kwargs + session=None, **kwargs ): """Update clusterhost state. @@ -2108,10 +2093,7 @@ def _update_clusterhost_state( ( clusterhost.cluster_id, clusterhost.host_id, cluster_ready, host_ready - ), - queue=user.email, - exchange=user.email, - routing_key=user.email + ) ) status = '%s: cluster ready %s host ready %s' % ( clusterhost.name, cluster_ready, host_ready @@ -2144,7 +2126,7 @@ def update_cluster_host_state_internal( ) return _update_clusterhost_state( clusterhost, from_database_only=from_database_only, - session=session, users=user, **kwargs + session=session, **kwargs ) @@ -2187,7 +2169,7 @@ def update_clusterhost_state_internal( clusterhost = _get_clusterhost(clusterhost_id, session=session) return _update_clusterhost_state( clusterhost, from_database_only=from_database_only, - session=session, user=user, **kwargs + session=session, **kwargs ) @@ -2261,10 +2243,7 @@ def update_cluster_state_internal( from compass.tasks import client as celery_client celery_client.celery.send_task( 'compass.tasks.cluster_installed', - (clusterhost.cluster_id, clusterhost_ready), - queue=user.email, - exchange=user.email, - routing_key=user.email + (clusterhost.cluster_id, clusterhost_ready) ) status = '%s installed action set clusterhost ready %s' % ( cluster.name, clusterhost_ready diff --git a/compass/db/api/health_check_report.py b/compass/db/api/health_check_report.py index aaea7a7c..562008c9 100644 --- a/compass/db/api/health_check_report.py +++ b/compass/db/api/health_check_report.py @@ -179,10 +179,7 @@ def start_check_cluster_health(cluster_id, send_report_url, from compass.tasks import client as celery_client celery_client.celery.send_task( 'compass.tasks.cluster_health', - (cluster.id, send_report_url, user.email), - queue=user.email, - exchange=user.email, - routing_key=user.email + (cluster.id, send_report_url, user.email) ) return { "cluster_id": cluster.id, diff --git a/compass/db/api/host.py b/compass/db/api/host.py index 5b079037..c82f3f8c 100644 --- a/compass/db/api/host.py +++ b/compass/db/api/host.py @@ -419,10 +419,7 @@ def del_host( 'compass.tasks.delete_host', ( user.email, host.id, cluster_ids - ), - queue=user.email, - exchange=user.email, - routing_key=user.email + ) ) return { 'status': 'delete action sent', @@ -921,10 +918,7 @@ def update_host_state_internal( ( host.id, clusterhosts_ready, clusters_os_ready - ), - queue=user.email, - exchange=user.email, - routing_key=user.email + ) ) status = '%s: clusterhosts ready %s clusters os ready %s' % ( host.name, clusterhosts_ready, clusters_os_ready @@ -1019,10 +1013,7 @@ def poweron_host( check_host_validated(host) celery_client.celery.send_task( 'compass.tasks.poweron_host', - (host.id,), - queue=user.email, - exchange=user.email, - routing_key=user.email + (host.id,) ) return { 'status': 'poweron %s action sent' % host.name, @@ -1048,10 +1039,7 @@ def poweroff_host( check_host_validated(host) celery_client.celery.send_task( 'compass.tasks.poweroff_host', - (host.id,), - queue=user.email, - exchange=user.email, - routing_key=user.email + (host.id,) ) return { 'status': 'poweroff %s action sent' % host.name, @@ -1077,10 +1065,7 @@ def reset_host( check_host_validated(host) celery_client.celery.send_task( 'compass.tasks.reset_host', - (host.id,), - queue=user.email, - exchange=user.email, - routing_key=user.email + (host.id,) ) return { 'status': 'reset %s action sent' % host.name,