Merge "Update getting scoped storage CDM"
This commit is contained in:
commit
640e4e1fea
|
@ -23,6 +23,7 @@ from watcher.decision_engine.model.collector import base
|
||||||
from watcher.decision_engine.model import element
|
from watcher.decision_engine.model import element
|
||||||
from watcher.decision_engine.model import model_root
|
from watcher.decision_engine.model import model_root
|
||||||
from watcher.decision_engine.model.notification import cinder
|
from watcher.decision_engine.model.notification import cinder
|
||||||
|
from watcher.decision_engine.scope import storage as storage_scope
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -55,7 +56,9 @@ class CinderClusterDataModelCollector(base.BaseClusterDataModelCollector):
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_audit_scope_handler(self, audit_scope):
|
def get_audit_scope_handler(self, audit_scope):
|
||||||
return None
|
self._audit_scope_handler = storage_scope.StorageScope(
|
||||||
|
audit_scope, self.config)
|
||||||
|
return self._audit_scope_handler
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
"""Build the storage cluster data model"""
|
"""Build the storage cluster data model"""
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
# implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
from oslo_log import log
|
||||||
|
|
||||||
|
from watcher.decision_engine.scope import base
|
||||||
|
|
||||||
|
|
||||||
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class StorageScope(base.BaseScope):
|
||||||
|
"""Storage Audit Scope Handler"""
|
||||||
|
|
||||||
|
def __init__(self, scope, config, osc=None):
|
||||||
|
super(StorageScope, self).__init__(scope, config)
|
||||||
|
self._osc = osc
|
||||||
|
|
||||||
|
def get_scoped_model(self, cluster_model):
|
||||||
|
"""Leave only nodes and instances proposed in the audit scope"""
|
||||||
|
if not cluster_model:
|
||||||
|
return None
|
||||||
|
|
||||||
|
for scope in self.scope:
|
||||||
|
storage_scope = scope.get('storage')
|
||||||
|
|
||||||
|
if not storage_scope:
|
||||||
|
return cluster_model
|
||||||
|
|
||||||
|
# TODO(hidekazu): currently self.scope is always []
|
||||||
|
# Audit scoper for storage data model will be implemented:
|
||||||
|
# https://blueprints.launchpad.net/watcher/+spec/audit-scoper-for-storage-data-model
|
||||||
|
return cluster_model
|
|
@ -203,7 +203,8 @@ class BaseStrategy(loadable.Loadable):
|
||||||
if self._storage_model is None:
|
if self._storage_model is None:
|
||||||
collector = self.collector_manager.get_cluster_model_collector(
|
collector = self.collector_manager.get_cluster_model_collector(
|
||||||
'storage', osc=self.osc)
|
'storage', osc=self.osc)
|
||||||
self._storage_model = self.audit_scope_handler.get_scoped_model(
|
audit_scope_handler = collector.audit_scope_handler
|
||||||
|
self._storage_model = audit_scope_handler.get_scoped_model(
|
||||||
collector.get_latest_cluster_data_model())
|
collector.get_latest_cluster_data_model())
|
||||||
|
|
||||||
if not self._storage_model:
|
if not self._storage_model:
|
||||||
|
|
Loading…
Reference in New Issue