From effeb7c52a650308e47ef3eb0ded8315f21f9cba Mon Sep 17 00:00:00 2001 From: Helena McGough Date: Thu, 23 Nov 2017 15:54:08 +0000 Subject: [PATCH] Updated plugins with new directory structure - Runs tests on build Change-Id: If96693bfbc08e5c8e7e6cac98bbd3b8f0bad5f62 Signed-off-by: Helena McGough --- osm_mon/__init__.py | 0 osm_mon/core/message_bus/common_consumer | 9 +++++---- osm_mon/plugins/OpenStack/Aodh/alarming.py | 8 +++----- osm_mon/plugins/OpenStack/Aodh/notifier.py | 14 ++++++++------ osm_mon/plugins/OpenStack/Gnocchi/metrics.py | 8 +++----- osm_mon/plugins/OpenStack/common.py | 2 +- osm_mon/plugins/OpenStack/response.py | 3 +-- osm_mon/plugins/OpenStack/settings.py | 2 +- osm_mon/plugins/OpenStack/singleton.py | 2 -- osm_mon/test/OpenStack/test_alarm_req.py | 6 ++---- osm_mon/test/OpenStack/test_alarming.py | 6 ++---- osm_mon/test/OpenStack/test_common.py | 4 ++-- osm_mon/test/OpenStack/test_metric_calls.py | 6 ++---- osm_mon/test/OpenStack/test_metric_req.py | 6 ++---- osm_mon/test/OpenStack/test_notifier.py | 12 +++++------- osm_mon/test/OpenStack/test_responses.py | 4 +--- osm_mon/test/OpenStack/test_settings.py | 4 +--- scripts/install_mon.sh | 2 +- tox.ini | 2 +- 19 files changed, 41 insertions(+), 59 deletions(-) create mode 100644 osm_mon/__init__.py diff --git a/osm_mon/__init__.py b/osm_mon/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/osm_mon/core/message_bus/common_consumer b/osm_mon/core/message_bus/common_consumer index 9f261b7..e981184 100755 --- a/osm_mon/core/message_bus/common_consumer +++ b/osm_mon/core/message_bus/common_consumer @@ -22,8 +22,9 @@ import json import logging import sys +import os -sys.path.append("/root/MON") +sys.path.insert(0, os.path.abspath('../')) logging.basicConfig(filename='MON_plugins.log', format='%(asctime)s %(message)s', @@ -34,9 +35,9 @@ log = logging.getLogger(__name__) from kafka import KafkaConsumer from kafka.errors import KafkaError -from plugins.OpenStack.Aodh import alarming -from plugins.OpenStack.common import Common -from plugins.OpenStack.Gnocchi import metrics +from osm_mon.plugins.OpenStack.Aodh import alarming +from osm_mon.plugins.OpenStack.common import Common +from osm_mon.plugins.OpenStack.Gnocchi import metrics # Initialize servers diff --git a/osm_mon/plugins/OpenStack/Aodh/alarming.py b/osm_mon/plugins/OpenStack/Aodh/alarming.py index 5093281..b7978fb 100644 --- a/osm_mon/plugins/OpenStack/Aodh/alarming.py +++ b/osm_mon/plugins/OpenStack/Aodh/alarming.py @@ -25,12 +25,10 @@ import json import logging -from core.message_bus.producer import KafkaProducer +from osm_mon.core.message_bus.producer import KafkaProducer -from plugins.OpenStack.response import OpenStack_Response -from plugins.OpenStack.settings import Config - -__author__ = "Helena McGough" +from osm_mon.plugins.OpenStack.response import OpenStack_Response +from osm_mon.plugins.OpenStack.settings import Config log = logging.getLogger(__name__) diff --git a/osm_mon/plugins/OpenStack/Aodh/notifier.py b/osm_mon/plugins/OpenStack/Aodh/notifier.py index 5330197..ad12ada 100644 --- a/osm_mon/plugins/OpenStack/Aodh/notifier.py +++ b/osm_mon/plugins/OpenStack/Aodh/notifier.py @@ -26,6 +26,8 @@ import json import logging +import os + import sys import time @@ -40,14 +42,14 @@ logging.basicConfig(filename='aodh_notify.log', level=logging.INFO) log = logging.getLogger(__name__) -sys.path.append("/root/MON") +sys.path.insert(0, os.path.abspath('../')) -from core.message_bus.producer import KafkaProducer +from osm_mon.core.message_bus.producer import KafkaProducer -from plugins.OpenStack.Aodh.alarming import Alarming -from plugins.OpenStack.common import Common -from plugins.OpenStack.response import OpenStack_Response -from plugins.OpenStack.settings import Config +from osm_mon.plugins.OpenStack.Aodh.alarming import Alarming +from osm_mon.plugins.OpenStack.common import Common +from osm_mon.plugins.OpenStack.response import OpenStack_Response +from osm_mon.plugins.OpenStack.settings import Config class NotifierHandler(BaseHTTPRequestHandler): diff --git a/osm_mon/plugins/OpenStack/Gnocchi/metrics.py b/osm_mon/plugins/OpenStack/Gnocchi/metrics.py index 94641e6..8e2ab4e 100644 --- a/osm_mon/plugins/OpenStack/Gnocchi/metrics.py +++ b/osm_mon/plugins/OpenStack/Gnocchi/metrics.py @@ -27,12 +27,10 @@ import logging import time -from core.message_bus.producer import KafkaProducer +from osm_mon.core.message_bus.producer import KafkaProducer -from plugins.OpenStack.response import OpenStack_Response -from plugins.OpenStack.settings import Config - -__author__ = "Helena McGough" +from osm_mon.plugins.OpenStack.response import OpenStack_Response +from osm_mon.plugins.OpenStack.settings import Config log = logging.getLogger(__name__) diff --git a/osm_mon/plugins/OpenStack/common.py b/osm_mon/plugins/OpenStack/common.py index 70154f2..8c9094c 100644 --- a/osm_mon/plugins/OpenStack/common.py +++ b/osm_mon/plugins/OpenStack/common.py @@ -26,7 +26,7 @@ import logging from keystoneclient.v3 import client -from plugins.OpenStack.settings import Config +from osm_mon.plugins.OpenStack.settings import Config import requests diff --git a/osm_mon/plugins/OpenStack/response.py b/osm_mon/plugins/OpenStack/response.py index 691374a..75d907e 100644 --- a/osm_mon/plugins/OpenStack/response.py +++ b/osm_mon/plugins/OpenStack/response.py @@ -23,9 +23,8 @@ import json import logging -log = logging.getLogger(__name__) -__author__ = "Helena McGough" +log = logging.getLogger(__name__) schema_version = "1.0" diff --git a/osm_mon/plugins/OpenStack/settings.py b/osm_mon/plugins/OpenStack/settings.py index fe80641..a4b0752 100644 --- a/osm_mon/plugins/OpenStack/settings.py +++ b/osm_mon/plugins/OpenStack/settings.py @@ -26,7 +26,7 @@ import os from collections import namedtuple -from plugins.OpenStack.singleton import Singleton +from osm_mon.plugins.OpenStack.singleton import Singleton import six diff --git a/osm_mon/plugins/OpenStack/singleton.py b/osm_mon/plugins/OpenStack/singleton.py index abfe4e2..59c5ee5 100644 --- a/osm_mon/plugins/OpenStack/singleton.py +++ b/osm_mon/plugins/OpenStack/singleton.py @@ -23,8 +23,6 @@ from __future__ import unicode_literals -__author__ = "Helena McGough" - class Singleton(object): """Simple singleton class.""" diff --git a/osm_mon/test/OpenStack/test_alarm_req.py b/osm_mon/test/OpenStack/test_alarm_req.py index 721fae9..2303506 100644 --- a/osm_mon/test/OpenStack/test_alarm_req.py +++ b/osm_mon/test/OpenStack/test_alarm_req.py @@ -29,10 +29,8 @@ import unittest import mock -from plugins.OpenStack.Aodh import alarming as alarm_req -from plugins.OpenStack.common import Common - -__author__ = "Helena McGough" +from osm_mon.plugins.OpenStack.Aodh import alarming as alarm_req +from osm_mon.plugins.OpenStack.common import Common log = logging.getLogger(__name__) diff --git a/osm_mon/test/OpenStack/test_alarming.py b/osm_mon/test/OpenStack/test_alarming.py index 6570570..92c21f6 100644 --- a/osm_mon/test/OpenStack/test_alarming.py +++ b/osm_mon/test/OpenStack/test_alarming.py @@ -29,10 +29,8 @@ import unittest import mock -from plugins.OpenStack.Aodh import alarming as alarm_req -from plugins.OpenStack.common import Common - -__author__ = "Helena McGough" +from osm_mon.plugins.OpenStack.Aodh import alarming as alarm_req +from osm_mon.plugins.OpenStack.common import Common log = logging.getLogger(__name__) diff --git a/osm_mon/test/OpenStack/test_common.py b/osm_mon/test/OpenStack/test_common.py index e725670..983128b 100644 --- a/osm_mon/test/OpenStack/test_common.py +++ b/osm_mon/test/OpenStack/test_common.py @@ -31,8 +31,8 @@ from keystoneclient.v3 import client import mock -from plugins.OpenStack.common import Common -from plugins.OpenStack.settings import Config +from osm_mon.plugins.OpenStack.common import Common +from osm_mon.plugins.OpenStack.settings import Config import requests diff --git a/osm_mon/test/OpenStack/test_metric_calls.py b/osm_mon/test/OpenStack/test_metric_calls.py index f4c7e97..3c4a7c8 100644 --- a/osm_mon/test/OpenStack/test_metric_calls.py +++ b/osm_mon/test/OpenStack/test_metric_calls.py @@ -29,11 +29,9 @@ import unittest import mock -from plugins.OpenStack.Gnocchi import metrics as metric_req +from osm_mon.plugins.OpenStack.Gnocchi import metrics as metric_req -from plugins.OpenStack.common import Common - -__author__ = "Helena McGough" +from osm_mon.plugins.OpenStack.common import Common log = logging.getLogger(__name__) diff --git a/osm_mon/test/OpenStack/test_metric_req.py b/osm_mon/test/OpenStack/test_metric_req.py index a3ab3dd..2a3cbc3 100644 --- a/osm_mon/test/OpenStack/test_metric_req.py +++ b/osm_mon/test/OpenStack/test_metric_req.py @@ -29,11 +29,9 @@ import unittest import mock -from plugins.OpenStack.Gnocchi import metrics as metric_req +from osm_mon.plugins.OpenStack.Gnocchi import metrics as metric_req -from plugins.OpenStack.common import Common - -__author__ = "Helena McGough" +from osm_mon.plugins.OpenStack.common import Common log = logging.getLogger(__name__) diff --git a/osm_mon/test/OpenStack/test_notifier.py b/osm_mon/test/OpenStack/test_notifier.py index ccebb69..97b3c2a 100644 --- a/osm_mon/test/OpenStack/test_notifier.py +++ b/osm_mon/test/OpenStack/test_notifier.py @@ -27,16 +27,14 @@ import unittest from BaseHTTPServer import BaseHTTPRequestHandler -from core.message_bus.producer import KafkaProducer - import mock -from plugins.OpenStack.Aodh.alarming import Alarming -from plugins.OpenStack.common import Common -from plugins.OpenStack.response import OpenStack_Response -from plugins.OpenStack.settings import Config +from osm_mon.core.message_bus.producer import KafkaProducer -__author__ = "Helena McGough" +from osm_mon.plugins.OpenStack.Aodh.alarming import Alarming +from osm_mon.plugins.OpenStack.common import Common +from osm_mon.plugins.OpenStack.response import OpenStack_Response +from osm_mon.plugins.OpenStack.settings import Config # Mock data from post request post_data = json.dumps({"severity": "critical", diff --git a/osm_mon/test/OpenStack/test_responses.py b/osm_mon/test/OpenStack/test_responses.py index 900d8fe..6cf4e3f 100644 --- a/osm_mon/test/OpenStack/test_responses.py +++ b/osm_mon/test/OpenStack/test_responses.py @@ -27,9 +27,7 @@ import unittest import mock -from plugins.OpenStack import response as resp - -__author__ = "Helena McGough" +from osm_mon.plugins.OpenStack import response as resp log = logging.getLogger(__name__) diff --git a/osm_mon/test/OpenStack/test_settings.py b/osm_mon/test/OpenStack/test_settings.py index dcc1053..44bed82 100644 --- a/osm_mon/test/OpenStack/test_settings.py +++ b/osm_mon/test/OpenStack/test_settings.py @@ -29,9 +29,7 @@ import unittest import mock -from plugins.OpenStack.settings import Config - -__author__ = "Helena McGough" +from osm_mon.plugins.OpenStack.settings import Config log = logging.getLogger(__name__) diff --git a/scripts/install_mon.sh b/scripts/install_mon.sh index 2a99b8a..56c2d5a 100644 --- a/scripts/install_mon.sh +++ b/scripts/install_mon.sh @@ -37,4 +37,4 @@ lxc exec MON -- git clone https://osm.etsi.org/gerrit/osm/MON.git lxc exec MON -- pip install -r /root/MON/requirements.txt lxc exec MON -- python /root/MON/kafkad lxc exec MON -- . /root/MON/scripts/kafka.sh -lxc exec MON -- . /root/MON/plugins/vRealiseOps/vROPs_Webservice/install.sh +lxc exec MON -- . /root/MON/osm_mon/plugins/vRealiseOps/vROPs_Webservice/install.sh diff --git a/tox.ini b/tox.ini index 37c4113..f6ea1e9 100644 --- a/tox.ini +++ b/tox.ini @@ -51,4 +51,4 @@ max-line-length = 80 show-source = True ignore = E123,E125,E241 builtins = _ -exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,core/*,devops_stages/*,plugins/CloudWatch/*, plugins/vRealiseOps/*,.rst +exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,core/*,devops_stages/**.rst -- 2.25.1