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
This commit is contained in:
parent
880a103778
commit
bbe9a3f651
|
@ -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))
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue