From: tierno Date: Tue, 30 Oct 2018 17:26:59 +0000 (+0000) Subject: fixing dockerfile.local X-Git-Tag: v5.0.0~14 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=b3cda2e2d399e761311fbe9e4ffc3b22037d6312;p=osm%2FLCM.git fixing dockerfile.local fixing package genaration dependencies with common n2vc Change-Id: I2fddf1035f80e008be04e572c00e05b7a0fc80ca Signed-off-by: tierno --- diff --git a/Dockerfile b/Dockerfile index 0000ba9..95365fa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,38 @@ +# Copyright 2018 Telefonica S.A. +# +# 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. + # This Dockerfile is intented for devops and deb package generation # # Use Dockerfile.local for running osm/LCM in a docker container from source -# Use Dockerfile.fromdeb for running osm/LCM in a docker container from last stable package FROM ubuntu:16.04 -RUN apt-get update && apt-get -y install git make python python3 \ - libcurl4-gnutls-dev libgnutls-dev tox python-dev python3-dev \ - debhelper python-setuptools python-all python3-all apt-utils +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get --yes install git tox make debhelper wget \ + python-all python3 python3-pip python3-all && \ + DEBIAN_FRONTEND=noninteractive pip3 install -U setuptools setuptools-version-command stdeb + +# TODO delete if not needed: +# libcurl4-gnutls-dev libgnutls-dev python-dev python3-dev python-setuptools apt-utils + + +# Uncomment this block to generate automatically a debian package and show info +# # Set the working directory to /app +# WORKDIR /app +# # Copy the current directory contents into the container at /app +# ADD . /app +#i CMD /app/devops-stages/stage-build.sh && find -name "*.deb" -exec dpkg -I {} ";" diff --git a/Dockerfile.local b/Dockerfile.local index 3f841cf..7cdf502 100644 --- a/Dockerfile.local +++ b/Dockerfile.local @@ -1,3 +1,18 @@ +# Copyright 2018 Telefonica S.A. +# +# 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. + FROM ubuntu:16.04 # Set the working directory to /app @@ -6,28 +21,21 @@ WORKDIR /app/osm_lcm # Copy the current directory contents into the container at /app ADD . /app -RUN apt-get update && apt-get install -y git python3 \ - python3-pip python3-pymongo python3-yaml python3-aiohttp \ - python3-stdeb python3-setuptools python3-all python-all \ - python3-bitarray python3-regex python3-lxml debhelper dh-python tox wget \ - python3-cffi \ +RUN apt-get update && apt-get install -y git tox python3 \ + python3-pip python3-aiohttp \ && pip3 install pip==9.0.3 \ - && pip3 install -U aiokafka pyang lxml six enum34 + && pip3 install -U 'PyYAML==3.*' 'aiohttp==0.20.2' flake8 RUN git clone https://osm.etsi.org/gerrit/osm/N2VC.git \ - && cd N2VC \ - && git checkout BUILD_v4.0.1_1 \ - && pip3 install websockets==4.0.1 \ - && pip3 install requests \ - && cd modules/libjuju && python3 setup.py develop && cd ../.. \ - && pip3 install -U -r requirements.txt \ - && python3 setup.py develop \ - && cd .. + && pip3 install -e N2VC \ + && pip3 install -e N2VC/modules/libjuju \ + && apt-get install -y libffi-dev libssl-dev + # cd N2VC; python3 setup.py develop + # cd modules/libjuju; python3 setup.py develop RUN git clone https://osm.etsi.org/gerrit/osm/common.git \ - && cd common && python3 setup.py develop && cd .. -# && pip3 install -U -r requirements.txt \ -# && cd .. + && pip3 install -e common + # python3-pymongo python3-yaml pycrypto aiokafka RUN mkdir -p /app/storage/kafka && mkdir -p /app/log diff --git a/MANIFEST.in b/MANIFEST.in index 99153b9..84ee0e9 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,19 @@ +# Copyright 2018 Telefonica S.A. +# +# 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. + include README.rst -recursive-include osm_lcm * +recursive-include osm_lcm *.py *.xml *.sh lcm.cfg +recursive-include devops-stages * diff --git a/Makefile b/Makefile index b439211..0ee3ddd 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,27 @@ +# Copyright 2018 Telefonica S.A. +# +# 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. + +all: clean package clean: - rm -rf dist deb_dist .build osm_lcm-*.tar.gz osm_lcm.egg-info eggs + rm -rf dist deb_dist osm_lcm-*.tar.gz osm_lcm.egg-info .eggs package: python3 setup.py --command-packages=stdeb.command sdist_dsc - cp python3-osm-lcm.postinst deb_dist/osm-lcm*/debian + # cp debian/python3-osm-lcm.postinst deb_dist/osm-lcm*/debian cd deb_dist/osm-lcm*/debian && echo "osm-common python3-osm-common" > py3dist-overrides # cd deb_dist/osm-lcm*/debian && echo "pip3 python3-pip" >> py3dist-overrides cd deb_dist/osm-lcm*/ && dpkg-buildpackage -rfakeroot -uc -us - mkdir -p .build - cp deb_dist/python3-osm-lcm*.deb .build/ - diff --git a/debian/python3-osm-lcm.postinst b/debian/python3-osm-lcm.postinst new file mode 100755 index 0000000..63e30b1 --- /dev/null +++ b/debian/python3-osm-lcm.postinst @@ -0,0 +1,26 @@ +#!/bin/bash + +## +# 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 with: OSM_TECH@list.etsi.org +## + +echo "POST INSTALL OSM-LCM" + +#Creation of log folder +mkdir -p /var/log/osm + +systemctl enable osm-lcm.service + diff --git a/devops-stages/stage-build.sh b/devops-stages/stage-build.sh index 58af160..4efe9d6 100755 --- a/devops-stages/stage-build.sh +++ b/devops-stages/stage-build.sh @@ -1,4 +1,21 @@ #!/bin/sh -rm -rf deb_dist -tox -e build -#make clean package + +# 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. + +# moved to a Makefile in order to add post install. Needed for "pip3 install aiokafka", +# that is not available with a package + +make clean # rm -rf deb_dist +tox -e build # make package + diff --git a/python3-osm-lcm.postinst b/python3-osm-lcm.postinst deleted file mode 100755 index 63e30b1..0000000 --- a/python3-osm-lcm.postinst +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -## -# 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 with: OSM_TECH@list.etsi.org -## - -echo "POST INSTALL OSM-LCM" - -#Creation of log folder -mkdir -p /var/log/osm - -systemctl enable osm-lcm.service - diff --git a/requirements.txt b/requirements.txt index 825516b..da0be6f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,16 @@ -pymongo -yaml -n2vc +# 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. + +pyyaml==3.* +aiohttp==0.20.2 +git+https://osm.etsi.org/gerrit/osm/common.git#egg=osm-common +git+https://osm.etsi.org/gerrit/osm/N2VC.git#egg=n2vc diff --git a/setup.py b/setup.py index bb0a0ab..5d7a52c 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,20 @@ #!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +# Copyright 2018 Telefonica S.A. +# +# 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. import os from setuptools import setup @@ -12,7 +28,7 @@ with open(os.path.join(here, 'README.rst')) as readme_file: setup( name=_name, - description='OSM North Bound Interface', + description='OSM Life Cycle Management module', long_description=README, version_command=('git describe --match v* --tags --long --dirty', 'pep440-git-full'), # version=VERSION, @@ -26,24 +42,21 @@ setup( packages=[_name], include_package_data=True, - data_files=[('/etc/osm/', ['osm_lcm/lcm.cfg']), - ('/etc/systemd/system/', ['osm_lcm/osm-lcm.service']), - ], + # data_files=[('/etc/osm/', ['osm_lcm/lcm.cfg']), + # ('/etc/systemd/system/', ['osm_lcm/osm-lcm.service']), + # ], dependency_links=[ - "git+https://osm.etsi.org/gerrit/osm/common.git@master#egg=osm-common-0.1.4" + 'git+https://osm.etsi.org/gerrit/osm/common.git#egg=osm-common', + 'git+https://osm.etsi.org/gerrit/osm/N2VC.git#egg=n2vc', ], install_requires=[ - 'pymongo', - 'PyYAML', + # 'pymongo', + 'PyYAML==3.*', 'aiohttp==0.20.2', + 'osm-common', + 'n2vc', # TODO this is version installed by 'apt python3-aiohttp' on Ubuntu Sserver 14.04 # version installed by pip 3.3.2 is not compatible. Code should be migrated to this version and use pip3 - # 'osm-common', ], setup_requires=['setuptools-version-command'], - # test_suite='nose.collector', - # entry_points=''' - # [console_scripts] - # osm=osm_lcm.lcm:lcm - # ''', ) diff --git a/stdeb.cfg b/stdeb.cfg new file mode 100644 index 0000000..a265bac --- /dev/null +++ b/stdeb.cfg @@ -0,0 +1,3 @@ +[DEFAULT] +X-Python3-Version : >= 3.5 +Depends3: python3-osm-common, python3-n2vc diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 0000000..70fb454 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,18 @@ +# Copyright 2018 Telefonica S.A. +# +# 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. + +flake8<3.0 +mock + diff --git a/tox.ini b/tox.ini index 3ed9406..e9ea45e 100644 --- a/tox.ini +++ b/tox.ini @@ -1,20 +1,37 @@ +# Copyright 2018 Telefonica S.A. +# +# 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. + [tox] -envlist = py27,py3,flake8 +envlist = py3 toxworkdir={homedir}/.tox [testenv] -deps=nose - mock -commands=nosetests +basepython = python3 +install_command = python3 -m pip install -r requirements.txt -U {opts} {packages} +deps = -r{toxinidir}/test-requirements.txt +commands=python3 -m unittest discover -v [testenv:flake8] basepython = python3 deps = flake8 -commands = - flake8 osm_lcm --max-line-length 120 --exclude .svn,CVS,.gz,.git,__pycache__,.tox,local,temp --ignore W291,W293,E226 +commands = flake8 osm_lcm --max-line-length 120 \ + --exclude .svn,CVS,.gz,.git,__pycache__,.tox,local,temp --ignore W291,W293,E226,W504 [testenv:build] basepython = python3 deps = stdeb setuptools-version-command commands = python3 setup.py --command-packages=stdeb.command bdist_deb +