- self.metric_list = ['cpu_utilization', 'average_memory_utilization', 'disk_read_ops',
- 'disk_write_ops', 'disk_read_bytes', 'disk_write_bytes', 'packets_dropped',
- 'packets_sent', 'packets_received']
+ self.nfvi_metric_list = ['cpu_utilization', 'average_memory_utilization', 'disk_read_ops',
+ 'disk_write_ops', 'disk_read_bytes', 'disk_write_bytes',
+ 'packets_dropped', 'packets_sent', 'packets_received']
+
+ def _get_vnf_metric_list(self, ns_id):
+ metric_list = self.nfvi_metric_list.copy()
+ vnfr_desc = self.db.get_list("vnfrs", {"nsr-id-ref": ns_id})
+ if not vnfr_desc:
+ raise EngineException("NS not found with id {}".format(ns_id), http_code=HTTPStatus.NOT_FOUND)
+ else:
+ for vnfr in vnfr_desc:
+ vnfd_desc = self.db.get_one("vnfds", {"_id": vnfr["vnfd-id"]}, fail_on_empty=True, fail_on_more=False)
+ if vnfd_desc.get("vdu"):
+ for vdu in vnfd_desc['vdu']:
+ # Checks for vdu metric in vdu-configuration
+ if 'vdu-configuration' in vdu and 'metrics' in vdu['vdu-configuration']:
+ metric_list.extend([quote(metric['name'])
+ for metric in vdu["vdu-configuration"]["metrics"]])
+ # Checks for vnf metric in vnf-configutaion
+ if 'vnf-configuration' in vnfd_desc and 'metrics' in vnfd_desc['vnf-configuration']:
+ metric_list.extend([quote(metric['name']) for metric in vnfd_desc["vnf-configuration"]["metrics"]])
+ metric_list = list(set(metric_list))
+ return metric_list