From 4da146638bc3838270fa41c9f9fb91961f726c97 Mon Sep 17 00:00:00 2001 From: Benjamin Diaz Date: Wed, 17 Oct 2018 14:44:36 -0300 Subject: [PATCH] Adds use of CustomCollector in Prometheus exporter Using a CustomCollector gives more control over the collection process, which allows handling the removal of metrics when a NS is deleted. Metrics now have a lifespan of a collection cycle, so metrics of deleted vdus are now not visible in the exporter. It also adds MonCollector class, which allows to abstract collection logic and facilitates testing. Signed-off-by: Benjamin Diaz Change-Id: Idfdb86c1ee9facd07187e6582954ae4cab32a5b4 --- docker/scripts/runInstall.sh | 2 +- ...exporter.py => mon_prometheus_exporter.py} | 6 +- osm_mon/{exporter => collector}/__init__.py | 0 osm_mon/collector/collector.py | 118 ++++++++++ osm_mon/collector/prometheus_exporter.py | 88 ++++++++ osm_mon/core/message_bus/common_consumer.py | 2 + osm_mon/core/settings.py | 3 +- osm_mon/exporter/exporter.py | 125 ----------- osm_mon/plugins/OpenStack/Aodh/notifier.py | 1 - osm_mon/test/collector/__init__.py | 22 ++ osm_mon/test/collector/test_collector.py | 206 ++++++++++++++++++ osm_mon/test/core/test_common_consumer.py | 22 ++ .../CloudWatch}/__init__.py | 0 .../alarm_details/acknowledge_alarm.json | 0 ...alarm_differentName_differentInstance.json | 0 ...eate_alarm_differentName_sameInstance.json | 0 ...eate_alarm_sameName_differentInstance.json | 0 .../create_alarm_sameName_sameInstance.json | 0 .../create_alarm/operation_invalid.json | 0 .../create_alarm/operation_valid.json | 0 .../create_alarm/statistic_invalid.json | 0 .../create_alarm/statistic_valid.json | 0 .../create_metric_req_invalid.json | 0 .../create_metric_req_valid.json | 0 .../delete_alarm/name_invalid.json | 0 .../test_schemas/delete_alarm/name_valid.json | 0 .../delete_alarm/name_valid_delete1.json | 0 .../delete_alarm/name_valid_delete2.json | 0 .../delete_alarm/name_valid_delete3.json | 0 .../delete_alarm/name_valid_delete4.json | 0 .../delete_metric_req_invalid.json | 0 .../delete_metric_req_valid.json | 0 .../list_alarm_valid_no_arguments.json | 0 .../list_alarm_valid_one_argument.json | 0 .../list_alarm_valid_two_arguments.json | 0 .../list_metrics/list_metric_req_invalid.json | 0 .../list_metrics/list_metric_req_valid.json | 0 .../read_coll_period_req_invalid.json | 0 .../read_coll_period_req_valid.json | 0 .../read_metric_name_req_invalid.json | 0 .../read_metric_name_req_valid.json | 0 .../update_alarm/name_invalid.json | 0 .../test_schemas/update_alarm/name_valid.json | 0 .../update_alarm/operation_invalid.json | 0 .../update_alarm/operation_valid.json | 0 .../update_alarm/statistic_invalid.json | 0 .../update_alarm/statistic_valid.json | 0 .../update_alarm/update_alarm_new_alarm.json | 0 .../update_metric_req_invalid.json | 0 .../update_metric_req_valid.json | 0 .../CloudWatch/unit_tests_alarms.py | 0 .../CloudWatch/unit_tests_metrics.py | 0 .../test/{ => plugins}/OpenStack/__init__.py | 0 .../OpenStack/integration/__init__.py | 0 .../integration/test_alarm_integration.py | 0 .../integration/test_metric_integration.py | 0 .../integration/test_notify_alarm.py | 0 .../OpenStack/integration/test_vim_account.py | 0 .../{ => plugins}/OpenStack/unit/__init__.py | 0 .../OpenStack/unit/test_alarm_req.py | 0 .../OpenStack/unit/test_alarming.py | 0 .../OpenStack/unit/test_common.py | 0 .../OpenStack/unit/test_metric_calls.py | 0 .../OpenStack/unit/test_metric_req.py | 0 .../OpenStack/unit/test_notifier.py | 0 .../OpenStack/unit/test_responses.py | 0 .../OpenStack/unit/test_settings.py | 0 osm_mon/test/{ => plugins}/VMware/__init__.py | 0 .../VMware/test_mon_plugin_vrops.py | 0 .../VMware/test_plugin_receiver.py | 0 osm_mon/test/plugins/__init__.py | 22 ++ setup.py | 2 +- 72 files changed, 487 insertions(+), 132 deletions(-) rename osm_mon/cmd/{exporter.py => mon_prometheus_exporter.py} (91%) rename osm_mon/{exporter => collector}/__init__.py (100%) create mode 100644 osm_mon/collector/collector.py create mode 100644 osm_mon/collector/prometheus_exporter.py delete mode 100644 osm_mon/exporter/exporter.py create mode 100644 osm_mon/test/collector/__init__.py create mode 100644 osm_mon/test/collector/test_collector.py rename osm_mon/test/{functional => plugins/CloudWatch}/__init__.py (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/alarm_details/acknowledge_alarm.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/create_alarm/create_alarm_differentName_differentInstance.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/create_alarm/create_alarm_differentName_sameInstance.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/create_alarm/create_alarm_sameName_differentInstance.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/create_alarm/create_alarm_sameName_sameInstance.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/create_alarm/operation_invalid.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/create_alarm/operation_valid.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/create_alarm/statistic_invalid.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/create_alarm/statistic_valid.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/create_metrics/create_metric_req_invalid.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/create_metrics/create_metric_req_valid.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/delete_alarm/name_invalid.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/delete_alarm/name_valid.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/delete_alarm/name_valid_delete1.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/delete_alarm/name_valid_delete2.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/delete_alarm/name_valid_delete3.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/delete_alarm/name_valid_delete4.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/delete_metrics/delete_metric_req_invalid.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/delete_metrics/delete_metric_req_valid.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/list_alarm/list_alarm_valid_no_arguments.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/list_alarm/list_alarm_valid_one_argument.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/list_alarm/list_alarm_valid_two_arguments.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/list_metrics/list_metric_req_invalid.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/list_metrics/list_metric_req_valid.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/read_metrics_data/read_coll_period_req_invalid.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/read_metrics_data/read_coll_period_req_valid.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/read_metrics_data/read_metric_name_req_invalid.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/read_metrics_data/read_metric_name_req_valid.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/update_alarm/name_invalid.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/update_alarm/name_valid.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/update_alarm/operation_invalid.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/update_alarm/operation_valid.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/update_alarm/statistic_invalid.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/update_alarm/statistic_valid.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/update_alarm/update_alarm_new_alarm.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/update_metrics/update_metric_req_invalid.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/test_schemas/update_metrics/update_metric_req_valid.json (100%) rename osm_mon/test/{ => plugins}/CloudWatch/unit_tests_alarms.py (100%) rename osm_mon/test/{ => plugins}/CloudWatch/unit_tests_metrics.py (100%) rename osm_mon/test/{ => plugins}/OpenStack/__init__.py (100%) rename osm_mon/test/{ => plugins}/OpenStack/integration/__init__.py (100%) rename osm_mon/test/{ => plugins}/OpenStack/integration/test_alarm_integration.py (100%) rename osm_mon/test/{ => plugins}/OpenStack/integration/test_metric_integration.py (100%) rename osm_mon/test/{ => plugins}/OpenStack/integration/test_notify_alarm.py (100%) rename osm_mon/test/{ => plugins}/OpenStack/integration/test_vim_account.py (100%) rename osm_mon/test/{ => plugins}/OpenStack/unit/__init__.py (100%) rename osm_mon/test/{ => plugins}/OpenStack/unit/test_alarm_req.py (100%) rename osm_mon/test/{ => plugins}/OpenStack/unit/test_alarming.py (100%) rename osm_mon/test/{ => plugins}/OpenStack/unit/test_common.py (100%) rename osm_mon/test/{ => plugins}/OpenStack/unit/test_metric_calls.py (100%) rename osm_mon/test/{ => plugins}/OpenStack/unit/test_metric_req.py (100%) rename osm_mon/test/{ => plugins}/OpenStack/unit/test_notifier.py (100%) rename osm_mon/test/{ => plugins}/OpenStack/unit/test_responses.py (100%) rename osm_mon/test/{ => plugins}/OpenStack/unit/test_settings.py (100%) rename osm_mon/test/{ => plugins}/VMware/__init__.py (100%) rename osm_mon/test/{ => plugins}/VMware/test_mon_plugin_vrops.py (100%) rename osm_mon/test/{ => plugins}/VMware/test_plugin_receiver.py (100%) create mode 100644 osm_mon/test/plugins/__init__.py diff --git a/docker/scripts/runInstall.sh b/docker/scripts/runInstall.sh index ccfc2f3..29ab3c6 100755 --- a/docker/scripts/runInstall.sh +++ b/docker/scripts/runInstall.sh @@ -23,5 +23,5 @@ /bin/bash /mon/osm_mon/plugins/vRealiseOps/vROPs_Webservice/install.sh python3 /mon/osm_mon/plugins/OpenStack/Aodh/notifier.py & python3 /mon/osm_mon/core/message_bus/common_consumer.py & -osm-mon-exporter +osm-mon-prometheus-exporter diff --git a/osm_mon/cmd/exporter.py b/osm_mon/cmd/mon_prometheus_exporter.py similarity index 91% rename from osm_mon/cmd/exporter.py rename to osm_mon/cmd/mon_prometheus_exporter.py index a3545a3..f018b5d 100644 --- a/osm_mon/cmd/exporter.py +++ b/osm_mon/cmd/mon_prometheus_exporter.py @@ -25,7 +25,7 @@ import logging import sys from osm_mon.core.settings import Config -from osm_mon.exporter.exporter import MonExporter +from osm_mon.collector.prometheus_exporter import MonPrometheusExporter def main(): @@ -42,9 +42,9 @@ def main(): kafka_handler.setFormatter(kafka_formatter) kafka_logger.addHandler(kafka_handler) log = logging.getLogger(__name__) - log.info("Starting MON Exporter...") + log.info("Starting MON Prometheus Exporter...") log.info("Config: %s", vars(cfg)) - exporter = MonExporter() + exporter = MonPrometheusExporter() exporter.run() diff --git a/osm_mon/exporter/__init__.py b/osm_mon/collector/__init__.py similarity index 100% rename from osm_mon/exporter/__init__.py rename to osm_mon/collector/__init__.py diff --git a/osm_mon/collector/collector.py b/osm_mon/collector/collector.py new file mode 100644 index 0000000..9bf3953 --- /dev/null +++ b/osm_mon/collector/collector.py @@ -0,0 +1,118 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Whitestack, LLC +# ************************************************************* + +# This file is part of OSM Monitoring module +# All Rights Reserved to Whitestack, LLC + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# For those usages not covered by the Apache License, Version 2.0 please +# contact: bdiaz@whitestack.com or glavado@whitestack.com +## +import json +import logging +import random +import uuid +from collections import Iterable + +from kafka import KafkaProducer, KafkaConsumer +from osm_common import dbmongo +from prometheus_client.core import GaugeMetricFamily + +from osm_mon.core.settings import Config + +log = logging.getLogger(__name__) + + +class MonCollector: + def __init__(self): + cfg = Config.instance() + self.kafka_server = cfg.BROKER_URI + self.common_db_host = cfg.MONGO_URI.split(':')[0] + self.common_db_port = cfg.MONGO_URI.split(':')[1] + self.common_db = dbmongo.DbMongo() + self.common_db.db_connect({'host': self.common_db_host, 'port': int(self.common_db_port), 'name': 'osm'}) + self.producer = KafkaProducer(bootstrap_servers=self.kafka_server, + key_serializer=str.encode, + value_serializer=str.encode) + self.consumer = KafkaConsumer(bootstrap_servers=self.kafka_server, + key_deserializer=bytes.decode, + value_deserializer=bytes.decode, + consumer_timeout_ms=10000, + group_id='mon-collector-' + str(uuid.uuid4())) + self.consumer.subscribe(['metric_response']) + + def collect_metrics(self) -> Iterable: + # TODO(diazb): Remove dependencies on prometheus_client + log.debug("collect_metrics") + metrics = {} + vnfrs = self.common_db.get_list('vnfrs') + for vnfr in vnfrs: + nsr_id = vnfr['nsr-id-ref'] + vnfd = self.common_db.get_one('vnfds', {"_id": vnfr['vnfd-id']}) + payloads = self._generate_metric_data_payloads(vnfr, vnfd) + for payload in payloads: + cor_id = payload['correlation_id'] + metric_name = payload['metric_name'] + vnf_member_index = payload['vnf_member_index'] + vdu_name = payload['vdu_name'] + self.producer.send(topic='metric_request', key='read_metric_data_request', + value=json.dumps(payload)) + self.producer.flush() + for message in self.consumer: + if message.key == 'read_metric_data_response': + content = json.loads(message.value) + if content['correlation_id'] == cor_id: + if len(content['metrics_data']['metrics_series']): + metric_reading = content['metrics_data']['metrics_series'][-1] + if metric_name not in metrics.keys(): + metrics[metric_name] = GaugeMetricFamily( + metric_name, + 'OSM metric', + labels=['ns_id', 'vnf_member_index', 'vdu_name'] + ) + metrics[metric_name].add_metric([nsr_id, vnf_member_index, vdu_name], + metric_reading) + break + return metrics.values() + + @staticmethod + def _generate_metric_data_payloads(vnfr: dict, vnfd: dict) -> list: + log.debug('_generate_metric_data_payloads') + payloads = [] + nsr_id = vnfr['nsr-id-ref'] + for vdur in vnfr['vdur']: + # This avoids errors when vdur records have not been completely filled + if 'name' not in vdur: + continue + vdu = next( + filter(lambda vdu: vdu['id'] == vdur['vdu-id-ref'], vnfd['vdu']) + ) + if 'monitoring-param' in vdu: + for param in vdu['monitoring-param']: + metric_name = param['nfvi-metric'] + vnf_member_index = vnfr['member-vnf-index-ref'] + vdu_name = vdur['name'] + cor_id = random.randint(1, 10e7) + payload = { + 'correlation_id': cor_id, + 'metric_name': metric_name, + 'ns_id': nsr_id, + 'vnf_member_index': vnf_member_index, + 'vdu_name': vdu_name, + 'collection_period': 1, + 'collection_unit': 'DAY', + } + payloads.append(payload) + return payloads diff --git a/osm_mon/collector/prometheus_exporter.py b/osm_mon/collector/prometheus_exporter.py new file mode 100644 index 0000000..d61a286 --- /dev/null +++ b/osm_mon/collector/prometheus_exporter.py @@ -0,0 +1,88 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Whitestack, LLC +# ************************************************************* + +# This file is part of OSM Monitoring module +# All Rights Reserved to Whitestack, LLC + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# For those usages not covered by the Apache License, Version 2.0 please +# contact: bdiaz@whitestack.com or glavado@whitestack.com +## +import logging +import threading +import time +from http.server import HTTPServer + +from prometheus_client import MetricsHandler +from prometheus_client.core import REGISTRY + +from osm_mon.collector.collector import MonCollector +from osm_mon.core.settings import Config + +log = logging.getLogger(__name__) + + +class MonPrometheusExporter: + + def __init__(self): + self.mon_collector = MonCollector() + self.custom_collector = CustomCollector() + + def _run_exporter(self): + log.debug('_run_exporter') + REGISTRY.register(self.custom_collector) + server_address = ('', 8000) + httpd = HTTPServer(server_address, MetricsHandler) + log.info("Starting MON Prometheus exporter at port %s", 8000) + httpd.serve_forever() + + def run(self): + log.debug('_run') + self._run_exporter() + self._run_collector() + + def _run_collector(self): + log.debug('_run_collector') + t = threading.Thread(target=self._collect_metrics_forever) + t.setDaemon(True) + t.start() + + def _collect_metrics_forever(self): + log.debug('_collect_metrics_forever') + cfg = Config.instance() + while True: + time.sleep(cfg.OSMMON_COLLECTOR_INTERVAL) + metrics = self.mon_collector.collect_metrics() + self.custom_collector.metrics = metrics + + +class CustomCollector(object): + + def __init__(self): + self.mon_collector = MonCollector() + self.metrics = [] + + def describe(self): + log.debug('describe') + return [] + + def collect(self): + log.debug("collect") + metrics = self.mon_collector.collect_metrics() + return metrics + + +if __name__ == '__main__': + MonPrometheusExporter().run() diff --git a/osm_mon/core/message_bus/common_consumer.py b/osm_mon/core/message_bus/common_consumer.py index 0b61e1e..b2677d8 100755 --- a/osm_mon/core/message_bus/common_consumer.py +++ b/osm_mon/core/message_bus/common_consumer.py @@ -91,6 +91,8 @@ class CommonConsumer: topics = ['metric_request', 'alarm_request', 'vim_account'] common_consumer.subscribe(topics) + common_consumer.poll() + common_consumer.seek_to_end() log.info("Listening for messages...") for message in common_consumer: diff --git a/osm_mon/core/settings.py b/osm_mon/core/settings.py index 6574f59..9700af5 100644 --- a/osm_mon/core/settings.py +++ b/osm_mon/core/settings.py @@ -66,7 +66,8 @@ class Config(object): CfgParam('OS_DEFAULT_GRANULARITY', "300", six.text_type), CfgParam('REQUEST_TIMEOUT', 10, int), CfgParam('OSMMON_LOG_LEVEL', "INFO", six.text_type), - CfgParam('OSMMON_KAFKA_LOG_LEVEL', "INFO", six.text_type), + CfgParam('OSMMON_KAFKA_LOG_LEVEL', "WARN", six.text_type), + CfgParam('OSMMON_COLLECTOR_INTERVAL', 10, int), ] _config_dict = {cfg.key: cfg for cfg in _configuration} diff --git a/osm_mon/exporter/exporter.py b/osm_mon/exporter/exporter.py deleted file mode 100644 index b7893e0..0000000 --- a/osm_mon/exporter/exporter.py +++ /dev/null @@ -1,125 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2018 Whitestack, LLC -# ************************************************************* - -# This file is part of OSM Monitoring module -# All Rights Reserved to Whitestack, LLC - -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# For those usages not covered by the Apache License, Version 2.0 please -# contact: bdiaz@whitestack.com or glavado@whitestack.com -## -import json -import logging -import random -import threading -import time -import uuid - -from kafka import KafkaProducer, KafkaConsumer -from osm_common import dbmongo -from prometheus_client import start_http_server, Gauge - -from osm_mon.core.settings import Config - -log = logging.getLogger(__name__) - - -class MonExporter: - - def __init__(self): - cfg = Config.instance() - self.kafka_server = cfg.BROKER_URI - self.common_db_host = cfg.MONGO_URI.split(':')[0] - self.common_db_port = cfg.MONGO_URI.split(':')[1] - self.collector_interval = 5 - self.metrics = {} - - def _run_exporter(self): - start_http_server(8000) - - def _run_collector(self): - producer = KafkaProducer(bootstrap_servers=self.kafka_server, - key_serializer=str.encode, - value_serializer=str.encode) - consumer = KafkaConsumer(bootstrap_servers=self.kafka_server, - key_deserializer=bytes.decode, - value_deserializer=bytes.decode, - consumer_timeout_ms=10000, - group_id='mon-collector-' + str(uuid.uuid4())) - consumer.subscribe(['metric_response']) - common_db = dbmongo.DbMongo() - common_db.db_connect({'host': self.common_db_host, 'port': int(self.common_db_port), 'name': 'osm'}) - - while True: - try: - time.sleep(self.collector_interval) - vnfrs = common_db.get_list('vnfrs') - for vnfr in vnfrs: - vnfd = common_db.get_one('vnfds', {"_id": vnfr['vnfd-id']}) - for vdur in vnfr['vdur']: - vdu = next( - filter(lambda vdu: vdu['id'] == vdur['vdu-id-ref'], vnfd['vdu']) - ) - if 'monitoring-param' in vdu: - for param in vdu['monitoring-param']: - metric_name = param['nfvi-metric'] - nsr_id = vnfr['nsr-id-ref'] - vnf_member_index = vnfr['member-vnf-index-ref'] - vdu_name = vdur['name'] - cor_id = random.randint(1, 10e7) - payload = { - 'correlation_id': cor_id, - 'metric_name': metric_name, - 'ns_id': nsr_id, - 'vnf_member_index': vnf_member_index, - 'vdu_name': vdu_name, - 'collection_period': 1, - 'collection_unit': 'DAY', - } - producer.send(topic='metric_request', key='read_metric_data_request', - value=json.dumps(payload)) - producer.flush() - for message in consumer: - if message.key == 'read_metric_data_response': - content = json.loads(message.value) - if content['correlation_id'] == cor_id and len( - content['metrics_data']['metrics_series']): - metric_reading = content['metrics_data']['metrics_series'][-1] - if metric_name not in self.metrics.keys(): - self.metrics[metric_name] = Gauge(metric_name, - 'Metric generated by MON collector', - ['ns_id', - 'vnf_member_index', - 'vdu_name']) - self.metrics[metric_name].labels( - ns_id=nsr_id, - vnf_member_index=vnf_member_index, - vdu_name=vdu_name - ).set(metric_reading) - break - - - except Exception: - log.exception("Error collecting metrics: ") - - def run(self): - t1 = threading.Thread(target=self._run_exporter) - t1.start() - t2 = threading.Thread(target=self._run_collector) - t2.start() - - -if __name__ == '__main__': - MonExporter().run() diff --git a/osm_mon/plugins/OpenStack/Aodh/notifier.py b/osm_mon/plugins/OpenStack/Aodh/notifier.py index b63e581..71c6c1c 100644 --- a/osm_mon/plugins/OpenStack/Aodh/notifier.py +++ b/osm_mon/plugins/OpenStack/Aodh/notifier.py @@ -131,7 +131,6 @@ def run(server_class=HTTPServer, handler_class=NotifierHandler, port=8662): try: server_address = ('', port) httpd = server_class(server_address, handler_class) - print('Starting alarm notifier...') log.info("Starting alarm notifier server on port: %s", port) httpd.serve_forever() except Exception as exc: diff --git a/osm_mon/test/collector/__init__.py b/osm_mon/test/collector/__init__.py new file mode 100644 index 0000000..2d39b96 --- /dev/null +++ b/osm_mon/test/collector/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Whitestack, LLC +# ************************************************************* + +# This file is part of OSM Monitoring module +# All Rights Reserved to Whitestack, LLC + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# For those usages not covered by the Apache License, Version 2.0 please +# contact: bdiaz@whitestack.com or glavado@whitestack.com +## \ No newline at end of file diff --git a/osm_mon/test/collector/test_collector.py b/osm_mon/test/collector/test_collector.py new file mode 100644 index 0000000..b4ec741 --- /dev/null +++ b/osm_mon/test/collector/test_collector.py @@ -0,0 +1,206 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Whitestack, LLC +# ************************************************************* + +# This file is part of OSM Monitoring module +# All Rights Reserved to Whitestack, LLC + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# For those usages not covered by the Apache License, Version 2.0 please +# contact: bdiaz@whitestack.com or glavado@whitestack.com +## +import unittest + +import mock +from kafka import KafkaProducer +from kafka.errors import KafkaError +from osm_common import dbmongo + +from osm_mon.collector.collector import MonCollector +from osm_mon.core.database import VimCredentials, DatabaseManager +from osm_mon.core.message_bus.common_consumer import CommonConsumer + + +@mock.patch.object(dbmongo.DbMongo, "db_connect", mock.Mock()) +class MonCollectorTest(unittest.TestCase): + def test_generate_metric_data_payloads(self): + vnfr = { + "_id": "0d9d06ad-3fc2-418c-9934-465e815fafe2", + "ip-address": "192.168.160.2", + "created-time": 1535392482.0044956, + "vim-account-id": "be48ae31-1d46-4892-a4b4-d69abd55714b", + "vdur": [ + { + "interfaces": [ + { + "mac-address": "fa:16:3e:71:fd:b8", + "name": "eth0", + "ip-address": "192.168.160.2" + } + ], + "status": "ACTIVE", + "vim-id": "63a65636-9fc8-4022-b070-980823e6266a", + "name": "cirros_ns-1-cirros_vnfd-VM-1", + "status-detailed": None, + "ip-address": "192.168.160.2", + "vdu-id-ref": "cirros_vnfd-VM" + } + ], + "id": "0d9d06ad-3fc2-418c-9934-465e815fafe2", + "vnfd-ref": "cirros_vdu_scaling_vnf", + "vnfd-id": "63f44c41-45ee-456b-b10d-5f08fb1796e0", + "_admin": { + "created": 1535392482.0067868, + "projects_read": [ + "admin" + ], + "modified": 1535392482.0067868, + "projects_write": [ + "admin" + ] + }, + "nsr-id-ref": "87776f33-b67c-417a-8119-cb08e4098951", + "member-vnf-index-ref": "1", + "connection-point": [ + { + "name": "eth0", + "id": None, + "connection-point-id": None + } + ] + } + vnfd = { + "_id": "63f44c41-45ee-456b-b10d-5f08fb1796e0", + "name": "cirros_vdu_scaling_vnf", + "vendor": "OSM", + "vdu": [ + { + "name": "cirros_vnfd-VM", + "monitoring-param": [ + { + "id": "cirros_vnfd-VM_memory_util", + "nfvi-metric": "average_memory_utilization" + } + ], + "vm-flavor": { + "vcpu-count": 1, + "memory-mb": 256, + "storage-gb": 2 + }, + "description": "cirros_vnfd-VM", + "count": 1, + "id": "cirros_vnfd-VM", + "interface": [ + { + "name": "eth0", + "external-connection-point-ref": "eth0", + "type": "EXTERNAL", + "virtual-interface": { + "bandwidth": "0", + "type": "VIRTIO", + "vpci": "0000:00:0a.0" + } + } + ], + "image": "cirros034" + } + ], + "monitoring-param": [ + { + "id": "cirros_vnf_memory_util", + "name": "cirros_vnf_memory_util", + "aggregation-type": "AVERAGE", + "vdu-monitoring-param-ref": "cirros_vnfd-VM_memory_util", + "vdu-ref": "cirros_vnfd-VM" + } + ], + "description": "Simple VNF example with a cirros and a scaling group descriptor", + "id": "cirros_vdu_scaling_vnf", + "logo": "cirros-64.png", + "version": "1.0", + "connection-point": [ + { + "name": "eth0", + "type": "VPORT" + } + ], + "mgmt-interface": { + "cp": "eth0" + }, + "scaling-group-descriptor": [ + { + "name": "scale_cirros_vnfd-VM", + "min-instance-count": 1, + "vdu": [ + { + "count": 1, + "vdu-id-ref": "cirros_vnfd-VM" + } + ], + "max-instance-count": 10, + "scaling-policy": [ + { + "name": "auto_memory_util_above_threshold", + "scaling-type": "automatic", + "cooldown-time": 60, + "threshold-time": 10, + "scaling-criteria": [ + { + "name": "group1_memory_util_above_threshold", + "vnf-monitoring-param-ref": "cirros_vnf_memory_util", + "scale-out-threshold": 80, + "scale-out-relational-operation": "GT", + "scale-in-relational-operation": "LT", + "scale-in-threshold": 20 + } + ] + } + ] + } + ], + "short-name": "cirros_vdu_scaling_vnf", + "_admin": { + "created": 1535392242.6281035, + "modified": 1535392242.6281035, + "storage": { + "zipfile": "package.tar.gz", + "pkg-dir": "cirros_vnf", + "path": "/app/storage/", + "folder": "63f44c41-45ee-456b-b10d-5f08fb1796e0", + "fs": "local", + "descriptor": "cirros_vnf/cirros_vdu_scaling_vnfd.yaml" + }, + "usageSate": "NOT_IN_USE", + "onboardingState": "ONBOARDED", + "userDefinedData": { + + }, + "projects_read": [ + "admin" + ], + "operationalState": "ENABLED", + "projects_write": [ + "admin" + ] + } + } + payloads = MonCollector._generate_metric_data_payloads(vnfr, vnfd) + expected_payload = {'ns_id': '87776f33-b67c-417a-8119-cb08e4098951', + 'vnf_member_index': '1', + 'metric_name': 'average_memory_utilization', + 'collection_period': 1, + 'collection_unit': 'DAY', + 'vdu_name': 'cirros_ns-1-cirros_vnfd-VM-1'} + self.assertEqual(len(payloads), 1) + self.assertEqual(set(expected_payload.items()).issubset(set(payloads[0].items())), True) diff --git a/osm_mon/test/core/test_common_consumer.py b/osm_mon/test/core/test_common_consumer.py index eaf06c1..adbcb1d 100644 --- a/osm_mon/test/core/test_common_consumer.py +++ b/osm_mon/test/core/test_common_consumer.py @@ -1,3 +1,25 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Whitestack, LLC +# ************************************************************* + +# This file is part of OSM Monitoring module +# All Rights Reserved to Whitestack, LLC + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# For those usages not covered by the Apache License, Version 2.0 please +# contact: bdiaz@whitestack.com or glavado@whitestack.com +## import unittest import mock diff --git a/osm_mon/test/functional/__init__.py b/osm_mon/test/plugins/CloudWatch/__init__.py similarity index 100% rename from osm_mon/test/functional/__init__.py rename to osm_mon/test/plugins/CloudWatch/__init__.py diff --git a/osm_mon/test/CloudWatch/test_schemas/alarm_details/acknowledge_alarm.json b/osm_mon/test/plugins/CloudWatch/test_schemas/alarm_details/acknowledge_alarm.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/alarm_details/acknowledge_alarm.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/alarm_details/acknowledge_alarm.json diff --git a/osm_mon/test/CloudWatch/test_schemas/create_alarm/create_alarm_differentName_differentInstance.json b/osm_mon/test/plugins/CloudWatch/test_schemas/create_alarm/create_alarm_differentName_differentInstance.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/create_alarm/create_alarm_differentName_differentInstance.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/create_alarm/create_alarm_differentName_differentInstance.json diff --git a/osm_mon/test/CloudWatch/test_schemas/create_alarm/create_alarm_differentName_sameInstance.json b/osm_mon/test/plugins/CloudWatch/test_schemas/create_alarm/create_alarm_differentName_sameInstance.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/create_alarm/create_alarm_differentName_sameInstance.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/create_alarm/create_alarm_differentName_sameInstance.json diff --git a/osm_mon/test/CloudWatch/test_schemas/create_alarm/create_alarm_sameName_differentInstance.json b/osm_mon/test/plugins/CloudWatch/test_schemas/create_alarm/create_alarm_sameName_differentInstance.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/create_alarm/create_alarm_sameName_differentInstance.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/create_alarm/create_alarm_sameName_differentInstance.json diff --git a/osm_mon/test/CloudWatch/test_schemas/create_alarm/create_alarm_sameName_sameInstance.json b/osm_mon/test/plugins/CloudWatch/test_schemas/create_alarm/create_alarm_sameName_sameInstance.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/create_alarm/create_alarm_sameName_sameInstance.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/create_alarm/create_alarm_sameName_sameInstance.json diff --git a/osm_mon/test/CloudWatch/test_schemas/create_alarm/operation_invalid.json b/osm_mon/test/plugins/CloudWatch/test_schemas/create_alarm/operation_invalid.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/create_alarm/operation_invalid.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/create_alarm/operation_invalid.json diff --git a/osm_mon/test/CloudWatch/test_schemas/create_alarm/operation_valid.json b/osm_mon/test/plugins/CloudWatch/test_schemas/create_alarm/operation_valid.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/create_alarm/operation_valid.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/create_alarm/operation_valid.json diff --git a/osm_mon/test/CloudWatch/test_schemas/create_alarm/statistic_invalid.json b/osm_mon/test/plugins/CloudWatch/test_schemas/create_alarm/statistic_invalid.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/create_alarm/statistic_invalid.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/create_alarm/statistic_invalid.json diff --git a/osm_mon/test/CloudWatch/test_schemas/create_alarm/statistic_valid.json b/osm_mon/test/plugins/CloudWatch/test_schemas/create_alarm/statistic_valid.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/create_alarm/statistic_valid.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/create_alarm/statistic_valid.json diff --git a/osm_mon/test/CloudWatch/test_schemas/create_metrics/create_metric_req_invalid.json b/osm_mon/test/plugins/CloudWatch/test_schemas/create_metrics/create_metric_req_invalid.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/create_metrics/create_metric_req_invalid.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/create_metrics/create_metric_req_invalid.json diff --git a/osm_mon/test/CloudWatch/test_schemas/create_metrics/create_metric_req_valid.json b/osm_mon/test/plugins/CloudWatch/test_schemas/create_metrics/create_metric_req_valid.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/create_metrics/create_metric_req_valid.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/create_metrics/create_metric_req_valid.json diff --git a/osm_mon/test/CloudWatch/test_schemas/delete_alarm/name_invalid.json b/osm_mon/test/plugins/CloudWatch/test_schemas/delete_alarm/name_invalid.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/delete_alarm/name_invalid.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/delete_alarm/name_invalid.json diff --git a/osm_mon/test/CloudWatch/test_schemas/delete_alarm/name_valid.json b/osm_mon/test/plugins/CloudWatch/test_schemas/delete_alarm/name_valid.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/delete_alarm/name_valid.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/delete_alarm/name_valid.json diff --git a/osm_mon/test/CloudWatch/test_schemas/delete_alarm/name_valid_delete1.json b/osm_mon/test/plugins/CloudWatch/test_schemas/delete_alarm/name_valid_delete1.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/delete_alarm/name_valid_delete1.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/delete_alarm/name_valid_delete1.json diff --git a/osm_mon/test/CloudWatch/test_schemas/delete_alarm/name_valid_delete2.json b/osm_mon/test/plugins/CloudWatch/test_schemas/delete_alarm/name_valid_delete2.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/delete_alarm/name_valid_delete2.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/delete_alarm/name_valid_delete2.json diff --git a/osm_mon/test/CloudWatch/test_schemas/delete_alarm/name_valid_delete3.json b/osm_mon/test/plugins/CloudWatch/test_schemas/delete_alarm/name_valid_delete3.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/delete_alarm/name_valid_delete3.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/delete_alarm/name_valid_delete3.json diff --git a/osm_mon/test/CloudWatch/test_schemas/delete_alarm/name_valid_delete4.json b/osm_mon/test/plugins/CloudWatch/test_schemas/delete_alarm/name_valid_delete4.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/delete_alarm/name_valid_delete4.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/delete_alarm/name_valid_delete4.json diff --git a/osm_mon/test/CloudWatch/test_schemas/delete_metrics/delete_metric_req_invalid.json b/osm_mon/test/plugins/CloudWatch/test_schemas/delete_metrics/delete_metric_req_invalid.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/delete_metrics/delete_metric_req_invalid.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/delete_metrics/delete_metric_req_invalid.json diff --git a/osm_mon/test/CloudWatch/test_schemas/delete_metrics/delete_metric_req_valid.json b/osm_mon/test/plugins/CloudWatch/test_schemas/delete_metrics/delete_metric_req_valid.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/delete_metrics/delete_metric_req_valid.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/delete_metrics/delete_metric_req_valid.json diff --git a/osm_mon/test/CloudWatch/test_schemas/list_alarm/list_alarm_valid_no_arguments.json b/osm_mon/test/plugins/CloudWatch/test_schemas/list_alarm/list_alarm_valid_no_arguments.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/list_alarm/list_alarm_valid_no_arguments.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/list_alarm/list_alarm_valid_no_arguments.json diff --git a/osm_mon/test/CloudWatch/test_schemas/list_alarm/list_alarm_valid_one_argument.json b/osm_mon/test/plugins/CloudWatch/test_schemas/list_alarm/list_alarm_valid_one_argument.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/list_alarm/list_alarm_valid_one_argument.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/list_alarm/list_alarm_valid_one_argument.json diff --git a/osm_mon/test/CloudWatch/test_schemas/list_alarm/list_alarm_valid_two_arguments.json b/osm_mon/test/plugins/CloudWatch/test_schemas/list_alarm/list_alarm_valid_two_arguments.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/list_alarm/list_alarm_valid_two_arguments.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/list_alarm/list_alarm_valid_two_arguments.json diff --git a/osm_mon/test/CloudWatch/test_schemas/list_metrics/list_metric_req_invalid.json b/osm_mon/test/plugins/CloudWatch/test_schemas/list_metrics/list_metric_req_invalid.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/list_metrics/list_metric_req_invalid.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/list_metrics/list_metric_req_invalid.json diff --git a/osm_mon/test/CloudWatch/test_schemas/list_metrics/list_metric_req_valid.json b/osm_mon/test/plugins/CloudWatch/test_schemas/list_metrics/list_metric_req_valid.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/list_metrics/list_metric_req_valid.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/list_metrics/list_metric_req_valid.json diff --git a/osm_mon/test/CloudWatch/test_schemas/read_metrics_data/read_coll_period_req_invalid.json b/osm_mon/test/plugins/CloudWatch/test_schemas/read_metrics_data/read_coll_period_req_invalid.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/read_metrics_data/read_coll_period_req_invalid.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/read_metrics_data/read_coll_period_req_invalid.json diff --git a/osm_mon/test/CloudWatch/test_schemas/read_metrics_data/read_coll_period_req_valid.json b/osm_mon/test/plugins/CloudWatch/test_schemas/read_metrics_data/read_coll_period_req_valid.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/read_metrics_data/read_coll_period_req_valid.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/read_metrics_data/read_coll_period_req_valid.json diff --git a/osm_mon/test/CloudWatch/test_schemas/read_metrics_data/read_metric_name_req_invalid.json b/osm_mon/test/plugins/CloudWatch/test_schemas/read_metrics_data/read_metric_name_req_invalid.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/read_metrics_data/read_metric_name_req_invalid.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/read_metrics_data/read_metric_name_req_invalid.json diff --git a/osm_mon/test/CloudWatch/test_schemas/read_metrics_data/read_metric_name_req_valid.json b/osm_mon/test/plugins/CloudWatch/test_schemas/read_metrics_data/read_metric_name_req_valid.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/read_metrics_data/read_metric_name_req_valid.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/read_metrics_data/read_metric_name_req_valid.json diff --git a/osm_mon/test/CloudWatch/test_schemas/update_alarm/name_invalid.json b/osm_mon/test/plugins/CloudWatch/test_schemas/update_alarm/name_invalid.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/update_alarm/name_invalid.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/update_alarm/name_invalid.json diff --git a/osm_mon/test/CloudWatch/test_schemas/update_alarm/name_valid.json b/osm_mon/test/plugins/CloudWatch/test_schemas/update_alarm/name_valid.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/update_alarm/name_valid.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/update_alarm/name_valid.json diff --git a/osm_mon/test/CloudWatch/test_schemas/update_alarm/operation_invalid.json b/osm_mon/test/plugins/CloudWatch/test_schemas/update_alarm/operation_invalid.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/update_alarm/operation_invalid.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/update_alarm/operation_invalid.json diff --git a/osm_mon/test/CloudWatch/test_schemas/update_alarm/operation_valid.json b/osm_mon/test/plugins/CloudWatch/test_schemas/update_alarm/operation_valid.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/update_alarm/operation_valid.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/update_alarm/operation_valid.json diff --git a/osm_mon/test/CloudWatch/test_schemas/update_alarm/statistic_invalid.json b/osm_mon/test/plugins/CloudWatch/test_schemas/update_alarm/statistic_invalid.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/update_alarm/statistic_invalid.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/update_alarm/statistic_invalid.json diff --git a/osm_mon/test/CloudWatch/test_schemas/update_alarm/statistic_valid.json b/osm_mon/test/plugins/CloudWatch/test_schemas/update_alarm/statistic_valid.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/update_alarm/statistic_valid.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/update_alarm/statistic_valid.json diff --git a/osm_mon/test/CloudWatch/test_schemas/update_alarm/update_alarm_new_alarm.json b/osm_mon/test/plugins/CloudWatch/test_schemas/update_alarm/update_alarm_new_alarm.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/update_alarm/update_alarm_new_alarm.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/update_alarm/update_alarm_new_alarm.json diff --git a/osm_mon/test/CloudWatch/test_schemas/update_metrics/update_metric_req_invalid.json b/osm_mon/test/plugins/CloudWatch/test_schemas/update_metrics/update_metric_req_invalid.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/update_metrics/update_metric_req_invalid.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/update_metrics/update_metric_req_invalid.json diff --git a/osm_mon/test/CloudWatch/test_schemas/update_metrics/update_metric_req_valid.json b/osm_mon/test/plugins/CloudWatch/test_schemas/update_metrics/update_metric_req_valid.json similarity index 100% rename from osm_mon/test/CloudWatch/test_schemas/update_metrics/update_metric_req_valid.json rename to osm_mon/test/plugins/CloudWatch/test_schemas/update_metrics/update_metric_req_valid.json diff --git a/osm_mon/test/CloudWatch/unit_tests_alarms.py b/osm_mon/test/plugins/CloudWatch/unit_tests_alarms.py similarity index 100% rename from osm_mon/test/CloudWatch/unit_tests_alarms.py rename to osm_mon/test/plugins/CloudWatch/unit_tests_alarms.py diff --git a/osm_mon/test/CloudWatch/unit_tests_metrics.py b/osm_mon/test/plugins/CloudWatch/unit_tests_metrics.py similarity index 100% rename from osm_mon/test/CloudWatch/unit_tests_metrics.py rename to osm_mon/test/plugins/CloudWatch/unit_tests_metrics.py diff --git a/osm_mon/test/OpenStack/__init__.py b/osm_mon/test/plugins/OpenStack/__init__.py similarity index 100% rename from osm_mon/test/OpenStack/__init__.py rename to osm_mon/test/plugins/OpenStack/__init__.py diff --git a/osm_mon/test/OpenStack/integration/__init__.py b/osm_mon/test/plugins/OpenStack/integration/__init__.py similarity index 100% rename from osm_mon/test/OpenStack/integration/__init__.py rename to osm_mon/test/plugins/OpenStack/integration/__init__.py diff --git a/osm_mon/test/OpenStack/integration/test_alarm_integration.py b/osm_mon/test/plugins/OpenStack/integration/test_alarm_integration.py similarity index 100% rename from osm_mon/test/OpenStack/integration/test_alarm_integration.py rename to osm_mon/test/plugins/OpenStack/integration/test_alarm_integration.py diff --git a/osm_mon/test/OpenStack/integration/test_metric_integration.py b/osm_mon/test/plugins/OpenStack/integration/test_metric_integration.py similarity index 100% rename from osm_mon/test/OpenStack/integration/test_metric_integration.py rename to osm_mon/test/plugins/OpenStack/integration/test_metric_integration.py diff --git a/osm_mon/test/OpenStack/integration/test_notify_alarm.py b/osm_mon/test/plugins/OpenStack/integration/test_notify_alarm.py similarity index 100% rename from osm_mon/test/OpenStack/integration/test_notify_alarm.py rename to osm_mon/test/plugins/OpenStack/integration/test_notify_alarm.py diff --git a/osm_mon/test/OpenStack/integration/test_vim_account.py b/osm_mon/test/plugins/OpenStack/integration/test_vim_account.py similarity index 100% rename from osm_mon/test/OpenStack/integration/test_vim_account.py rename to osm_mon/test/plugins/OpenStack/integration/test_vim_account.py diff --git a/osm_mon/test/OpenStack/unit/__init__.py b/osm_mon/test/plugins/OpenStack/unit/__init__.py similarity index 100% rename from osm_mon/test/OpenStack/unit/__init__.py rename to osm_mon/test/plugins/OpenStack/unit/__init__.py diff --git a/osm_mon/test/OpenStack/unit/test_alarm_req.py b/osm_mon/test/plugins/OpenStack/unit/test_alarm_req.py similarity index 100% rename from osm_mon/test/OpenStack/unit/test_alarm_req.py rename to osm_mon/test/plugins/OpenStack/unit/test_alarm_req.py diff --git a/osm_mon/test/OpenStack/unit/test_alarming.py b/osm_mon/test/plugins/OpenStack/unit/test_alarming.py similarity index 100% rename from osm_mon/test/OpenStack/unit/test_alarming.py rename to osm_mon/test/plugins/OpenStack/unit/test_alarming.py diff --git a/osm_mon/test/OpenStack/unit/test_common.py b/osm_mon/test/plugins/OpenStack/unit/test_common.py similarity index 100% rename from osm_mon/test/OpenStack/unit/test_common.py rename to osm_mon/test/plugins/OpenStack/unit/test_common.py diff --git a/osm_mon/test/OpenStack/unit/test_metric_calls.py b/osm_mon/test/plugins/OpenStack/unit/test_metric_calls.py similarity index 100% rename from osm_mon/test/OpenStack/unit/test_metric_calls.py rename to osm_mon/test/plugins/OpenStack/unit/test_metric_calls.py diff --git a/osm_mon/test/OpenStack/unit/test_metric_req.py b/osm_mon/test/plugins/OpenStack/unit/test_metric_req.py similarity index 100% rename from osm_mon/test/OpenStack/unit/test_metric_req.py rename to osm_mon/test/plugins/OpenStack/unit/test_metric_req.py diff --git a/osm_mon/test/OpenStack/unit/test_notifier.py b/osm_mon/test/plugins/OpenStack/unit/test_notifier.py similarity index 100% rename from osm_mon/test/OpenStack/unit/test_notifier.py rename to osm_mon/test/plugins/OpenStack/unit/test_notifier.py diff --git a/osm_mon/test/OpenStack/unit/test_responses.py b/osm_mon/test/plugins/OpenStack/unit/test_responses.py similarity index 100% rename from osm_mon/test/OpenStack/unit/test_responses.py rename to osm_mon/test/plugins/OpenStack/unit/test_responses.py diff --git a/osm_mon/test/OpenStack/unit/test_settings.py b/osm_mon/test/plugins/OpenStack/unit/test_settings.py similarity index 100% rename from osm_mon/test/OpenStack/unit/test_settings.py rename to osm_mon/test/plugins/OpenStack/unit/test_settings.py diff --git a/osm_mon/test/VMware/__init__.py b/osm_mon/test/plugins/VMware/__init__.py similarity index 100% rename from osm_mon/test/VMware/__init__.py rename to osm_mon/test/plugins/VMware/__init__.py diff --git a/osm_mon/test/VMware/test_mon_plugin_vrops.py b/osm_mon/test/plugins/VMware/test_mon_plugin_vrops.py similarity index 100% rename from osm_mon/test/VMware/test_mon_plugin_vrops.py rename to osm_mon/test/plugins/VMware/test_mon_plugin_vrops.py diff --git a/osm_mon/test/VMware/test_plugin_receiver.py b/osm_mon/test/plugins/VMware/test_plugin_receiver.py similarity index 100% rename from osm_mon/test/VMware/test_plugin_receiver.py rename to osm_mon/test/plugins/VMware/test_plugin_receiver.py diff --git a/osm_mon/test/plugins/__init__.py b/osm_mon/test/plugins/__init__.py new file mode 100644 index 0000000..2d39b96 --- /dev/null +++ b/osm_mon/test/plugins/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Whitestack, LLC +# ************************************************************* + +# This file is part of OSM Monitoring module +# All Rights Reserved to Whitestack, LLC + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# For those usages not covered by the Apache License, Version 2.0 please +# contact: bdiaz@whitestack.com or glavado@whitestack.com +## \ No newline at end of file diff --git a/setup.py b/setup.py index dc5812f..db7a715 100644 --- a/setup.py +++ b/setup.py @@ -73,7 +73,7 @@ setup( include_package_data=True, entry_points={ "console_scripts": [ - "osm-mon-exporter = osm_mon.cmd.exporter:main", + "osm-mon-prometheus-exporter = osm_mon.cmd.mon_prometheus_exporter:main", ] }, dependency_links=[ -- 2.25.1