--- /dev/null
+# Copyright 2017 Intel Research and Development Ireland Limited
+# *************************************************************
+
+# This file is part of OSM Monitoring module
+# All Rights Reserved to Intel Corporation
+
+# 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: helena.mcgough@intel.com or adrian.hoban@intel.com
+##
+[DEFAULT]
+test_command=python -m subunit.run discover . $LISTOPT $IDOPTION
+test_id_option=--load-list $IDFILE
+test_list_option=--list
'create_alarm_response', status=alarm_status,
alarm_id=alarm_id,
cor_id=alarm_details['correlation_id'])
+ log.info("Response Message: %s", resp_message)
self._producer.create_alarm_response(
'create_alarm_resonse', resp_message,
'alarm_response')
resp_message = self._response.generate_response(
'list_alarm_response', alarm_list=alarm_list,
cor_id=list_details['correlation_id'])
+ log.info("Response Message: %s", resp_message)
self._producer.list_alarm_response(
'list_alarm_response', resp_message,
'alarm_response')
'delete_alarm_response', alarm_id=alarm_id,
status=resp_status,
cor_id=request_details['correlation_id'])
+ log.info("Response message: %s", resp_message)
self._producer.delete_alarm_response(
'delete_alarm_response', resp_message,
'alarm_response')
'update_alarm_response', alarm_id=alarm_id,
cor_id=alarm_details['correlation_id'],
status=status)
+ log.info("Response message: %s", resp_message)
self._producer.update_alarm_response(
'update_alarm_response', resp_message,
'alarm_response')
'create_metric_response', status=status,
cor_id=values['correlation_id'],
metric_id=metric_id, r_id=resource_id)
+ log.info("Response messages: %s", resp_message)
self._producer.create_metrics_resp(
'create_metric_response', resp_message,
'metric_response')
r_id=values['resource_uuid'],
cor_id=values['correlation_id'],
times=timestamps, metrics=metric_data)
+ log.info("Response message: %s", resp_message)
self._producer.read_metric_data_response(
'read_metric_data_response', resp_message,
'metric_response')
m_name=values['metric_name'],
status=status, r_id=values['resource_uuid'],
cor_id=values['correlation_id'])
+ log.info("Response message: %s", resp_message)
self._producer.delete_metric_response(
'delete_metric_response', resp_message,
'metric_response')
'update_metric_response', status=False,
cor_id=values['correlation_id'],
r_id=resource_id, m_id=metric_id)
+ log.info("Response message: %s", resp_message)
self._producer.update_metric_response(
'update_metric_response', resp_message,
'metric_response')
resp_message = self._response.generate_response(
'list_metric_response', m_list=metric_list,
cor_id=list_details['correlation_id'])
+ log.info("Response message: %s", resp_message)
self._producer.list_metric_response(
'list_metric_response', resp_message,
'metric_response')
diff = PERIOD_MS[collection_unit]
else:
diff = collection_period * PERIOD_MS[collection_unit]
- s_time = (end_time - diff)/1000.0
+ s_time = (end_time - diff) / 1000.0
start_time = datetime.datetime.fromtimestamp(s_time).strftime(
'%Y-%m-%dT%H:%M:%S.%f')
base_url = "{}/v1/metric/%(0)s/measures?start=%(1)s&stop=%(2)s"
headers = {'X-Auth-Token': auth_token,
'Content-type': 'application/json'}
# perform request and return its result
- response = None
try:
if req_type == "put":
response = requests.put(
url, data=payload, headers=headers,
timeout=1)
- elif req_type == "post":
- response = requests.post(
- url, data=payload, headers=headers,
- timeout=1)
elif req_type == "get":
response = requests.get(
url, params=params, headers=headers, timeout=1)
response = requests.delete(
url, headers=headers, timeout=1)
else:
- log.warn("Invalid request type")
+ response = requests.post(
+ url, data=payload, headers=headers,
+ timeout=1)
except Exception as e:
log.warn("Exception thrown on request", e)
cherrypy
jsmin
jsonschema
-mysql_python
python-openstackclient
python-novaclient
python-keystoneclient
--- /dev/null
+# Copyright 2017 Intel Research and Development Ireland Limited
+# *************************************************************
+
+# This file is part of OSM Monitoring module
+# All Rights Reserved to Intel Corporation
+
+# 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: helena.mcgough@intel.com or adrian.hoban@intel.com
+##
+
+[metadata]
+name = MON
+summary = Monitoring module for OSM.
+description-file =
+ README.rst
+author = OSM
+home-page = https://osm.etsi.org/
+classifier =
+ Environment :: OSM
+ Intended Audience :: Information Technology
+ Intended Audience :: System Administrators
+ License :: ETSI Approved :: Apache Software License
+ Operating System :: POSIX :: Linux
+ Programming Language :: Python
+ Programming Language :: Python :: 2
+ Programming Language :: Python :: 2.7
+ Programming Language :: Python :: 3
+ Programming Language :: Python :: 3.5
+
+[test]
+test_suite=test
+
+[files]
+packages =
+ Aodh
+ Gnocchi
_copyright = 'Intel Research and Development Ireland'
_url = 'https://osm.etsi.org/gitweb/?p=osm/MON.git;a=tree'
_requirements = [
- "MySQL-python",
+ "MySQL-python",
"requests",
"logutils",
"cherrypy",
"pyopenssl",
"cherrypy",
"bottle",
+ "six",
]
setup(name="mon_core",
--- /dev/null
+# Copyright 2017 Intel Research and Development Ireland Limited
+# *************************************************************
+
+# This file is part of OSM Monitoring module
+# All Rights Reserved to Intel Corporation
+
+# 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: helena.mcgough@intel.com or adrian.hoban@intel.com
+##
+
+flake8
+mock
+os-testr
+testrepository
+testscenarios
+testtools
+kafka
--- /dev/null
+# Copyright 2017 Intel Research and Development Ireland Limited
+# *************************************************************
+
+# This file is part of OSM Monitoring module
+# All Rights Reserved to Intel Corporation
+
+# 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: helena.mcgough@intel.com or adrian.hoban@intel.com
+##
+
--- /dev/null
+# Copyright 2017 Intel Research and Development Ireland Limited
+# *************************************************************
+
+# This file is part of OSM Monitoring module
+# All Rights Reserved to Intel Corporation
+
+# 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: helena.mcgough@intel.com or adrian.hoban@intel.com
+##
+"""Tests for all common OpenStack methods."""
+
+import unittest
+
+import mock
+
+from plugins.OpenStack.common import Common
+
+import requests
+
+
+class TestCommon(unittest.TestCase):
+ """Test the common class for OpenStack plugins."""
+
+ def setUp(self):
+ """Test Setup."""
+ super(TestCommon, self).setUp()
+ self.common = Common()
+
+ @mock.patch.object(requests, 'post')
+ def test_post_req(self, post):
+ """Testing a post request."""
+ self.common._perform_request("url", "auth_token", req_type="post",
+ payload="payload")
+
+ post.assert_called_with("url", data="payload", headers=mock.ANY,
+ timeout=mock.ANY)
+
+ @mock.patch.object(requests, 'get')
+ def test_get_req(self, get):
+ """Testing a get request."""
+ # Run the defualt get request without any parameters
+ self.common._perform_request("url", "auth_token", req_type="get")
+
+ get.assert_called_with("url", params=None, headers=mock.ANY,
+ timeout=mock.ANY)
+
+ # Test with some parameters specified
+ get.reset_mock()
+ self.common._perform_request("url", "auth_token", req_type="get",
+ params="some parameters")
+
+ get.assert_called_with("url", params="some parameters",
+ headers=mock.ANY, timeout=mock.ANY)
+
+ @mock.patch.object(requests, 'put')
+ def test_put_req(self, put):
+ """Testing a put request."""
+ self.common._perform_request("url", "auth_token", req_type="put",
+ payload="payload")
+ put.assert_called_with("url", data="payload", headers=mock.ANY,
+ timeout=mock.ANY)
+
+ @mock.patch.object(requests, 'delete')
+ def test_delete_req(self, delete):
+ """Testing a delete request."""
+ self.common._perform_request("url", "auth_token", req_type="delete")
+
+ delete.assert_called_with("url", headers=mock.ANY, timeout=mock.ANY)
--- /dev/null
+# Copyright 2017 Intel Research and Development Ireland Limited
+# *************************************************************
+
+# This file is part of OSM Monitoring module
+# All Rights Reserved to Intel Corporation
+
+# 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: helena.mcgough@intel.com or adrian.hoban@intel.com
+##
+
--- /dev/null
+# Copyright 2017 Intel Research and Development Ireland Limited
+# *************************************************************
+
+# This file is part of OSM Monitoring module
+# All Rights Reserved to Intel Corporation
+
+# 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: helena.mcgough@intel.com or adrian.hoban@intel.com
+##
+
+#! /bin/sh
+
+TESTRARGS=$1
+
+exec 3>&1
+status=$(exec 4>&1 >&3; ( python setup.py testr --slowest --testr-args="--subunit $TESTRARGS"; echo $? >&4 ) | subunit-trace -f) && exit $status
+
--- /dev/null
+# Copyright 2017 Intel Research and Development Ireland Limited
+# *************************************************************
+
+# This file is part of OSM Monitoring module
+# All Rights Reserved to Intel Corporation
+
+# 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: helena.mcgough@intel.com or adrian.hoban@intel.com
+##
+
+# Tox (http://tox.testrun.org/) is a tool for running tests
+# in multiple virtualenvs. This configuration file will run the
+# test suite on all supported python versions. To use it, "pip install tox"
+# and then run "tox" from this directory.
+
+[tox]
+minversion = 1.6
+envlist = py27
+skipsdist = True
+
+[testenv]
+usedevelop = True
+install_command = pip install -r requirements.txt -U {opts} {packages}
+commands = sh tools/pretty_tox.sh '{posargs}'
+deps = -r{toxinidir}/test-requirements.txt
+whitelist_externals = sh
+setenv =
+ VIRTUAL_ENV={envdir}
+
+[testenv:pep8]
+commands = flake8 test
+
+[testenv:venv]
+commands = {posargs}
+
+[testenv:cover]
+commands = python setup.py test --coverage
+
+[pep8]
+max-line-length = 80
+
+[flake8]
+# E123, E125 skipped as they are invalid PEP-8.
+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