-# 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
-
+# 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
-##
+# 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.
+########################################################################################
+# This Dockerfile is intented for devops testing and deb package generation
+#
+# To run stage 2 locally:
+#
+# docker build -t stage2 .
+# docker run -ti -v `pwd`:/work -w /work --entrypoint /bin/bash stage2
+# devops-stages/stage-test.sh
+# devops-stages/stage-build.sh
+#
FROM ubuntu:20.04
-RUN apt-get update && \
- DEBIAN_FRONTEND=noninteractive apt-get --yes install git tox=3.13.2-2 make=4.2.1-1.2 python-all=2.7.17-2ubuntu4 python3=3.8.2-0ubuntu2 python3-pip=20.0.2-5ubuntu1.1 debhelper wget && \
- DEBIAN_FRONTEND=noninteractive apt-get --yes install libmysqlclient-dev=8.0.23-0ubuntu0.20.04.1 libxml2 python3-all=3.8.2-0ubuntu2 dh-python=4.20191017ubuntu7 && \
- DEBIAN_FRONTEND=noninteractive pip3 install -U setuptools==53.0.0 setuptools-version-command==2.2 stdeb==0.10.0
+RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
+ DEBIAN_FRONTEND=noninteractive apt-get -y install \
+ debhelper \
+ dh-python \
+ git \
+ python3 \
+ python3-all \
+ python3-dev \
+ python3-setuptools
+
+RUN python3 -m easy_install pip==21.0.1
+RUN pip3 install tox==3.22.0
# contact: bdiaz@whitestack.com or glavado@whitestack.com
##
-include requirements.txt
-include test-requirements.txt
include README.rst
-recursive-include osm_policy_module *.py *.xml *.sh *.yaml
-recursive-include devops-stages *
\ No newline at end of file
+recursive-include osm_policy_module *.py *.xml *.sh *.yaml *.txt
+++ /dev/null
-all: clean package
-
-clean:
- rm -rf dist deb_dist osm_policy_module-*.tar.gz osm_policy_module.egg-info .eggs
-
-package:
- python3 setup.py --command-packages=stdeb.command sdist_dsc
- cp debian/python3-osm-policy-module.postinst deb_dist/osm-policy-module*/debian
- cd deb_dist/osm-policy-module*/ && dpkg-buildpackage -rfakeroot -uc -us
\ No newline at end of file
+++ /dev/null
-#!/bin/bash
-
-# 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
-##
-
-echo "Installing python dependencies via pip..."
-pip3 install aiokafka==0.6.0
-pip3 install peewee==3.8.*
-pip3 install jsonschema==2.6.*
-pip3 install pyyaml==3.*
-pip3 install pymysql
-pip3 install peewee-migrate==1.1.*
-pip3 install requests==2.*
-echo "Installation of python dependencies finished"
\ No newline at end of file
-# 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
+#!/bin/sh
+# 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: prithiv.mohan@intel.com or adrian.hoban@intel.com
+# 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.
-#__author__ = "Prithiv Mohan"
-#__date__ = "14/Sep/2017"
+rm -rf dist deb_dist osm*.tar.gz *.egg-info .eggs
-#!/bin/bash
-make
+tox -e dist
# 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: prithiv.mohan@intel.com or adrian.hoban@intel.com
-
-#__author__ = "Prithiv Mohan"
-#__date__ = "14/Sep/2017"
-
-#!/bin/bash
-tox
+OUTPUT=$(TOX_PARALLEL_NO_SPINNER=1 tox --parallel=auto)
+printf "$OUTPUT"
--- /dev/null
+# Copyright ETSI Contributors and Others.
+#
+# 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.
+
+git+https://osm.etsi.org/gerrit/osm/common.git@master#egg=osm-common
--- /dev/null
+aiokafka==0.7.0
+ # via osm-common
+dataclasses==0.6
+ # via osm-common
+kafka-python==2.0.2
+ # via aiokafka
+git+https://osm.etsi.org/gerrit/osm/common.git@master#egg=osm-common
+ # via -r requirements-dev.in
+pycrypto==2.6.1
+ # via osm-common
+pymongo==3.11.3
+ # via osm-common
+pyyaml==5.4.1
+ # via osm-common
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# 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.
+#######################################################################################
--- /dev/null
+# Copyright ETSI Contributors and Others.
+#
+# 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.
+
+stdeb
+setuptools-version-command
\ No newline at end of file
--- /dev/null
+setuptools-version-command==2.2
+ # via -r requirements-dist.in
+stdeb==0.10.0
+ # via -r requirements-dist.in
+
+# The following packages are considered to be unsafe in a requirements file:
+# setuptools
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# 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.
+#######################################################################################
--- /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
+##
+coverage
+mock
+nose2
--- /dev/null
+coverage==5.5
+ # via
+ # -r requirements-test.in
+ # nose2
+mock==4.0.3
+ # via -r requirements-test.in
+nose2==0.10.0
+ # via -r requirements-test.in
+six==1.15.0
+ # via nose2
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# 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.
+#######################################################################################
--- /dev/null
+# Copyright ETSI Contributors and Others.
+#
+# 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.
+
+aiokafka
+peewee==3.8.*
+jsonschema==2.6.*
+pyyaml
+pymysql==0.9.*
+peewee-migrate==1.1.*
+requests==2.*
-# Copyright 2020 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
-
+aiokafka==0.7.0
+ # via -r requirements.in
+cached-property==1.5.2
+ # via peewee-migrate
+certifi==2020.12.5
+ # via requests
+chardet==4.0.0
+ # via requests
+click==7.1.2
+ # via peewee-migrate
+idna==2.10
+ # via requests
+jsonschema==2.6.0
+ # via -r requirements.in
+kafka-python==2.0.2
+ # via aiokafka
+mock==4.0.3
+ # via peewee-migrate
+peewee-migrate==1.1.6
+ # via -r requirements.in
+peewee==3.8.2
+ # via
+ # -r requirements.in
+ # peewee-migrate
+pymysql==0.9.3
+ # via -r requirements.in
+pyyaml==5.4.1
+ # via -r requirements.in
+requests==2.25.1
+ # via -r requirements.in
+urllib3==1.26.4
+ # via requests
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# 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: fbravo@whitestack.com or glavado@whitestack.com
-##
-
-aiokafka==0.6.0
-peewee==3.8.*
-jsonschema==2.6.*
-pyyaml==3.*
-pymysql==0.9.*
-peewee-migrate==1.1.*
-requests==2.*
-git+https://osm.etsi.org/gerrit/osm/common.git@v5.0#egg=osm-common
+# 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.
+#######################################################################################
_name = 'osm_policy_module'
_version_command = ('git describe --match v* --tags --long --dirty', 'pep440-git-full')
-_author = "Benjamín Díaz"
-_author_email = 'bdiaz@whitestack.com'
+_author = "OSM Support"
+_author_email = 'osmsupport@etsi.org'
_description = 'OSM Policy Module'
-_maintainer = 'Benjamín Díaz'
-_maintainer_email = 'bdiaz@whitestack.com'
+_maintainer = 'OSM Support'
+_maintainer_email = 'osmsupport@etsi.org'
_license = 'Apache 2.0'
_url = 'https://osm.etsi.org/gitweb/?p=osm/MON.git;a=tree'
packages=[_name],
package_dir={_name: _name},
include_package_data=True,
- install_requires=[
- "aiokafka==0.6.0",
- "peewee==3.8.*",
- "jsonschema==2.6.*",
- "pyyaml==3.*",
- "pymysql",
- "peewee-migrate==1.1.*",
- "requests==2.*",
- "osm-common",
- ],
+
entry_points={
"console_scripts": [
"osm-policy-agent = osm_policy_module.cmd.policy_module_agent:main",
"osm-pol-healthcheck = osm_policy_module.cmd.policy_module_healthcheck:main",
]
},
- dependency_links=[
- 'git+https://osm.etsi.org/gerrit/osm/common.git#egg=osm-common'
- ],
setup_requires=['setuptools-version-command']
)
+# Copyright ETSI Contributors and Others.
+#
+# 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.
+
[DEFAULT]
-X-Python3-Version : >= 3.4
-Depends3 : libmysqlclient-dev, python3-pip, python3-osm-common
\ No newline at end of file
+X-Python3-Version : >= 3.5
+++ /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<3.0
-mock
-coverage==4.5.3
-# 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
-
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# 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.
+# 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.
+#######################################################################################
+
[tox]
-envlist = cover, flake8
+envlist = black, cover, flake8, pylint, safety
+[tox:jenkins]
+toxworkdir = /tmp/.tox
[testenv]
usedevelop = True
-install_command = pip install -U {opts} {packages}
+basepython = python3
setenv = VIRTUAL_ENV={envdir}
PYTHONDONTWRITEBYTECODE = 1
- TESTS_DIR=./osm_policy_module/tests/unit/
-deps = -r{toxinidir}/requirements.txt
- -r{toxinidir}/test-requirements.txt
+deps = -r{toxinidir}/requirements.txt
+
+#######################################################################################
+[testenv:black]
+deps = black
+skip_install = true
commands =
- coverage erase
+ - black --check --diff osm_policy_module/
+
+#######################################################################################
[testenv:cover]
-basepython = python3
-deps = nose2
- -r{toxinidir}/requirements.txt
- -r{toxinidir}/test-requirements.txt
+deps = {[testenv]deps}
+ -r{toxinidir}/requirements-dev.txt
+ -r{toxinidir}/requirements-test.txt
+commands =
+ sh -c 'rm -f nosetests.xml'
+ coverage erase
+ nose2 -C --coverage osm_policy_module
+ coverage report --omit='*tests*'
+ coverage html -d ./cover --omit='*tests*'
+ coverage xml -o coverage.xml --omit=*tests*
+whitelist_externals = sh
+
+
+#######################################################################################
+[testenv:flake8]
+deps = flake8
commands =
- coverage erase
- nose2 -C --coverage osm_policy_module --plugin nose2.plugins.junitxml
- coverage report --omit='*tests*'
- coverage html -d ./cover --omit='*tests*'
- coverage xml -o coverage.xml --omit='*tests*'
+ flake8 osm_policy_module/ setup.py
+
+#######################################################################################
[testenv:pylint]
-basepython = python3
-deps = pylint
- -r{toxinidir}/requirements.txt
- -r{toxinidir}/test-requirements.txt
+deps = {[testenv]deps}
+ -r{toxinidir}/requirements-dev.txt
+ -r{toxinidir}/requirements-test.txt
+ pylint
commands =
pylint -E osm_policy_module
-[testenv:flake8]
-basepython = python3
-deps = flake8
- -r{toxinidir}/requirements.txt
+
+#######################################################################################
+[testenv:safety]
+setenv =
+ LC_ALL=C.UTF-8
+ LANG=C.UTF-8
+deps = {[testenv]deps}
+ safety
commands =
- flake8 osm_policy_module
+ - safety check --full-report
-[testenv:build]
-basepython = python3
-deps = stdeb
- setuptools-version-command
-commands = python3 setup.py --command-packages=stdeb.command bdist_deb
+#######################################################################################
+[testenv:pip-compile]
+deps = pip-tools==5.5.0
+commands =
+ - sh -c 'for file in requirements*.in ; do pip-compile -rU --no-header $file ;\
+ out=`echo $file | sed "s/.in/.txt/"` ; \
+ head -16 tox.ini >> $out ;\
+ done'
+whitelist_externals = sh
+
+
+#######################################################################################
+[testenv:dist]
+deps = {[testenv]deps}
+ -r{toxinidir}/requirements-dist.txt
+
+# In the commands, we copy the requirements.txt to be presented as a source file (.py)
+# so it gets included in the .deb package for others to consume
+commands =
+ sh -c 'cp requirements.txt osm_policy_module/requirements.txt'
+ python3 setup.py --command-packages=stdeb.command sdist_dsc
+ sh -c 'cd deb_dist/osm-policy-module*/ && dpkg-buildpackage -rfakeroot -uc -us'
+ sh -c 'rm osm_policy_module/requirements.txt'
+whitelist_externals = sh
+
+#######################################################################################
[flake8]
-# E123, E125 skipped as they are invalid PEP-8.
+ignore =
+ W291,
+ W293,
+ E123,
+ E125,
+ E226,
+ E241
+exclude =
+ .git,
+ __pycache__,
+ .tox,
max-line-length = 120
show-source = True
-ignore = E123,E125,E241
builtins = _
-exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,devops_stages/*,.rst