diff --git a/.landscape.yml b/.landscape.yml new file mode 100644 index 00000000..81c29088 --- /dev/null +++ b/.landscape.yml @@ -0,0 +1,22 @@ +doc-warnings: true +test-warnings: false +strictness: medium +max-line-length: 100 +autodetect: true +pep8: + full: true +pep257: + run: false +mccabe: + run: false +requirements: + - requirements.txt +python-targets: + - 2 + - 3 +ignore-paths: + - docs + - test +ignore-patterns: +# This file is only defining the imported Alignak version + - alignak_backend/__init__.py diff --git a/.travis.yml b/.travis.yml index f813a693..441b3b77 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,12 +18,22 @@ script: - cd test - pip freeze # so to help eventual debug: know what exact versions are in use can be rather useful. - cd .. + # Code static analysis - pep8 --max-line-length=100 --exclude='*.pyc, *.cfg, *.log' --ignore='E402' alignak_backend/* - rm -fr alignak_backend/__pycache__ - pylint --rcfile=.pylintrc alignak_backend/* - pep257 --select=D300 alignak_backend + # Code test and dynamic analysis - cd test + - coverage erase + - nosetests -xv --nologcapture --process-restartworker --processes=1 --process-timeout=300 --with-coverage --cover-package=alignak_backend test*.py + - coverage report + # Test code static analysis - pep8 --max-line-length=100 --exclude='*.pyc, *.cfg, *.log' --ignore='E402' test_*.py - pylint --rcfile=../.pylintrc test_*.py - - nosetests -xv --nologcapture --process-restartworker --processes=1 --process-timeout=300 - cd .. +after_success: + # to get coverage data with relative paths and not absolute we have to + # execute coveralls from the base directory of the project, + # so we need to move the .coverage file here : + mv test/.coverage . && coveralls --rcfile=test/.coveragerc -v diff --git a/README.rst b/README.rst index f23a3aab..6bb0edb7 100644 --- a/README.rst +++ b/README.rst @@ -7,6 +7,14 @@ Alignak Backend :target: https://travis-ci.org/Alignak-monitoring-contrib/alignak-backend :alt: Develop branch build status +.. image:: https://landscape.io/github/Alignak-monitoring-contrib/alignak-backend/develop/landscape.svg?style=flat + :target: https://landscape.io/github/Alignak-monitoring-contrib/alignak-backend/develop + :alt: Development code static analysis + +.. image:: https://coveralls.io/repos/Alignak-monitoring-contrib/alignak-backend/badge.svg?branch=develop&service=github + :target: https://coveralls.io/github/Alignak-monitoring-contrib/alignak-backend?branch=develop + :alt: Development code coverage + .. image:: https://readthedocs.org/projects/alignak-backend/badge/?version=latest :target: http://alignak-backend.readthedocs.org/en/latest/?badge=latest :alt: Latest documentation Status @@ -17,7 +25,11 @@ Alignak Backend .. image:: https://badge.fury.io/py/alignak_backend.svg :target: https://badge.fury.io/py/alignak_backend - :alt: Last PyPi version + :alt: Most recent PyPi version + +.. image:: https://img.shields.io/badge/IRC-%23alignak-1e72ff.svg?style=flat + :target: http://webchat.freenode.net/?channels=%23alignak + :alt: Join the chat #alignak on freenode.net .. image:: https://img.shields.io/badge/License-AGPL%20v3-blue.svg :target: http://www.gnu.org/licenses/agpl-3.0 @@ -31,47 +43,55 @@ This package is an Alignak Backend. It is used to: -* manage configuration (hosts, services, contacts, timeperiods...) +* manage monitoring configuration (hosts, services, contacts, timeperiods...) - * end user (webui, command line...) can get and add configurations elements - * Alignak gets this configuration when its arbiter module starts + * end user (WebUI, python/php client, curl command line,...) can get, add, edit monitoring configurations elements + * inner templating system to easily create new hosts, services, users, ... + * Alignak gets this configuration when its arbiter module starts * manage retention - * Alignak load and save retention information for checks/hosts/services + * Alignak saves and loads retention information for checks/hosts/services from the backend -* manage live states +* manage the monitoring live state * Alignak add/update states for hosts and services * end user (webui, command line...) can get these information +* manage the metrics from the checks performance data -Release strategy ----------------- + * Alignak backend send metrics to Graphite / InfluxDB timeseries databases + * Alignak backend automatically creates Grafana panels for hosts / services metrics -Alignak backend and its *satellites* (backend client, and backend import tools) must all have the -same features level. As of it, take care to install the same minor version on your system to -ensure compatibility between all the packages. Use 0.4.x version of Backend import and Backend -client with a 0.4.x version of the Backend. -The current version of Alignak backend is 0.5.6. +Installation +------------ + +From PyPI +~~~~~~~~~ +To install the package from PyPI: +:: -This version is published on PyPi and can be installed with ``pip install alignak_backend``. + sudo pip install alignak-backend -It contains: -- compatibility with new upcoming Alignak 1.0 version +From source files +~~~~~~~~~~~~~~~~~ +To install the package from the source files: +:: -- modified data model: - - live state in the host/service elements - - user preferences in the user data model - - unreachable managed for the hosts and services + git clone https://github.com/Alignak-monitoring-contrib/alignak-backend + cd alignak-backend + sudo pip install . -Previous versions: -- 0.4: version compatible with Alignak version 0.2 (objects serialization and uuid) +Release strategy +---------------- -- 0.3: version compatible with Alignak version 0.1 +Alignak backend and its *satellites* (backend client, and backend import tools) must all have the +same features level. As of it, take care to install the same minor version on your system to +ensure compatibility between all the packages. Use 0.4.x version of Backend import and Backend +client with a 0.4.x version of the Backend. Bugs, issues and contributing ----------------------------- diff --git a/alignak_backend/__init__.py b/alignak_backend/__init__.py index 1803ec91..a368a0fb 100755 --- a/alignak_backend/__init__.py +++ b/alignak_backend/__init__.py @@ -8,17 +8,33 @@ This module is an Alignak REST backend """ # Application version and manifest -VERSION = (0, 5, 6) +VERSION = (1, 0, 'rc1') +VERSION = (0, 7, 2) __application__ = u"Alignak_Backend" __short_version__ = '.'.join((str(each) for each in VERSION[:2])) __version__ = '.'.join((str(each) for each in VERSION[:4])) __author__ = u"Alignak team" -__copyright__ = u"(c) 2015 - %s" % __author__ +__author_email__ = u"david.durieux@alignak.net" +__copyright__ = u"(c) 2015-2017 - %s" % __author__ __license__ = u"GNU Affero General Public License, version 3" __description__ = u"Alignak REST backend" __releasenotes__ = u"""Alignak REST Backend""" -__doc_url__ = "https://github.com/Alignak-monitoring-contrib/alignak-backend" +__git_url__ = "https://github.com/Alignak-monitoring-contrib/alignak-backend" +__doc_url__ = "http://alignak-backend.readthedocs.org" + +__classifiers__ = [ + 'Development Status :: 5 - Production/Stable', + 'Environment :: Console', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)', + 'Natural Language :: English', + 'Programming Language :: Python', + 'Topic :: System :: Monitoring', + 'Topic :: System :: Systems Administration' +] + # Application manifest manifest = { 'name': __application__, diff --git a/etc/settings.json b/etc/settings.json index f32820eb..c281cda0 100644 --- a/etc/settings.json +++ b/etc/settings.json @@ -22,11 +22,11 @@ "MONGO_USERNAME": null, /* Username to access to MongoDB */ "MONGO_PASSWORD": null, /* Password to access to MongoDB */ - /* Timeseries data are stored in retention in backend. Activate the timeseries scheduler - will push into timeseries databases the data. - BE CAREFULL, ACTIVATE IT ONLY ON ONE BACKEND */ + /* Timeseries data are stored internally in the backend. + The timeseries scheduler will push them regularly to the configured databases + BE CAREFULL, ACTIVATE THIS ON ONE BACKEND ONLY! */ "SCHEDULER_TIMESERIES_ACTIVE": false, /* This scheduler will create / update dashboards in grafana. - BE CAREFULL, ACTIVATE IT ONLY ON ONE BACKEND */ + BE CAREFULL, ACTIVATE IT ON ONE BACKEND ONLY! */ "SCHEDULER_GRAFANA_ACTIVE": false } diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index cb72fd13..00000000 --- a/setup.cfg +++ /dev/null @@ -1,23 +0,0 @@ -[metadata] -classifiers = - Development Status :: 4 - Beta - Environment :: Console - Intended Audience :: System Administrators - License :: OSI Approved :: GNU General Public License v3 (GPLv3) - Natural Language :: English - Programming Language :: Python :: 2.7 - Programming Language :: Python :: 3.4 - Topic :: System :: Monitoring - Topic :: System :: Systems Administration - -[files] -packages = - alignak_backend - -[entry_points] -console_scripts = - alignak_backend = alignak_backend.main:main - -[pbr] -skip_authors = True -skip_changelog = True diff --git a/setup.py b/setup.py index 5e2c288a..09eb3832 100644 --- a/setup.py +++ b/setup.py @@ -2,10 +2,8 @@ # -*- coding: utf-8 -*- from __future__ import print_function -import os import sys -import re -del os.link + from importlib import import_module try: @@ -20,39 +18,13 @@ if python_version < (2, 7): sys.exit("This application requires a minimum Python 2.7.x, sorry!") -try: - from alignak.version import VERSION - __alignak_version__ = VERSION -except: - __alignak_version__ = 'x.y.z' - from alignak_backend import __application__, __version__, __copyright__ -from alignak_backend import __releasenotes__, __license__, __doc_url__ +from alignak_backend import __releasenotes__, __license__, __doc_url__, __git_url__ +from alignak_backend import __author__, __author_email__, __classifiers__ from alignak_backend import __name__ as __pkg_name__ package = import_module('alignak_backend') -# Define paths -if 'linux' in sys.platform or 'sunos5' in sys.platform: - installation_paths = { - 'bin': "/usr/bin", - 'var': "/var/lib/alignak-backend/", - 'etc': "/etc/alignak-backend", - 'run': "/var/run/alignak-backend", - 'log': "/var/log/alignak-backend", - } -elif 'bsd' in sys.platform or 'dragonfly' in sys.platform: - installation_paths = { - 'bin': "/usr/local/bin", - 'var': "/usr/local/libexec/alignak-backend", - 'etc': "/usr/local/etc/alignak-backend", - 'run': "/var/run/alignak-backend", - 'log': "/var/log/alignak-backend", - } -else: - print("Unsupported platform, sorry!") - exit(1) - setup( name=__pkg_name__, version=__version__, @@ -60,43 +32,33 @@ license=__license__, # metadata for upload to PyPI - author="David Durieux", - author_email="d.durieux@siprossii.com", + author=__author__, + author_email=__author_email__, keywords="alignak monitoring backend", - url="https://github.com/Alignak-monitoring-contrib/alignak-backend", + url=__git_url__, description=package.__doc__.strip(), long_description=open('README.rst').read(), + classifiers = __classifiers__, + zip_safe=False, packages=find_packages(), - include_package_data=True, - # package_data={ - # 'sample': ['package_data.dat'], - # }, - data_files = [(installation_paths['etc'], ['etc/settings.json'])], + # Where to install distributed files + data_files = [('etc/alignak-backend', ['etc/settings.json'])], + + # Dependencies (if some) ... install_requires=[ 'python-dateutil==2.4.2', 'Eve>=0.5', 'flask-bootstrap', 'docopt', 'jsonschema', - 'eve-swagger', 'configparser', - 'future', 'influxdb', 'flask-apscheduler' + 'eve-swagger', 'configparser', 'future', 'influxdb', 'flask-apscheduler', + 'uwsgi' ], + # Entry points (if some) ... entry_points={ 'console_scripts': [ 'alignak-backend = alignak_backend.main:main' ], - }, - - classifiers = [ - 'Development Status :: 4 - Beta', - 'Environment :: Console', - 'Intended Audience :: Developers', - 'Intended Audience :: System Administrators', - 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', - 'Natural Language :: English', - 'Programming Language :: Python', - 'Topic :: System :: Monitoring', - 'Topic :: System :: Systems Administration' - ] + } ) diff --git a/test/.coveragerc b/test/.coveragerc index 623e1b29..100f215d 100644 --- a/test/.coveragerc +++ b/test/.coveragerc @@ -1,6 +1,10 @@ +[run] +omit = + ./test* + [report] omit = - */python?.?/* - */site-packages/nose/* -[run] -omit = test* + */python?.?/* + */site-packages/nose/* + /usr/share/pyshared/* + ./test*