From 3ddffeaff35f46938e43558d852d330b9041d7c5 Mon Sep 17 00:00:00 2001 From: Benjamin Diaz Date: Wed, 6 Mar 2019 15:54:37 -0300 Subject: [PATCH] Fixes bug with VM status collection when VIM is down Change-Id: I5f4c8ad9d074ede337aae53e4120088d0a307170 Signed-off-by: Benjamin Diaz --- osm_mon/collector/infra_collectors/openstack.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/osm_mon/collector/infra_collectors/openstack.py b/osm_mon/collector/infra_collectors/openstack.py index 5c34e9c..cb8259e 100644 --- a/osm_mon/collector/infra_collectors/openstack.py +++ b/osm_mon/collector/infra_collectors/openstack.py @@ -57,8 +57,6 @@ class OpenstackInfraCollector(BaseVimInfraCollector): vnf_member_index = vnfr['member-vnf-index-ref'] for vdur in vnfr['vdur']: resource_uuid = vdur['vim-id'] - vm = self.nova.servers.get(resource_uuid) - vm_status = (1 if vm.status == 'ACTIVE' else 0) tags = { 'vim_account_id': self.vim_account_id, 'resource_uuid': resource_uuid, @@ -66,7 +64,13 @@ class OpenstackInfraCollector(BaseVimInfraCollector): 'vnf_member_index': vnf_member_index, 'vdur_name': vdur['name'] } - vm_status_metric = Metric(tags, 'vm_status', vm_status) + try: + vm = self.nova.servers.get(resource_uuid) + vm_status = (1 if vm.status == 'ACTIVE' else 0) + vm_status_metric = Metric(tags, 'vm_status', vm_status) + except Exception: + log.exception("VM status is not OK!") + vm_status_metric = Metric(tags, 'vm_status', 0) metrics.append(vm_status_metric) return metrics -- 2.25.1