Browse Source

Check if scope is None

if scope is None, don't create data model

Change-Id: Icf611966c9b0a3882615d778ee6c72a8da73841d
Closed-Bug: #1881920
(cherry picked from commit 9f0138e1cf)
changes/72/736872/1
licanwei 1 month ago
parent
commit
cbb06e6765
4 changed files with 45 additions and 0 deletions
  1. +3
    -0
      watcher/decision_engine/model/collector/cinder.py
  2. +3
    -0
      watcher/decision_engine/model/collector/ironic.py
  3. +3
    -0
      watcher/decision_engine/model/collector/nova.py
  4. +36
    -0
      watcher/tests/decision_engine/cluster/test_cluster_data_model_collector.py

+ 3
- 0
watcher/decision_engine/model/collector/cinder.py View File

@@ -152,6 +152,9 @@ class CinderClusterDataModelCollector(base.BaseClusterDataModelCollector):
if self._audit_scope_handler is None:
LOG.debug("No audit, Don't Build storage data model")
return
if self._data_model_scope is None:
LOG.debug("No audit scope, Don't Build storage data model")
return

builder = CinderModelBuilder(self.osc)
return builder.execute(self._data_model_scope)


+ 3
- 0
watcher/decision_engine/model/collector/ironic.py View File

@@ -63,6 +63,9 @@ class BaremetalClusterDataModelCollector(base.BaseClusterDataModelCollector):
if self._audit_scope_handler is None:
LOG.debug("No audit, Don't Build Baremetal data model")
return
if self._data_model_scope is None:
LOG.debug("No audit scope, Don't Build Baremetal data model")
return

builder = BareMetalModelBuilder(self.osc)
return builder.execute(self._data_model_scope)


+ 3
- 0
watcher/decision_engine/model/collector/nova.py View File

@@ -184,6 +184,9 @@ class NovaClusterDataModelCollector(base.BaseClusterDataModelCollector):
if self._audit_scope_handler is None:
LOG.debug("No audit, Don't Build compute data model")
return
if self._data_model_scope is None:
LOG.debug("No audit scope, Don't Build compute data model")
return

builder = NovaModelBuilder(self.osc)
return builder.execute(self._data_model_scope)


+ 36
- 0
watcher/tests/decision_engine/cluster/test_cluster_data_model_collector.py View File

@@ -17,6 +17,9 @@
import mock

from watcher.decision_engine.model.collector import base
from watcher.decision_engine.model.collector import cinder
from watcher.decision_engine.model.collector import ironic
from watcher.decision_engine.model.collector import nova
from watcher.decision_engine.model import model_root
from watcher.tests import base as test_base

@@ -55,3 +58,36 @@ class TestClusterDataModelCollector(test_base.TestCase):
self.assertIsNot(
collector.cluster_data_model,
collector.get_latest_cluster_data_model())


class TestComputeDataModelCollector(test_base.TestCase):

def test_model_scope_is_none(self):
m_config = mock.Mock()
collector = nova.NovaClusterDataModelCollector(config=m_config)

collector._audit_scope_handler = mock.Mock()
collector._data_model_scope = None
self.assertIsNone(collector.execute())


class TestStorageDataModelCollector(test_base.TestCase):

def test_model_scope_is_none(self):
m_config = mock.Mock()
collector = cinder.CinderClusterDataModelCollector(config=m_config)

collector._audit_scope_handler = mock.Mock()
collector._data_model_scope = None
self.assertIsNone(collector.execute())


class TestBareMetalDataModelCollector(test_base.TestCase):

def test_model_scope_is_none(self):
m_config = mock.Mock()
collector = ironic.BaremetalClusterDataModelCollector(config=m_config)

collector._audit_scope_handler = mock.Mock()
collector._data_model_scope = None
self.assertIsNone(collector.execute())

Loading…
Cancel
Save