From 0bf28bec6097d128aa439b288b249fafcac7dbc0 Mon Sep 17 00:00:00 2001 From: Michael H Wilson Date: Tue, 16 Oct 2012 15:47:52 -0600 Subject: Fix hardcoded topic strings with constants. Replace hardcoded topic strings like 'volume' or 'compute' with config constants like FLAGS.volume_topic, etc. See bug #1057831 and bug #1061628. Change-Id: I817ecc3cbe3245b51a0c047be58d17edfec8a838 --- nova/db/sqlalchemy/api.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'nova/db') diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 0946d0b19..2e390a2ff 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -331,7 +331,8 @@ def service_destroy(context, service_id): service_ref = service_get(context, service_id, session=session) service_ref.delete(session=session) - if service_ref.topic == 'compute' and service_ref.compute_node: + if (service_ref.topic == FLAGS.compute_topic and + service_ref.compute_node): for c in service_ref.compute_node: c.delete(session=session) @@ -387,7 +388,7 @@ def service_get_all_compute_by_host(context, host): result = model_query(context, models.Service, read_deleted="no").\ options(joinedload('compute_node')).\ filter_by(host=host).\ - filter_by(topic="compute").\ + filter_by(topic=FLAGS.compute_topic).\ all() if not result: @@ -420,7 +421,7 @@ def service_get_all_compute_sorted(context): # (SELECT host, SUM(instances.vcpus) AS instance_cores # FROM instances GROUP BY host) AS inst_cores # ON services.host = inst_cores.host - topic = 'compute' + topic = FLAGS.compute_topic label = 'instance_cores' subq = model_query(context, models.Instance.host, func.sum(models.Instance.vcpus).label(label), @@ -438,7 +439,7 @@ def service_get_all_compute_sorted(context): def service_get_all_volume_sorted(context): session = get_session() with session.begin(): - topic = 'volume' + topic = FLAGS.volume_topic label = 'volume_gigabytes' subq = model_query(context, models.Volume.host, func.sum(models.Volume.size).label(label), -- cgit