Merge "Add cdm-scoping"
This commit is contained in:
@@ -123,11 +123,18 @@ class BaseClusterDataModelCollector(loadable.LoadableSingleton):
|
||||
|
||||
STALE_MODEL = model_root.ModelRoot(stale=True)
|
||||
|
||||
def __init__(self, config, osc=None):
|
||||
def __init__(self, config, osc=None, audit_scope=None):
|
||||
super(BaseClusterDataModelCollector, self).__init__(config)
|
||||
self.osc = osc if osc else clients.OpenStackClients()
|
||||
self._cluster_data_model = None
|
||||
self.lock = threading.RLock()
|
||||
self._audit_scope = audit_scope
|
||||
self._audit_scope_handler = None
|
||||
|
||||
@abc.abstractproperty
|
||||
def audit_scope_handler(self):
|
||||
"""Get audit scope handler"""
|
||||
raise NotImplementedError()
|
||||
|
||||
@property
|
||||
def cluster_data_model(self):
|
||||
|
||||
@@ -37,6 +37,10 @@ class CinderClusterDataModelCollector(base.BaseClusterDataModelCollector):
|
||||
def __init__(self, config, osc=None):
|
||||
super(CinderClusterDataModelCollector, self).__init__(config, osc)
|
||||
|
||||
@property
|
||||
def audit_scope_handler(self):
|
||||
return None
|
||||
|
||||
@property
|
||||
def notification_endpoints(self):
|
||||
"""Associated notification endpoints
|
||||
|
||||
@@ -50,14 +50,17 @@ class CollectorManager(object):
|
||||
|
||||
return self._notification_endpoints
|
||||
|
||||
def get_cluster_model_collector(self, name, osc=None):
|
||||
def get_cluster_model_collector(self, name, osc=None, audit_scope=None):
|
||||
"""Retrieve cluster data model collector
|
||||
|
||||
:param name: name of the cluster data model collector plugin
|
||||
:type name: str
|
||||
:param osc: an OpenStackClients instance
|
||||
:type osc: :py:class:`~.OpenStackClients` instance
|
||||
:param audit_scope: an BaseScope instance
|
||||
:type audit_scope: :py:class:`~.BaseScope` instance
|
||||
:returns: cluster data model collector plugin
|
||||
:rtype: :py:class:`~.BaseClusterDataModelCollector`
|
||||
"""
|
||||
return self.collector_loader.load(name, osc=osc)
|
||||
return self.collector_loader.load(
|
||||
name, osc=osc, audit_scope=audit_scope)
|
||||
|
||||
@@ -21,6 +21,7 @@ from watcher.decision_engine.model.collector import base
|
||||
from watcher.decision_engine.model import element
|
||||
from watcher.decision_engine.model import model_root
|
||||
from watcher.decision_engine.model.notification import nova
|
||||
from watcher.decision_engine.scope import compute as compute_scope
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
@@ -32,9 +33,119 @@ class NovaClusterDataModelCollector(base.BaseClusterDataModelCollector):
|
||||
representation of the resources exposed by the compute service.
|
||||
"""
|
||||
|
||||
HOST_AGGREGATES = "#/items/properties/compute/host_aggregates/"
|
||||
SCHEMA = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"host_aggregates": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"anyOf": [
|
||||
{"$ref": HOST_AGGREGATES + "id"},
|
||||
{"$ref": HOST_AGGREGATES + "name"},
|
||||
]
|
||||
}
|
||||
},
|
||||
"availability_zones": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": False
|
||||
}
|
||||
},
|
||||
"exclude": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"instances": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"uuid": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": False
|
||||
}
|
||||
},
|
||||
"compute_nodes": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": False
|
||||
}
|
||||
},
|
||||
"host_aggregates": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"anyOf": [
|
||||
{"$ref": HOST_AGGREGATES + "id"},
|
||||
{"$ref": HOST_AGGREGATES + "name"},
|
||||
]
|
||||
}
|
||||
},
|
||||
"instance_metadata": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"additionalProperties": False
|
||||
}
|
||||
}
|
||||
},
|
||||
"additionalProperties": False
|
||||
},
|
||||
"host_aggregates": {
|
||||
"id": {
|
||||
"properties": {
|
||||
"id": {
|
||||
"oneOf": [
|
||||
{"type": "integer"},
|
||||
{"enum": ["*"]}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": False
|
||||
},
|
||||
"name": {
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": False
|
||||
}
|
||||
},
|
||||
"additionalProperties": False
|
||||
}
|
||||
|
||||
def __init__(self, config, osc=None):
|
||||
super(NovaClusterDataModelCollector, self).__init__(config, osc)
|
||||
|
||||
@property
|
||||
def audit_scope_handler(self):
|
||||
if not self._audit_scope_handler:
|
||||
self._audit_scope_handler = compute_scope.ComputeScope(
|
||||
self._audit_scope, self.config)
|
||||
return self._audit_scope_handler
|
||||
|
||||
@property
|
||||
def notification_endpoints(self):
|
||||
"""Associated notification endpoints
|
||||
|
||||
Reference in New Issue
Block a user