From e5ef517abec7db86ce2ee7cba628548ce4b5a6fd Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Thu, 20 Apr 2017 14:46:29 +0200 Subject: [PATCH] Support of debian packaging via stdeb; postinst script; renaming some files Change-Id: I966a27d84688ee2e7083324033ebea3ade6fc871 Signed-off-by: garciadeblas --- MANIFEST.in | 3 +- Makefile | 26 +++++----- openmanod.cfg => osm_ro/openmanod.cfg | 0 osm-ro.service => osm_ro/osm-ro.service | 0 .../{openmano-report.sh => openmano-report} | 0 scripts/python-osm-ro.postinst | 49 +++++++++++++++++++ .../{service-openmano.sh => service-openmano} | 0 setup.py | 20 +++----- stdeb.cfg | 6 +++ 9 files changed, 76 insertions(+), 28 deletions(-) rename openmanod.cfg => osm_ro/openmanod.cfg (100%) rename osm-ro.service => osm_ro/osm-ro.service (100%) rename scripts/{openmano-report.sh => openmano-report} (100%) create mode 100755 scripts/python-osm-ro.postinst rename scripts/{service-openmano.sh => service-openmano} (100%) create mode 100644 stdeb.cfg diff --git a/MANIFEST.in b/MANIFEST.in index f586ebf3..48790d46 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,9 +1,8 @@ #include MANIFEST.in #include requirements.txt include README.rst +include RO_VERSION include openmano include openmanod -include openmanod.cfg -include osm-ro.service recursive-include osm_ro * diff --git a/Makefile b/Makefile index 226bcb41..5bde339b 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,19 @@ SHELL := /bin/bash -all: pip deb +all: package install prepare: pip install setuptools - #pip install -r requirements.txt mkdir -p build/ + #git describe | sed -e 's/^v//' > build/RO_VERSION + echo "1.1.5" > build/RO_VERSION cp MANIFEST.in build/ cp requirements.txt build/ cp README.rst build/ cp setup.py build/ + cp stdeb.cfg build/ cp -r osm_ro build/ cp openmano build/ cp openmanod build/ - cp openmanod.cfg build/ - cp osm-ro.service build/ cp -r vnfs build/osm_ro cp -r scenarios build/osm_ro cp -r instance-scenarios build/osm_ro @@ -32,25 +32,25 @@ build: connectors prepare pip: prepare cd build && ./setup.py sdist - cd build && ./setup.py bdist_wheel -deb: prepare - echo "Nothing to be done" - #cd build; ./setup.py --command-packages=stdeb.command bdist_deb - #fpm -s python -t deb build/setup.py +package: prepare + cd build && python setup.py --command-packages=stdeb.command sdist_dsc --with-python2=True + cd build && cp osm_ro/scripts/python-osm-ro.postinst deb_dist/osm-ro*/debian/ + cd build/deb_dist/osm-ro* && dpkg-buildpackage -rfakeroot -uc -us snap: echo "Nothing to be done yet" install: - cd build && pip install dist/*.tar.gz + DEBIAN_FRONTEND=noninteractive apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y python-pip && \ + pip install --upgrade pip && \ + dpkg -i build/deb_dist/*.deb develop: prepare + #pip install -r requirements.txt cd build && ./setup.py develop -sync: - #cp build/dist/* /root/artifacts/... - test: ./test/basictest.sh --force --insert-bashrc --install-openvim --init-openvim diff --git a/openmanod.cfg b/osm_ro/openmanod.cfg similarity index 100% rename from openmanod.cfg rename to osm_ro/openmanod.cfg diff --git a/osm-ro.service b/osm_ro/osm-ro.service similarity index 100% rename from osm-ro.service rename to osm_ro/osm-ro.service diff --git a/scripts/openmano-report.sh b/scripts/openmano-report similarity index 100% rename from scripts/openmano-report.sh rename to scripts/openmano-report diff --git a/scripts/python-osm-ro.postinst b/scripts/python-osm-ro.postinst new file mode 100755 index 00000000..00f24002 --- /dev/null +++ b/scripts/python-osm-ro.postinst @@ -0,0 +1,49 @@ +#!/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-RO" +OSMRO_PATH=`python -c 'import osm_ro; print osm_ro.__path__[0]'` +#OSMLIBOVIM_PATH=`python -c 'import lib_osm_openvim; print lib_osm_openvim.__path__[0]'` + +#Pip packages required for vmware connector +pip install --upgrade pip +pip install pyvcloud +pip install progressbar +pip install prettytable +pip install pyvmomi + +systemctl enable osm-ro.service + +#Creation of log folder +mkdir -p /var/log/osm + +#configure arg-autocomplete for this user +su $SUDO_USER -c 'activate-global-python-argcomplete --user' +if ! su $SUDO_USER -c 'grep -q bash_completion.d/python-argcomplete.sh ${HOME}/.bashrc' +then + echo " inserting .bash_completion.d/python-argcomplete.sh execution at .bashrc" + su $SUDO_USER -c 'echo ". ${HOME}/.bash_completion.d/python-argcomplete.sh" >> ~/.bashrc' +fi + +echo ' +To make OSM RO work, you have to install mysql and a database, and finally start openmano service' +echo ' ${OSMRO_PATH}/scripts/install-db-server.sh -u USER -p ' +echo ' service openmano start' + + diff --git a/scripts/service-openmano.sh b/scripts/service-openmano similarity index 100% rename from scripts/service-openmano.sh rename to scripts/service-openmano diff --git a/setup.py b/setup.py index 20b6c3a4..fb389700 100755 --- a/setup.py +++ b/setup.py @@ -1,12 +1,13 @@ #!/usr/bin/env python +#from distutils.core import setup +#from distutils.command.install_data import install_data from setuptools import setup -from setuptools.command.install import install from os import system #import glob _name = 'osm_ro' -_version = '1.0.0' +_version = open('RO_VERSION').read() _description = 'OSM Resource Orchestrator' _author = 'ETSI OSM' _author_email = 'alfonso.tiernosepulveda@telefonica.com' @@ -35,12 +36,6 @@ _requirements = [ "boto", ] -class ROInstaller(install): - def run(self): - cmd = 'echo "Running install script"' - system(cmd) - install.run(self) - setup(name=_name, version = _version, description = _description, @@ -57,13 +52,12 @@ setup(name=_name, package_data = {_name: ['vnfs/*.yaml', 'vnfs/examples/*.yaml', 'scenarios/*.yaml', 'scenarios/examples/*.yaml', 'instance-scenarios/examples/*.yaml', 'database_utils/*', - 'scripts/install-openmano*.sh']}, - data_files = [('/etc/osm/', ['openmanod.cfg']), - ('/etc/systemd/system/', ['osm-ro.service']), + 'scripts/*']}, + data_files = [('/etc/osm/', ['osm_ro/openmanod.cfg']), + ('/etc/systemd/system/', ['osm_ro/osm-ro.service']), ], - scripts=['openmanod', 'openmano', 'osm_ro/scripts/service-openmano.sh', 'osm_ro/scripts/openmano-report.sh',], + scripts=['openmanod', 'openmano', 'osm_ro/scripts/service-openmano', 'osm_ro/scripts/openmano-report',], install_requires=_requirements, include_package_data=True, - cmdclass = {'install': ROInstaller}, ) diff --git a/stdeb.cfg b/stdeb.cfg new file mode 100644 index 00000000..09787370 --- /dev/null +++ b/stdeb.cfg @@ -0,0 +1,6 @@ +[DEFAULT] +Suite: xenial +XS-Python-Version: >= 2.7 +Maintainer: Gerardo Garcia +Depends: python-pip, libmysqlclient-dev, libssl-dev, libffi-dev, python-argcomplete, python-boto, python-bottle, python-jsonschema, python-logutils, python-cinderclient, python-glanceclient, python-keystoneclient, python-neutronclient, python-novaclient, python-mysqldb, mysql-server + -- 2.25.1