From: lavado Date: Wed, 11 Dec 2019 11:32:48 +0000 (-0500) Subject: Collect null project_ids as empty strings X-Git-Tag: v7.0.1rc3 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=26615e4273101ec43643bed7647a70d5e853e8a2;p=osm%2FMON.git Collect null project_ids as empty strings This deals with errored or transient elements at common database that do not have a valid project_id. Fixes bug 966 Change-Id: I628d621a9ad94c7c7e96894af8743fd30b90d893 Signed-off-by: lavado --- diff --git a/osm_mon/collector/infra_collectors/base_osinfra.py b/osm_mon/collector/infra_collectors/base_osinfra.py index 37b9293..bce363c 100644 --- a/osm_mon/collector/infra_collectors/base_osinfra.py +++ b/osm_mon/collector/infra_collectors/base_osinfra.py @@ -49,7 +49,7 @@ class BaseOpenStackInfraCollector(BaseVimInfraCollector): if self.vim_account['_admin']['projects_read']: vim_project_id = self.vim_account['_admin']['projects_read'][0] else: - vim_project_id = None + vim_project_id = '' vim_tags = { 'vim_account_id': self.vim_account['_id'], 'project_id': vim_project_id @@ -64,7 +64,7 @@ class BaseOpenStackInfraCollector(BaseVimInfraCollector): if vnfr['_admin']['projects_read']: vnfr_project_id = vnfr['_admin']['projects_read'][0] else: - vnfr_project_id = None + vnfr_project_id = '' for vdur in vnfr['vdur']: if 'vim-id' not in vdur: log.debug("Field vim-id is not present in vdur") diff --git a/osm_mon/collector/infra_collectors/onos.py b/osm_mon/collector/infra_collectors/onos.py index 1ad2f4f..33a3aa4 100644 --- a/osm_mon/collector/infra_collectors/onos.py +++ b/osm_mon/collector/infra_collectors/onos.py @@ -45,7 +45,7 @@ class OnosInfraCollector(BaseSdncInfraCollector): if self.sdnc['_admin']['projects_read']: sdnc_project_id = self.sdnc['_admin']['projects_read'][0] else: - sdnc_project_id = None + sdnc_project_id = '' sdnc_tags = { 'sdnc_id': self.sdnc['_id'], 'project_id': sdnc_project_id diff --git a/osm_mon/collector/infra_collectors/vmware.py b/osm_mon/collector/infra_collectors/vmware.py index 7f8ebc2..6accd65 100644 --- a/osm_mon/collector/infra_collectors/vmware.py +++ b/osm_mon/collector/infra_collectors/vmware.py @@ -93,7 +93,10 @@ class VMwareInfraCollector(BaseVimInfraCollector): vim_account['vim_url'] = vim_account_info['vim_url'] vim_account['org_user'] = vim_account_info['vim_user'] vim_account['vim_uuid'] = vim_account_info['_id'] - vim_account['project_id'] = vim_account_info['_admin']['projects_read'][0] + if vim_account_info['_admin']['projects_read']: + vim_account['project_id'] = vim_account_info['_admin']['projects_read'][0] + else: + vim_account['project_id'] = '' vim_config = vim_account_info['config'] vim_account['admin_username'] = vim_config['admin_username'] @@ -181,7 +184,10 @@ class VMwareInfraCollector(BaseVimInfraCollector): nsr_id = vnfr['nsr-id-ref'] ns_name = self.common_db.get_nsr(nsr_id)['name'] vnf_member_index = vnfr['member-vnf-index-ref'] - vnfr_project_id = vnfr['_admin']['projects_read'][0] + if vnfr['_admin']['projects_read']: + vnfr_project_id = vnfr['_admin']['projects_read'][0] + else: + vnfr_project_id = '' for vdur in vnfr['vdur']: resource_uuid = vdur['vim-id'] tags = { diff --git a/osm_mon/collector/vnf_collectors/juju.py b/osm_mon/collector/vnf_collectors/juju.py index 82ee98f..1ca8bf5 100644 --- a/osm_mon/collector/vnf_collectors/juju.py +++ b/osm_mon/collector/vnf_collectors/juju.py @@ -56,7 +56,7 @@ class VCACollector(BaseCollector): if vnfr['_admin']['projects_read']: tags['project_id'] = vnfr['_admin']['projects_read'][0] else: - tags['project_id'] = None + tags['project_id'] = '' metrics = [] for vdur in vnfr['vdur']: diff --git a/osm_mon/collector/vnf_collectors/openstack.py b/osm_mon/collector/vnf_collectors/openstack.py index d1cd2a1..60b387c 100644 --- a/osm_mon/collector/vnf_collectors/openstack.py +++ b/osm_mon/collector/vnf_collectors/openstack.py @@ -88,7 +88,7 @@ class OpenstackCollector(BaseVimCollector): if vnfr['_admin']['projects_read']: tags['project_id'] = vnfr['_admin']['projects_read'][0] else: - tags['project_id'] = None + tags['project_id'] = '' metrics = [] for vdur in vnfr['vdur']: diff --git a/osm_mon/collector/vnf_collectors/vio.py b/osm_mon/collector/vnf_collectors/vio.py index b59f02d..8413496 100644 --- a/osm_mon/collector/vnf_collectors/vio.py +++ b/osm_mon/collector/vnf_collectors/vio.py @@ -55,7 +55,7 @@ class VIOCollector(BaseVimCollector): if vnfr['_admin']['projects_read']: tags['project_id'] = vnfr['_admin']['projects_read'][0] else: - tags['project_id'] = None + tags['project_id'] = '' # Fetch the list of all known resources from vROPS. resource_list = self.vrops.get_vm_resource_list_from_vrops() diff --git a/osm_mon/collector/vnf_collectors/vmware.py b/osm_mon/collector/vnf_collectors/vmware.py index 888b013..b974d76 100644 --- a/osm_mon/collector/vnf_collectors/vmware.py +++ b/osm_mon/collector/vnf_collectors/vmware.py @@ -187,7 +187,7 @@ class VMwareCollector(BaseVimCollector): if vnfr['_admin']['projects_read']: tags['project_id'] = vnfr['_admin']['projects_read'][0] else: - tags['project_id'] = None + tags['project_id'] = '' # Fetch the list of all known resources from vROPS. resource_list = self.vrops.get_vm_resource_list_from_vrops()