From: hoban Date: Tue, 17 Apr 2018 14:10:07 +0000 (+0200) Subject: Merge "Get Metric_UUID directly from VIM Change-Id: I9b8c47b2fd7987f8834dc7c90e826d9d... X-Git-Tag: v4.0.0~14 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;ds=sidebyside;h=341c33b98b4951c5d617e040cf856d4011a09266;hp=-c;p=osm%2FMON.git Merge "Get Metric_UUID directly from VIM Change-Id: I9b8c47b2fd7987f8834dc7c90e826d9d2789ce51 Signed-off-by: gcalvino " --- 341c33b98b4951c5d617e040cf856d4011a09266 diff --combined osm_mon/plugins/OpenStack/Gnocchi/metrics.py index 2724508,a30b732..47bc7d9 --- a/osm_mon/plugins/OpenStack/Gnocchi/metrics.py +++ b/osm_mon/plugins/OpenStack/Gnocchi/metrics.py @@@ -28,7 -28,6 +28,7 @@@ import loggin import time import six +import yaml from osm_mon.core.message_bus.producer import KafkaProducer from osm_mon.plugins.OpenStack.common import Common @@@ -39,7 -38,7 +39,7 @@@ from osm_mon.plugins.OpenStack.setting log = logging.getLogger(__name__) METRIC_MAPPINGS = { - "average_memory_utilization": "memory.percent", + "average_memory_utilization": "memory.usage", "disk_read_ops": "disk.read.requests", "disk_write_ops": "disk.write.requests", "disk_read_bytes": "disk.read.bytes", @@@ -79,10 -78,7 +79,10 @@@ class Metrics(object) def metric_calls(self, message): """Consume info from the message bus to manage metric requests.""" - values = json.loads(message.value) + try: + values = json.loads(message.value) + except ValueError: + values = yaml.safe_load(message.value) log.info("OpenStack metric action required.") auth_token = Common.get_auth_token(values['vim_uuid']) @@@ -115,9 -111,12 +115,12 @@@ # Generate and send a response message try: + + metric_id = self.get_metric_id(endpoint, auth_token, METRIC_MAPPINGS[values['metric_name']], + values['resource_uuid']) resp_message = self._response.generate_response( 'read_metric_data_response', - m_id=values['metric_uuid'], + m_id=metric_id, m_name=values['metric_name'], r_id=values['resource_uuid'], cor_id=values['correlation_id'], @@@ -131,7 -130,8 +134,8 @@@ elif message.key == "delete_metric_request": # delete the specified metric in the request - metric_id = values['metric_uuid'] + metric_id = self.get_metric_id(endpoint, auth_token, METRIC_MAPPINGS[values['metric_name']], + values['resource_uuid']) status = self.delete_metric( endpoint, auth_token, metric_id) @@@ -352,7 -352,6 +356,6 @@@ def get_metric_id(self, endpoint, auth_token, metric_name, resource_id): """Check if the desired metric already exists for the resource.""" url = "{}/v1/resource/generic/%s".format(endpoint) % resource_id - try: # Try return the metric id if it exists result = Common.perform_request( @@@ -378,8 -377,9 +381,9 @@@ timestamps = [] data = [] try: + #get metric_id + metric_id = self.get_metric_id(endpoint, auth_token, METRIC_MAPPINGS[values['metric_name']], values['resource_uuid']) # Try and collect measures - metric_id = values['metric_uuid'] collection_unit = values['collection_unit'].upper() collection_period = values['collection_period']