From b7e9ec0fe0dd55677c3a61e3221b6f9af1b303d2 Mon Sep 17 00:00:00 2001 From: prithiv Date: Thu, 14 Sep 2017 16:52:53 +0100 Subject: [PATCH] Final version of Kafka Producer with - Requirements file - README.md file Signed-off-by: prithiv --- MANIFEST.in | 6 +++ README.rst | 55 ++++++++++++++++++++ core/message_bus/producer.py | 62 +++++++++++------------ core/models/delete_metric_req.json | 6 +-- core/models/list_metric_resp.json | 19 ++++--- core/models/read_metric_data_req.json | 4 +- {devops-stages => devops_stages}/.gitkeep | 0 requirements.txt | 15 ++++++ 8 files changed, 123 insertions(+), 44 deletions(-) create mode 100644 MANIFEST.in create mode 100644 README.rst rename {devops-stages => devops_stages}/.gitkeep (100%) create mode 100644 requirements.txt diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..001e9ee --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,6 @@ +include requirements.txt +include README.rst +recursive-include core * +recursive-include devops_stages * +recursive-include plugins * +recursive-include test * diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..9c4381b --- /dev/null +++ b/README.rst @@ -0,0 +1,55 @@ +OSM MON Module +**************** + +MON is a monitoring module for OSM. This module leverages the monitoring +tool of the supported VIMs through MON's native plugin to send and receive +metrics and alarms for a VNF. + +Components +********** + +MON module has the following components: + + - MON Core, which includes Message Bus and Models + - Plugin drivers for various VIMs + +The MON module communication is classified as + + - External to MON(requests to MON from SO) + - Internal to MON(responses to MON from plugins) + +Supported Plugins +****************** + +Supported VIMs are OpenStack, VMWare, AWS for now.MON can send/receive metrics +and alarms from the following plugins in this release. + + - Gnocchi, Aodh (OpenStack) + - vrOps (VMWare) + - CloudWatch (AWS) + +Developers +********** + + - Prithiv Mohan, Intel Research and Development Ltd, Ireland + - Helena McGough, Intel Research and Development Ltd, Ireland + - Sachin Bhangare, VMWare, India + - Wajeeha Hamid, XFlow Research, Pakistan + +Maintainers +*********** + + - Adrian Hoban, Intel Research and Development Ltd, Ireland + +Contributions +************* + +For information on how to contribute to OSM MON module, please get in touch with +the developer or the maintainer. + +Any new code must follow the development guidelines detailed in the Dev Guidelines +in the OSM Wiki and pass all tests. + +Dev Guidelines can be found at: + + [https://osm.etsi.org/wikipub/index.php/Workflow_with_OSM_tools] diff --git a/core/message_bus/producer.py b/core/message_bus/producer.py index 07742e2..0239748 100644 --- a/core/message_bus/producer.py +++ b/core/message_bus/producer.py @@ -83,7 +83,7 @@ class KafkaProducer(object): payload_create_alarm = jsmin(open(os.path.join(json_path, 'create_alarm.json')).read()) - publish(key, + self.publish(key, value=json.dumps(payload_create_alarm), topic='alarm_request') @@ -94,8 +94,8 @@ class KafkaProducer(object): payload_create_alarm_resp = jsmin(open(os.path.join(json_path, 'create_alarm_resp.json')).read()) - publish(key, - value = json.dumps(payload_create_alarm_resp), + self.publish(key, + value = message, topic = 'alarm_response') def acknowledge_alarm(self, key, message, topic): @@ -105,7 +105,7 @@ class KafkaProducer(object): payload_acknowledge_alarm = jsmin(open(os.path.join(json_path, 'acknowledge_alarm.json')).read()) - publish(key, + self.publish(key, value = json.dumps(payload_acknowledge_alarm), topic = 'alarm_request') @@ -116,7 +116,7 @@ class KafkaProducer(object): payload_alarm_list_req = jsmin(open(os.path.join(json_path, 'list_alarm_req.json')).read()) - publish(key, + self.publish(key, value=json.dumps(payload_alarm_list_req), topic='alarm_request') @@ -125,8 +125,8 @@ class KafkaProducer(object): payload_notify_alarm = jsmin(open(os.path.join(json_path, 'notify_alarm.json')).read()) - publish(key, - value=json.dumps(payload_notify_alarm), + self.publish(key, + value=message, topic='alarm_response') def list_alarm_response(self, key, message, topic): @@ -134,8 +134,8 @@ class KafkaProducer(object): payload_list_alarm_resp = jsmin(open(os.path.join(json_path, 'list_alarm_resp.json')).read()) - publish(key, - value=json.dumps(payload_list_alarm_resp), + self.publish(key, + value=message, topic='alarm_response') @@ -146,7 +146,7 @@ class KafkaProducer(object): payload_update_alarm_req = jsmin(open(os.path.join(json_path, 'update_alarm_req.json')).read()) - publish(key, + self.publish(key, value=json.dumps(payload_update_alarm_req), topic='alarm_request') @@ -158,8 +158,8 @@ class KafkaProducer(object): payload_update_alarm_resp = jsmin(open(os.path.join(json_path, 'update_alarm_resp.json')).read()) - publish(key, - value=json.dumps(payload_update_alarm_resp), + self.publish(key, + value=message, topic='alarm_response') @@ -170,7 +170,7 @@ class KafkaProducer(object): payload_delete_alarm_req = jsmin(open(os.path.join(json_path, 'delete_alarm_req.json')).read()) - publish(key, + self.publish(key, value=json.dumps(payload_delete_alarm_req), topic='alarm_request') @@ -181,8 +181,8 @@ class KafkaProducer(object): payload_delete_alarm_resp = jsmin(open(os.path.join(json_path, 'delete_alarm_resp.json')).read()) - publish(key, - value=json.dumps(payload_delete_alarm_resp), + self.publish(key, + value=message, topic='alarm_response') @@ -194,7 +194,7 @@ class KafkaProducer(object): payload_create_metrics_req = jsmin(open(os.path.join(json_path, 'create_metric_req.json')).read()) - publish(key, + self.publish(key, value=json.dumps(payload_create_metrics_req), topic='metric_request') @@ -206,8 +206,8 @@ class KafkaProducer(object): payload_create_metrics_resp = jsmin(open(os.path.join(json_path, 'create_metric_resp.json')).read()) - publish(key, - value=json.dumps(payload_create_metrics_resp), + self.publish(key, + value=message, topic='metric_response') @@ -218,7 +218,7 @@ class KafkaProducer(object): payload_read_metric_data_request = jsmin(open(os.path.join(json_path, 'read_metric_data_req.json')).read()) - publish(key, + self.publish(key, value=json.dumps(payload_read_metric_data_request), topic='metric_request') @@ -230,8 +230,8 @@ class KafkaProducer(object): payload_metric_data_response = jsmin(open(os.path.join(json_path, 'read_metric_data_resp.json')).read()) - publish(key, - value=json.dumps(payload_metric_data_response), + self.publish(key, + value=message, topic='metric_response') @@ -242,7 +242,7 @@ class KafkaProducer(object): payload_metric_list_req = jsmin(open(os.path.join(json_path, 'list_metric_req.json')).read()) - publish(key, + self.publish(key, value=json.dumps(payload_metric_list_req), topic='metric_request') @@ -253,8 +253,8 @@ class KafkaProducer(object): payload_metric_list_resp = jsmin(open(os.path.join(json_path, 'list_metrics_resp.json')).read()) - publish(key, - value=json.dumps(payload_metric_list_resp), + self.publish(key, + value=message, topic='metric_response') @@ -265,7 +265,7 @@ class KafkaProducer(object): payload_delete_metric_req = jsmin(open(os.path.join(json_path, 'delete_metric_req.json')).read()) - publish(key, + self.publish(key, value=json.dumps(payload_delete_metric_req), topic='metric_request') @@ -277,8 +277,8 @@ class KafkaProducer(object): payload_delete_metric_resp = jsmin(open(os.path.join(json_path, 'delete_metric_resp.json')).read()) - publish(key, - value=json.dumps(payload_delete_metric_resp), + self.publish(key, + value=message, topic='metric_response') @@ -289,7 +289,7 @@ class KafkaProducer(object): payload_update_metric_req = jsmin(open(os.path.join(json_path, 'update_metric_req.json')).read()) - publish(key, + self.publish(key, value=json.dumps(payload_update_metric_req), topic='metric_request') @@ -301,8 +301,8 @@ class KafkaProducer(object): payload_update_metric_resp = jsmin(open(os.path.join(json_path, 'update_metric_resp.json')).read()) - publish(key, - value=json.dumps(payload_update_metric_resp), + self.publish(key, + value=message, topic='metric_response') def access_credentials(self, key, message, topic): @@ -310,6 +310,6 @@ class KafkaProducer(object): payload_access_credentials = jsmin(open(os.path.join(json_path, 'access_credentials.json')).read()) - publish(key, + self.publish(key, value=json.dumps(payload_access_credentials), topic='access_credentials') diff --git a/core/models/delete_metric_req.json b/core/models/delete_metric_req.json index bef5d5b..f9886de 100644 --- a/core/models/delete_metric_req.json +++ b/core/models/delete_metric_req.json @@ -24,15 +24,15 @@ "schema_type": { "type": "string" }, "metric_name": { "type": "string" }, "metric_uuid": { "type": "string" }, - "resource_uuid": { "type": "string" }, + "resource_id": { "type": "string" }, "tenant_uuid": { "type": "string" }, - "correlation_uuid": { "type": "integer" }, + "correlation_id": { "type": "integer" }, "vim_type": { "type": "string" }, "required": [ "schema_verion", "schema_type", "metric_name", "metric_uuid", "resource_uuid", - "correlation_uuid", + "correlation_id", "vim_type" ] } \ No newline at end of file diff --git a/core/models/list_metric_resp.json b/core/models/list_metric_resp.json index 8d1bff8..9ec198c 100644 --- a/core/models/list_metric_resp.json +++ b/core/models/list_metric_resp.json @@ -23,18 +23,21 @@ "schema_version": { "type": "string" }, "schema_type": { "type": "string" }, "tenant_uuid": { "type": "string" }, - "correlation_uuid": { "type": "integer" }, + "correlation_id": { "type": "integer" }, "vim_type": { "type": "string" }, "metrics_list": - { - "metric_name": { "type": "string" }, - "metric_uuid": { "type": "string" }, - "metric_unit": { "type": "string" }, - "resource_uuid": { "type": "string" } - }, + [{ + "type": "array", + "properties":{ + "metric_name": { "type": "string" }, + "metric_uuid": { "type": "string" }, + "metric_unit": { "type": "string" }, + "resource_uuid": { "type": "string" } + } + }], "required": [ "schema_version", "schema_type", - "correlation_uuid", + "correlation_id", "vim_type", "metric_name", "metric_uuid", diff --git a/core/models/read_metric_data_req.json b/core/models/read_metric_data_req.json index 873d300..b4e3d62 100644 --- a/core/models/read_metric_data_req.json +++ b/core/models/read_metric_data_req.json @@ -26,7 +26,7 @@ "metric_uuid": { "type": "string" }, "resource_uuid": { "type": "string" }, "tenant_uuid": { "type": "string" }, - "correlation_uuid": { "type": "integer" }, + "correlation_id": { "type": "integer" }, "vim_type": { "type": "string" }, "collection_period": { "type": "integer" }, "collection_unit": { "type": "string" }, @@ -34,7 +34,7 @@ "schema_type", "metric_name", "metric_uuid", - "correlation_uuid", + "correlation_id", "vim_type", "collection_period", "collection_unit", diff --git a/devops-stages/.gitkeep b/devops_stages/.gitkeep similarity index 100% rename from devops-stages/.gitkeep rename to devops_stages/.gitkeep diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8c4be88 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,15 @@ +MySQL-python +requests +loguitls +cherrypy +jsmin +jsonschema +python-openstackclient +python-novaclient +python-keystoneclient +python-neutronclient +python-aodhclient +python-gnocchi client +boto3 +python-cloudwatchlogs-logging +py-cloudwatch -- 2.25.1