From aa300c9fcfee85f11cedf0957f0406676b995fbc Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Thu, 7 May 2020 14:16:22 +0000 Subject: [PATCH] VIO to use Openstack collector (gnocchi) if no vrops_site is provided Change-Id: I9118e63d9405ce7339dbd077aec7e93aa0e18f20 Signed-off-by: garciadeblas --- osm_mon/collector/service.py | 2 ++ .../tests/unit/collector/test_collector_service.py | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/osm_mon/collector/service.py b/osm_mon/collector/service.py index f329918..c04f548 100644 --- a/osm_mon/collector/service.py +++ b/osm_mon/collector/service.py @@ -139,4 +139,6 @@ class CollectorService: vim_type = vim_account['vim_type'] if 'config' in vim_account and 'vim_type' in vim_account['config']: vim_type = vim_account['config']['vim_type'].lower() + if vim_type == 'vio' and 'vrops_site' not in vim_account['config']: + vim_type = 'openstack' return vim_type diff --git a/osm_mon/tests/unit/collector/test_collector_service.py b/osm_mon/tests/unit/collector/test_collector_service.py index 61a288a..9b5f002 100644 --- a/osm_mon/tests/unit/collector/test_collector_service.py +++ b/osm_mon/tests/unit/collector/test_collector_service.py @@ -52,11 +52,21 @@ class CollectorServiceTest(TestCase): collector._collect_vim_metrics({}, 'test_vim_account_id') openstack_collect.assert_not_called() + @mock.patch.object(OpenstackCollector, "__init__", lambda *args, **kwargs: None) + @mock.patch.object(OpenstackCollector, "collect") + @mock.patch.object(CommonDbClient, "get_vim_account") + def test_init_vim_collector_and_collect_vio_with_openstack_collector(self, _get_vim_account, openstack_collect): + _get_vim_account.return_value = {'vim_type': 'openstack', 'config': {'vim_type': 'VIO'}} + collector = CollectorService(self.config) + collector._collect_vim_metrics({}, 'test_vim_account_id') + openstack_collect.assert_called_once_with({}) + @mock.patch.object(VIOCollector, "__init__", lambda *args, **kwargs: None) @mock.patch.object(VIOCollector, "collect") @mock.patch.object(CommonDbClient, "get_vim_account") - def test_init_vim_collector_and_collect_vio(self, _get_vim_account, vio_collect): - _get_vim_account.return_value = {'vim_type': 'openstack', 'config': {'vim_type': 'VIO'}} + def test_init_vim_collector_and_collect_vio_with_vrops_collector(self, _get_vim_account, vio_collect): + _get_vim_account.return_value = {'vim_type': 'openstack', + 'config': {'vim_type': 'VIO', 'vrops_site': 'https://vrops'}} collector = CollectorService(self.config) collector._collect_vim_metrics({}, 'test_vim_account_id') vio_collect.assert_called_once_with({}) -- 2.25.1