From 2c290ca4088492a3c32bb6ab218d0004da68f6ea Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Thu, 6 Apr 2017 03:12:51 +0200 Subject: [PATCH] Restructuring code in osm_ro folder, and setup based on MANIFEST Also updated Makefile and service-openmano.sh Change-Id: I60cf49013315efafd73de377452e38faf2f2f1e0 Signed-off-by: garciadeblas --- MANIFEST.in | 9 ++ Makefile | 49 ++++----- openmanod.py | 8 +- openmano.service => osm-ro.service | 2 +- .../console_proxy_thread.py | 0 db_base.py => osm_ro/db_base.py | 0 httpserver.py => osm_ro/httpserver.py | 0 nfvo.py => osm_ro/nfvo.py | 0 nfvo_db.py => osm_ro/nfvo_db.py | 0 .../openmano_schemas.py | 0 openmanoclient.py => osm_ro/openmanoclient.py | 0 utils.py => osm_ro/utils.py | 0 vim_thread.py => osm_ro/vim_thread.py | 0 vimconn.py => osm_ro/vimconn.py | 0 .../vimconn_openstack.py | 0 .../vimconn_openvim.py | 0 vimconn_vmware.py => osm_ro/vimconn_vmware.py | 0 vmwarecli.py => osm_ro/vmwarecli.py | 0 vmwarerecli.py => osm_ro/vmwarerecli.py | 0 requirements.txt | 36 +++---- scripts/service-openmano.sh | 4 +- setup.py | 99 ++++++++++--------- 22 files changed, 110 insertions(+), 97 deletions(-) create mode 100644 MANIFEST.in rename openmano.service => osm-ro.service (59%) rename console_proxy_thread.py => osm_ro/console_proxy_thread.py (100%) rename db_base.py => osm_ro/db_base.py (100%) rename httpserver.py => osm_ro/httpserver.py (100%) rename nfvo.py => osm_ro/nfvo.py (100%) rename nfvo_db.py => osm_ro/nfvo_db.py (100%) rename openmano_schemas.py => osm_ro/openmano_schemas.py (100%) rename openmanoclient.py => osm_ro/openmanoclient.py (100%) rename utils.py => osm_ro/utils.py (100%) rename vim_thread.py => osm_ro/vim_thread.py (100%) rename vimconn.py => osm_ro/vimconn.py (100%) rename vimconn_openstack.py => osm_ro/vimconn_openstack.py (100%) rename vimconn_openvim.py => osm_ro/vimconn_openvim.py (100%) rename vimconn_vmware.py => osm_ro/vimconn_vmware.py (100%) rename vmwarecli.py => osm_ro/vmwarecli.py (100%) rename vmwarerecli.py => osm_ro/vmwarerecli.py (100%) diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..154ea275 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,9 @@ +#include MANIFEST.in +#include requirements.txt +include README.rst +include openmano +include openmanod.py +include openmanod.cfg +include osm-ro.service +recursive-include osm_ro * + diff --git a/Makefile b/Makefile index b5e6960f..76a29908 100644 --- a/Makefile +++ b/Makefile @@ -2,42 +2,47 @@ SHELL := /bin/bash all: pypackage debpackage prepare: - mkdir -p build - cp *.py build/ - #cd build; mv openmanod.py openmanod - cp openmano build/ - cp openmanod.cfg build/ + mkdir -p build/ + cp MANIFEST.in build/ cp requirements.txt build/ cp README.rst build/ - cp openmano.service build/ - cp -r vnfs build/ - cp -r scenarios build/ - cp -r instance-scenarios build/ - cp -r scripts build/ - cd build/scripts; mv service-openmano.sh service-openmano; mv openmano-report.sh openmano-report - cp -r database_utils build/ + cp setup.py build/ + cp -r osm_ro build/ + cp openmano build/ + cp openmanod.py 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 + cp -r scripts build/osm_ro + cp -r database_utils build/osm_ro connectors: prepare # python-novaclient is required for that - rm -f build/openmanolinkervimconn.py - cd build; for i in `ls vimconn_*.py |sed "s/\.py//"` ; do echo "import $$i" >> openmanolinkervimconn.py; done - python build/openmanolinkervimconn.py - rm -f build/openmanolinkervimconn.py + rm -f build/osm_ro/openmanolinkervimconn.py + cd build/osm_ro; for i in `ls vimconn_*.py |sed "s/\.py//"` ; do echo "import $$i" >> openmanolinkervimconn.py; done + python build/osm_ro/openmanolinkervimconn.py + rm -f build/osm_ro/openmanolinkervimconn.py -build: prepare - python -m py_compile build/*.py +build: connectors prepare + python -m py_compile build/osm_ro/*.py -pypackage: build +pypackage: prepare cd build; ./setup.py sdist - #cp build/dist/* /root/artifacts/... + cd build; ./setup.py bdist_wheel -debpackage: build - echo "Nothing to be done yet" +debpackage: prepare + echo "Nothing to be done" + #cd build; ./setup.py --command-packages=stdeb.command bdist_deb #fpm -s python -t deb build/setup.py snappackage: echo "Nothing to be done yet" +sync: + #cp build/dist/* /root/artifacts/... + test: ./test/basictest.sh --force --insert-bashrc --install-openvim --init-openvim diff --git a/openmanod.py b/openmanod.py index 03901c3f..bb32339c 100755 --- a/openmanod.py +++ b/openmanod.py @@ -37,19 +37,17 @@ __version__="0.5.8-r518" version_date="Jan 2017" database_version="0.19" #expected database schema version -import httpserver import time import sys import getopt import yaml -import nfvo_db from jsonschema import validate as js_v, exceptions as js_e -from openmano_schemas import config_schema -from db_base import db_base_Exception -import nfvo import logging import logging.handlers as log_handlers import socket +from osm_ro import httpserver, nfvo, nfvo_db +from osm_ro.openmano_schemas import config_schema +from osm_ro.db_base import db_base_Exception global global_config global logger diff --git a/openmano.service b/osm-ro.service similarity index 59% rename from openmano.service rename to osm-ro.service index cc8966c8..155150b7 100644 --- a/openmano.service +++ b/osm-ro.service @@ -3,7 +3,7 @@ Description=openmano server (OSM RO) [Service] User=${USER_OWNER} -ExecStart=openmanod -c /etc/osm/openmanod.cfg --log-file=/var/log/osm/openmano.log +ExecStart=openmanod.py -c /etc/osm/openmanod.cfg --log-file=/var/log/osm/openmano.log Restart=always [Install] diff --git a/console_proxy_thread.py b/osm_ro/console_proxy_thread.py similarity index 100% rename from console_proxy_thread.py rename to osm_ro/console_proxy_thread.py diff --git a/db_base.py b/osm_ro/db_base.py similarity index 100% rename from db_base.py rename to osm_ro/db_base.py diff --git a/httpserver.py b/osm_ro/httpserver.py similarity index 100% rename from httpserver.py rename to osm_ro/httpserver.py diff --git a/nfvo.py b/osm_ro/nfvo.py similarity index 100% rename from nfvo.py rename to osm_ro/nfvo.py diff --git a/nfvo_db.py b/osm_ro/nfvo_db.py similarity index 100% rename from nfvo_db.py rename to osm_ro/nfvo_db.py diff --git a/openmano_schemas.py b/osm_ro/openmano_schemas.py similarity index 100% rename from openmano_schemas.py rename to osm_ro/openmano_schemas.py diff --git a/openmanoclient.py b/osm_ro/openmanoclient.py similarity index 100% rename from openmanoclient.py rename to osm_ro/openmanoclient.py diff --git a/utils.py b/osm_ro/utils.py similarity index 100% rename from utils.py rename to osm_ro/utils.py diff --git a/vim_thread.py b/osm_ro/vim_thread.py similarity index 100% rename from vim_thread.py rename to osm_ro/vim_thread.py diff --git a/vimconn.py b/osm_ro/vimconn.py similarity index 100% rename from vimconn.py rename to osm_ro/vimconn.py diff --git a/vimconn_openstack.py b/osm_ro/vimconn_openstack.py similarity index 100% rename from vimconn_openstack.py rename to osm_ro/vimconn_openstack.py diff --git a/vimconn_openvim.py b/osm_ro/vimconn_openvim.py similarity index 100% rename from vimconn_openvim.py rename to osm_ro/vimconn_openvim.py diff --git a/vimconn_vmware.py b/osm_ro/vimconn_vmware.py similarity index 100% rename from vimconn_vmware.py rename to osm_ro/vimconn_vmware.py diff --git a/vmwarecli.py b/osm_ro/vmwarecli.py similarity index 100% rename from vmwarecli.py rename to osm_ro/vmwarecli.py diff --git a/vmwarerecli.py b/osm_ro/vmwarerecli.py similarity index 100% rename from vmwarerecli.py rename to osm_ro/vmwarerecli.py diff --git a/requirements.txt b/requirements.txt index 0f6b6f61..38c055cb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,21 +1,21 @@ --index-url https://pypi.python.org/simple/ -PyYAML==3.10 -bottle==0.12.7 -PyMySQL==0.7.2 -jsonschema==2.5.1 -paramiko==1.16.0 -argcomplete==0.8.1 -requests==2.13.0 -logutils==0.3.3 -python-cinderclient==1.6.0 -python-glanceclient==2.0.0 -python-keystoneclient==2.3.1 -python-neutronclient==4.1.1 -python-novaclient==3.3.1 -pyvcloud==16 -pyvmomi==6.5 -progressbar==2.3 -prettytable==0.7.2 -boto==2.38.0 +PyYAML +bottle +MySQL-python +jsonschema +paramiko +argcomplete +requests +logutils +python-novaclient +python-keystoneclient +python-glanceclient +python-neutronclient +python-cinderclient +pyvcloud +pyvmomi +progressbar +prettytable +boto diff --git a/scripts/service-openmano.sh b/scripts/service-openmano.sh index 1a48d4a3..0224d20f 100755 --- a/scripts/service-openmano.sh +++ b/scripts/service-openmano.sh @@ -116,7 +116,7 @@ do running=y done #if installed as a service and it is not provided a screen name call service - [[ -f /etc/systemd/system/openmano.service ]] && [[ -z $option_screen_name ]] && running=y #&& service openmano status + [[ -f /etc/systemd/system/osm-ro.service ]] && [[ -z $option_screen_name ]] && running=y #&& service osm-ro status if [ -z "$running" ] then echo -n " $om_name not running" && [[ -n "$option_screen_name" ]] && echo " on screen '$option_screen_name'" || echo @@ -124,7 +124,7 @@ do fi #if installed as a service and it is not provided a screen name call service - [[ -f /etc/systemd/system/openmano.service ]] && [[ -z $option_screen_name ]] && service openmano $om_action && ( [[ $om_action == status ]] || sleep 5 ) && exit $? + [[ -f /etc/systemd/system/osm-ro.service ]] && [[ -z $option_screen_name ]] && service osm-ro $om_action && ( [[ $om_action == status ]] || sleep 5 ) && exit $? #stop diff --git a/setup.py b/setup.py index 2d2d07a1..68781be1 100755 --- a/setup.py +++ b/setup.py @@ -1,68 +1,69 @@ #!/usr/bin/env python from setuptools import setup +from setuptools.command.install import install +from os import system #import glob -requirements = [ +_name = 'osm_ro' +_version = '1.0.0' +_description = 'OSM Resource Orchestrator' +_author = 'ETSI OSM' +_author_email = 'alfonso.tiernosepulveda@telefonica.com' +_maintainer = 'garciadeblas' +_maintainer_email = 'gerardo.garciadeblas@telefonica.com' +_license = 'Apache 2.0' +_url = 'https://osm.etsi.org/gitweb/?p=osm/RO.git;a=summary' +_requirements = [ "PyYAML", "bottle", - "mysqldb", + "MySQL-python", "jsonschema", "paramiko", "argcomplete", "requests", "logutils", - "pip", - "novaclient", - "keystoneclient", - "glanceclient", - "neutronclient", - "cinderclient", - "boto", + "python-novaclient", + "python-keystoneclient", + "python-glanceclient", + "python-neutronclient", + "python-cinderclient", "pyvcloud", "progressbar", "prettytable", "pyvmomi", + "boto", ] -setup(name='osm-ro', - version='1.0', - description='OSM Resource Orchestrator', - long_description=open('README.rst').read(), - author='ETSI OSM', - author_email='alfonso.tiernosepulveda@telefonica.com', - maintainer='garciadeblas', - maintainer_email='gerardo.garciadeblas@telefonica.com', - url='https://osm.etsi.org/gitweb/?p=osm/RO.git;a=summary', - license='Apache 2.0', - #packages=['ro-server', 'ro-client'], - #py_modules=glob.glob('*.py') - py_modules=['console_proxy_thread', - 'db_base', - 'httpserver', - 'nfvo_db', - 'nfvo', - 'openmanoclient', - 'openmanoconfig', - 'openmanod', - 'openmano_schemas', - 'utils', - 'vimconn_openstack', - 'vimconn_openvim', - 'vimconn', - 'vimconn_vmware', - 'vmwarecli', - 'vmwarerecli', - ], - install_requires=requirements, - #package_data={'': ['vnfs', 'scenarios', 'instance-scenarios', 'database_utils/mano_db_structure.sql']} - data_files=[('/etc/osm/', ['openmanod.cfg']), - ('/etc/systemd/system/', ['openmano.service']), - ('vnfs', ['vnfs']), - ('scenarios', ['scenarios']), - ('instance-scenarios', ['instance-scenarios']), - ('database_utils', ['database-utils']), - ], - scripts=['openmanod.py', 'openmano', 'scripts/service-openmano', 'scripts/openmano-report',] - ) +class ROInstaller(install): + def run(self): + cmd = 'echo "Running install script"' + system(cmd) + install.run(self) + +setup(name=_name, + version = _version, + description = _description, + long_description = open('README.rst').read(), + author = _author, + author_email = _author_email, + maintainer = _maintainer, + maintainer_email = _maintainer_email, + url = _url, + license = _license, + packages = [_name], + #packages = ['osm_ro', 'osm_roclient'], + package_dir = {_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=['openmanod.py', 'openmano', 'osm_ro/scripts/service-openmano.sh', 'osm_ro/scripts/openmano-report.sh',], + install_requires=_requirements, + include_package_data=True, + cmdclass = {'install': ROInstaller}, + ) -- 2.25.1