+#!/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.
+
# This Dockerfile is intented for devops and deb package generation
#
# Use Dockerfile.local for running osm/NBI in a docker container from source
FROM ubuntu:16.04
-RUN apt-get update && apt-get -y install git make python python3 \
+RUN apt-get update && apt-get -y install wget git make python python3 python-pip \
libcurl4-gnutls-dev libgnutls-dev tox python-dev python3-dev \
- debhelper python-setuptools python-all python3-all apt-utils
+ debhelper python-setuptools python-all python3-all apt-utils python-magic \
+ python3-pip python-pip && \
+ DEBIAN_FRONTEND=noninteractive pip3 install -U stdeb setuptools-version-command && \
+ DEBIAN_FRONTEND=noninteractive pip2 install -U stdeb
+
+# 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
+CMD /app/devops-stages/stage-build.sh && find -name "*.deb" -exec dpkg -I {} ";"
FROM ubuntu:16.04
+ARG REPOSITORY_BASE=http://osm-download.etsi.org/repository/osm/debian
+ARG RELEASE=ReleaseFIVE
+ARG REPOSITORY_KEY=OSM%20ETSI%20Release%20Key.gpg
+ARG REPOSITORY=testing
+
+RUN apt-get update && apt-get install -y curl software-properties-common
+RUN curl ${REPOSITORY_BASE}/${RELEASE}/${REPOSITORY_KEY} | apt-key add -
+RUN add-apt-repository -y "deb ${REPOSITORY_BASE}/${RELEASE} ${REPOSITORY} NBI IM common" && apt update
+
+RUN apt-get -y install python3-osm-nbi
+
# Set the working directory to /app
WORKDIR /app/osm_nbi
-# avoid extra information from packages
-RUN echo 'path-exclude /usr/share/doc/*\n\
-path-include /usr/share/doc/*/copyright\n\
-path-exclude /usr/share/man/*\n\
-path-exclude /usr/share/groff/*\n\
-path-exclude /usr/share/info/*\n\
-path-exclude /usr/share/lintian/*\n\
-path-exclude /usr/share/linda/*\n'\
-> /etc/dpkg/dpkg.cfg.d/01_nodoc && \
- echo 'APT::Install-Recommends "false";\n\
-APT::AutoRemove::RecommendsImportant "false";\n\
-APT::AutoRemove::SuggestsImportant "false";\n'\
-> /etc/apt/apt.conf.d/99_norecommends
-
-
-RUN apt-get update && apt-get install -y curl software-properties-common \
- && add-apt-repository -y "deb http://osm-download.etsi.org/repository/osm/debian/ReleaseFOUR testing common NBI" \
- && curl "http://osm-download.etsi.org/repository/osm/debian/ReleaseFOUR/OSM%20ETSI%20Release%20Key.gpg" | apt-key add - \
- && apt-get update && apt-get install -y python3-osm-nbi python3-osm-common \
- && rm -rf /var/lib/apt/lists/*
+RUN cp -R /usr/lib/python3/dist-packages/osm_nbi/html_public /app/osm_nbi/html_public \
+ && cp /usr/lib/python3/dist-packages/osm_nbi/nbi.cfg /app/osm_nbi/ \
+ && cp -R /usr/lib/python3/dist-packages/osm_nbi/http /app/osm_nbi/
EXPOSE 9999
ENV OSMNBI_STORAGE_PATH /app/storage
# database
ENV OSMNBI_DATABASE_DRIVER mongo
-ENV OSMNBI_DATABASE_HOST mongo
-ENV OSMNBI_DATABASE_PORT 27017
+ENV OSMNBI_DATABASE_URI mongodb://mongo:27017
# web
ENV OSMNBI_STATIC_DIR /app/osm_nbi/html_public
# logs
-ENV OSMNBI_LOG_FILE /app/log
+# ENV OSMNBI_LOG_FILE /app/log
ENV OSMNBI_LOG_LEVEL DEBUG
# message
ENV OSMNBI_MESSAGE_DRIVER kafka
ENV OSMNBI_MESSAGE_HOST kafka
ENV OSMNBI_MESSAGE_PORT 9092
+# authentication
+ENV OSMNBI_AUTHENTICATION_BACKEND internal
+#ENV OSMNBI_AUTHENTICATION_BACKEND keystone
+#ENV OSMNBI_AUTHENTICATION_AUTH_URL keystone
+#ENV OSMNBI_AUTHENTICATION_AUTH_PORT 5000
+#ENV OSMNBI_AUTHENTICATION_USER_DOMAIN_NAME default
+#ENV OSMNBI_AUTHENTICATION_PROJECT_DOMAIN_NAME default
+#ENV OSMNBI_AUTHENTICATION_SERVICE_USERNAME nbi
+#ENV OSMNBI_AUTHENTICATION_SERVICE_PASSWORD nbi
+#ENV OSMNBI_AUTHENTICATION_SERVICE_PROJECT service
# Run app.py when the container launches
-CMD ["python3", "nbi.py"]
+CMD ["python3", "/usr/lib/python3/dist-packages/osm_nbi/nbi.py"]
+
+HEALTHCHECK --interval=5s --timeout=2s --retries=12 \
+ CMD curl -k https://localhost:9999/osm/ | grep Welcome || exit 1
# web
ENV OSMNBI_STATIC_DIR /app/NBI/osm_nbi/html_public
# logs
-# ENV OSMNBI_LOG_FILE /app/log
+# ENV OSMNBI_LOG_FILE /app/log/nbi.log
ENV OSMNBI_LOG_LEVEL DEBUG
# message
ENV OSMNBI_MESSAGE_DRIVER kafka
-#include MANIFEST.in
-#include requirements.txt
+# Copyright 2018 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
+##
+
include README.rst
-recursive-include osm_nbi *
+recursive-include osm_nbi *.py *.sh *.cfg
+recursive-include osm_nbi/html_public *
+recursive-include osm_nbi/http *
+recursive-include devops-stages *
+# 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_nbi-*.tar.gz osm_nbi.egg-info .eggs
+ rm -rf dist deb_dist osm_nbi-*.tar.gz osm_nbi.egg-info .eggs
package:
python3 setup.py --command-packages=stdeb.command sdist_dsc
- cp python3-osm-nbi.postinst deb_dist/osm-nbi*/debian
- cd deb_dist/osm-nbi*/debian && echo "osm-common python3-osm-common" > py3dist-overrides
+ cp debian/python3-osm-nbi.postinst deb_dist/osm-nbi*/debian
+ # cd deb_dist/osm-nbi*/debian && echo "osm-common python3-osm-common" > py3dist-overrides
# cd deb_dist/osm-nbi*/debian && echo "pip3 python3-pip" >> py3dist-overrides
cd deb_dist/osm-nbi*/ && dpkg-buildpackage -rfakeroot -uc -us
- mkdir -p .build
- cp deb_dist/python3-osm-nbi*.deb .build/
--- /dev/null
+#!/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-NBI"
+echo "Installing python dependencies via pip..."
+
+pip3 install pip==9.0.3
+pip3 install cherrypy==18.0.0
+pip3 install keystoneauth1
+
+#Creation of log folder
+mkdir -p /var/log/osm
+
+# systemctl enable osm-nbi.service
#!/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.
+
+make clean
+# tox -e build
+make package
+++ /dev/null
-#!/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-NBI"
-
-#Creation of log folder
-mkdir -p /var/log/osm
-
-systemctl enable osm-nbi.service
-
--- /dev/null
+# 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.
+
+CherryPy==18.0.0
+jsonschema
+PyYAML==3.*
+python-keystoneclient
+git+https://osm.etsi.org/gerrit/osm/common.git#egg=osm-common
+git+https://osm.etsi.org/gerrit/osm/IM.git#egg=osm-im
+
#!/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
packages=[_name],
include_package_data=True,
# exclude_package_data={'': ['osm_nbi/local', 'temp']},
- data_files=[('/etc/osm/', ['osm_nbi/nbi.cfg']),
- ('/etc/systemd/system/', ['osm_nbi/osm-nbi.service']),
- ],
+ # data_files=[('/etc/osm/', ['osm_nbi/nbi.cfg']),
+ # ('/etc/systemd/system/', ['osm_nbi/osm-nbi.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/IM.git#egg=osm-im",
+ 'git+https://osm.etsi.org/gerrit/osm/common.git#egg=osm-common'
],
install_requires=[
- 'CherryPy', 'pymongo', 'jsonschema', 'PyYAML', 'python-keystoneclient'
- # 'osm-common',
+ 'CherryPy==18.0.0',
+ 'osm-common',
+ 'jsonschema',
+ 'PyYAML',
+ 'osm-im',
+ 'python-keystoneclient'
],
setup_requires=['setuptools-version-command'],
- # test_suite='nose.collector',
- # entry_points='''
- # [console_scripts]
- # osm=osm_nbi.nbi:nbi
- # ''',
)
[DEFAULT]
-Depends: python3-cherrypy3, python3-pymongo, python3-yaml, python3-jsonschema, python3-keystoneclient
+X-Python3-Version : >= 3.5
+Depends3 : python3-osm-common, python3-osm-im, python3-cherrypy3, python3-yaml, python3-jsonschema, python3-keystoneclient
--- /dev/null
+# 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
+
+# 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 = stdeb
setuptools-version-command
commands = python3 setup.py --command-packages=stdeb.command bdist_deb
+