From bbe9a3f651462e549caffca8b7b53bcd30411fa8 Mon Sep 17 00:00:00 2001 From: Saurabh Surana Date: Tue, 8 Dec 2015 15:55:59 -0800 Subject: [PATCH] monitor now uses objects layer to access db records since we moved policy checks into the API layer, we can now use objects layer to access db records from cue monitor. When objects layer was doing policy checks we couldn't use object layer without a valid conext object, and since cue monitor doesn't have a conext object earlier we couldn't use objects layer in cue monitor. Closes-Bug: 1517174 Change-Id: I1a66b1fd5e66a807498d69ceb0ac9748f6547e2b --- cue/monitor/monitor_service.py | 7 +++---- cue/objects/cluster.py | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cue/monitor/monitor_service.py b/cue/monitor/monitor_service.py index acef5e03..5405cfa6 100644 --- a/cue/monitor/monitor_service.py +++ b/cue/monitor/monitor_service.py @@ -18,7 +18,7 @@ from oslo_service import loopingcall from oslo_service import service from tooz import coordination -from cue.db import api as db_api +from cue import objects import cue.taskflow.client as taskflow_client from cue.taskflow.flow import check_cluster_status @@ -103,15 +103,14 @@ class MonitorService(service.Service): # and [1] is a list of that clusters node ids def get_cluster_id_node_ids(): - dbapi = db_api.get_instance() - clusters = dbapi.get_clusters(None, project_only=False) + clusters = objects.Cluster.get_clusters(None, project_only=False) cluster_ids = [] for cluster in clusters: if cluster.status not in ['ACTIVE', 'DOWN']: continue node_ids = [] - for node in dbapi.get_nodes_in_cluster(None, cluster.id): + for node in objects.Node.get_nodes_by_cluster_id(None, cluster.id): node_ids.append(node.id) cluster_ids.append((cluster.id, node_ids)) diff --git a/cue/objects/cluster.py b/cue/objects/cluster.py index 1daeef6d..939cb533 100644 --- a/cue/objects/cluster.py +++ b/cue/objects/cluster.py @@ -73,14 +73,14 @@ class Cluster(base.CueObject): cluster_id, *args, **kwargs) @classmethod - def get_clusters(cls, context): + def get_clusters(cls, context, *args, **kwargs): """Returns a list of Cluster objects for project_id. :param context: The request context. :returns: a list of :class:'Cluster' object. """ - db_clusters = cls.dbapi.get_clusters(context) + db_clusters = cls.dbapi.get_clusters(context, *args, **kwargs) return [Cluster._from_db_object(Cluster(), obj) for obj in db_clusters] @classmethod