Collect null project_ids as empty strings 79/8379/1 sol006 v7.0.0 v7.0.1rc1 v7.0.1rc2 v7.0.1rc3
authorlavado <glavado@whitestack.com>
Wed, 11 Dec 2019 11:32:48 +0000 (06:32 -0500)
committerlavado <glavado@whitestack.com>
Wed, 11 Dec 2019 11:58:01 +0000 (06:58 -0500)
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 <glavado@whitestack.com>
osm_mon/collector/infra_collectors/base_osinfra.py
osm_mon/collector/infra_collectors/onos.py
osm_mon/collector/infra_collectors/vmware.py
osm_mon/collector/vnf_collectors/juju.py
osm_mon/collector/vnf_collectors/openstack.py
osm_mon/collector/vnf_collectors/vio.py
osm_mon/collector/vnf_collectors/vmware.py

index 37b9293..bce363c 100644 (file)
@@ -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")
index 1ad2f4f..33a3aa4 100644 (file)
@@ -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
index 7f8ebc2..6accd65 100644 (file)
@@ -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 = {
index 82ee98f..1ca8bf5 100644 (file)
@@ -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']:
index d1cd2a1..60b387c 100644 (file)
@@ -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']:
index b59f02d..8413496 100644 (file)
@@ -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()
index 888b013..b974d76 100644 (file)
@@ -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()