def collect(self) -> List[Metric]:
metrics = []
vim_status = self.is_vim_ok()
- vim_project_id = self.vim_account['_admin']['projects_read'][0]
+ if self.vim_account['_admin']['projects_read']:
+ vim_project_id = self.vim_account['_admin']['projects_read'][0]
+ else:
+ vim_project_id = None
vim_tags = {
'vim_account_id': self.vim_account['_id'],
'project_id': vim_project_id
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 = None
for vdur in vnfr['vdur']:
if 'vim-id' not in vdur:
log.debug("Field vim-id is not present in vdur")
def collect(self) -> List[Metric]:
metrics = []
sdnc_status = self.is_sdnc_ok()
- sdnc_project_id = self.sdnc['_admin']['projects_read'][0]
+ if self.sdnc['_admin']['projects_read']:
+ sdnc_project_id = self.sdnc['_admin']['projects_read'][0]
+ else:
+ sdnc_project_id = None
sdnc_tags = {
'sdnc_id': self.sdnc['_id'],
'project_id': sdnc_project_id
# Populate extra tags for metrics
tags = {}
tags['ns_name'] = self.common_db.get_nsr(nsr_id)['name']
- tags['project_id'] = vnfr['_admin']['projects_read'][0]
+ if vnfr['_admin']['projects_read']:
+ tags['project_id'] = vnfr['_admin']['projects_read'][0]
+ else:
+ tags['project_id'] = None
metrics = []
for vdur in vnfr['vdur']:
# Populate extra tags for metrics
tags = {}
tags['ns_name'] = self.common_db.get_nsr(nsr_id)['name']
- tags['project_id'] = vnfr['_admin']['projects_read'][0]
+ if vnfr['_admin']['projects_read']:
+ tags['project_id'] = vnfr['_admin']['projects_read'][0]
+ else:
+ tags['project_id'] = None
metrics = []
for vdur in vnfr['vdur']:
nsr_id = vnfr['nsr-id-ref']
tags = {}
tags['ns_name'] = self.common_db.get_nsr(nsr_id)['name']
- tags['project_id'] = vnfr['_admin']['projects_read'][0]
+ if vnfr['_admin']['projects_read']:
+ tags['project_id'] = vnfr['_admin']['projects_read'][0]
+ else:
+ tags['project_id'] = None
# Fetch the list of all known resources from vROPS.
resource_list = self.vrops.get_vm_resource_list_from_vrops()
nsr_id = vnfr['nsr-id-ref']
tags = {}
tags['ns_name'] = self.common_db.get_nsr(nsr_id)['name']
- tags['project_id'] = vnfr['_admin']['projects_read'][0]
+ if vnfr['_admin']['projects_read']:
+ tags['project_id'] = vnfr['_admin']['projects_read'][0]
+ else:
+ tags['project_id'] = None
# Fetch the list of all known resources from vROPS.
resource_list = self.vrops.get_vm_resource_list_from_vrops()
def get_vnfd_by_name(self, vnfd_name: str):
# TODO: optimize way of getting single VNFD in shared enviroments (RBAC)
- vnfd = self.common_db.get_list("vnfds",
- {"name": vnfd_name})[0]
- return vnfd
+ if self.common_db.get_list("vnfds", {"name": vnfd_name}):
+ vnfd = self.common_db.get_list("vnfds", {"name": vnfd_name})[0]
+ return vnfd
+ else:
+ return None
def get_nsrs(self):
return self.common_db.get_list('nsrs')
grafana:
url: http://grafana:3000
- token: "Basic YWRtaW46YWRtaW4="
prometheus:
url: http://prometheus:9090
log = logging.getLogger(__name__)
-# TODO (lavado): migrate to Class, import config variables
+# TODO (lavado): migrate to Class, import config variables to get token
url = "http://grafana:3000/api/"
headers = {
'content-type': "application/json",
dashboards = response.json()
dashboard_uids = []
for dashboard in dashboards:
- print(dashboard['uid'])
dashboard_uids.append(dashboard['uid'])
log.debug("Searching for all dashboard uids: %s", dashboard_uids)
return dashboard_uids