From: garciadeblas Date: Thu, 20 Apr 2017 12:46:29 +0000 (+0200) Subject: Support of debian packaging via stdeb; postinst script; renaming some files X-Git-Tag: v2.0.0~22^2~2 X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FRO.git;a=commitdiff_plain;h=e5ef517abec7db86ce2ee7cba628548ce4b5a6fd Support of debian packaging via stdeb; postinst script; renaming some files Change-Id: I966a27d84688ee2e7083324033ebea3ade6fc871 Signed-off-by: garciadeblas --- 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/openmanod.cfg deleted file mode 100644 index ebcee2b6..00000000 --- a/openmanod.cfg +++ /dev/null @@ -1,78 +0,0 @@ -## -# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U. -# This file is part of openmano -# All Rights Reserved. -# -# 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: nfvlabs@tid.es -## - -#HTTP Server parameters (MANO API). IP address and port where openmanod listens -# IPtables/firewalld must allow this port -# for CentOS/Redhad firewalld is configured at '/etc/firewalld/services/openmanod.xml' -# edit this file and reload firewalld with 'firewall-cmd --reload' if port is changed -http_host: 0.0.0.0 # IP address, (by default, 0.0.0.0 means that it will listen in all interfaces) -http_port: 9090 # General port (by default, 9090) -#http_admin_port: 9095 # Admin port where openmano is listening (when missing, no administration server is launched) - # Not used in current version! - -#Parameters for a VIM console access. Can be directly the VIM URL or a proxy to offer the openmano IP address -http_console_proxy: False #by default True. If False proxy is not implemented and VIM URL is offered. It is - #assumed then, that client can access directly to the VIMs -#http_console_host: #by default the same as 'http_host'. However is openmano server is behind a NAT/proxy - #you should specify the public IP used to access the server. Also when 'http_host' is - #0.0.0.0 you should specify the concrete IP address (or name) the server is accessed -# Ports to be used. Comma separated list. Can contain a {"from":, "to":} entry -#e.g. from 9000 to 9005: [{"from":9000, "to":9005}], or also [9000,9001,9002,9003,9004,9005] -#e.g. from 9000 to 9100 apart from 9050,9053: [{"from":9000, "to":9049},9051,9052,{"from":9054, "to":9099}] -http_console_ports: [{"from":9096, "to":9110}] - -#Database parameters -db_host: localhost # by default localhost -db_user: mano # DB user -db_passwd: manopw # DB password -db_name: mano_db # Name of the MANO DB - -#other MANO parameters -# Folder where the VNF descriptors will be stored -# The folder will be created in the execution folder if it does not exist -#vnf_repository: "./vnfrepo" # Use an absolute path to avoid misunderstandings - -# Indicates if at VNF onboarding, flavors and images are loaded at all related VIMs, -# in order to speed up the later instantiation. -auto_push_VNF_to_VIMs: False # by default True - -#general logging parameters - #choose among: DEBUG, INFO, WARNING, ERROR, CRITICAL -log_level: DEBUG #general log levels for internal logging -#standard output is used unless 'log_file' is specify -#log_file: /var/log/openmano/openmano.log - -#individual logging settings -#log_level_db: DEBUG #database log levels -#log_file_db: /opt/openmano/logs/openmano_db.log -#log_level_vim: DEBUG #VIM connection log levels -#log_file_vim: /opt/openmano/logs/openmano_vimconn.log -#log_level_nfvo: DEBUG #Main engine log levels -#log_file_nfvo: /opt/openmano/logs/openmano_nfvo.log -#log_level_http: DEBUG #Main engine log levels -#log_file_http: /opt/openmano/logs/openmano_http.log -#log_level_console: DEBUG #proxy console log levels -#log_file_console: /opt/openmano/logs/openmano_console.log - -#Uncomment to send logs via IP to an external host -#log_socket_host: localhost -log_socket_port: 9022 -log_socket_level: DEBUG #general log levels for socket logging diff --git a/osm-ro.service b/osm-ro.service deleted file mode 100644 index cc8966c8..00000000 --- a/osm-ro.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=openmano server (OSM RO) - -[Service] -User=${USER_OWNER} -ExecStart=openmanod -c /etc/osm/openmanod.cfg --log-file=/var/log/osm/openmano.log -Restart=always - -[Install] -WantedBy=multi-user.target - diff --git a/osm_ro/openmanod.cfg b/osm_ro/openmanod.cfg new file mode 100644 index 00000000..ebcee2b6 --- /dev/null +++ b/osm_ro/openmanod.cfg @@ -0,0 +1,78 @@ +## +# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U. +# This file is part of openmano +# All Rights Reserved. +# +# 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: nfvlabs@tid.es +## + +#HTTP Server parameters (MANO API). IP address and port where openmanod listens +# IPtables/firewalld must allow this port +# for CentOS/Redhad firewalld is configured at '/etc/firewalld/services/openmanod.xml' +# edit this file and reload firewalld with 'firewall-cmd --reload' if port is changed +http_host: 0.0.0.0 # IP address, (by default, 0.0.0.0 means that it will listen in all interfaces) +http_port: 9090 # General port (by default, 9090) +#http_admin_port: 9095 # Admin port where openmano is listening (when missing, no administration server is launched) + # Not used in current version! + +#Parameters for a VIM console access. Can be directly the VIM URL or a proxy to offer the openmano IP address +http_console_proxy: False #by default True. If False proxy is not implemented and VIM URL is offered. It is + #assumed then, that client can access directly to the VIMs +#http_console_host: #by default the same as 'http_host'. However is openmano server is behind a NAT/proxy + #you should specify the public IP used to access the server. Also when 'http_host' is + #0.0.0.0 you should specify the concrete IP address (or name) the server is accessed +# Ports to be used. Comma separated list. Can contain a {"from":, "to":} entry +#e.g. from 9000 to 9005: [{"from":9000, "to":9005}], or also [9000,9001,9002,9003,9004,9005] +#e.g. from 9000 to 9100 apart from 9050,9053: [{"from":9000, "to":9049},9051,9052,{"from":9054, "to":9099}] +http_console_ports: [{"from":9096, "to":9110}] + +#Database parameters +db_host: localhost # by default localhost +db_user: mano # DB user +db_passwd: manopw # DB password +db_name: mano_db # Name of the MANO DB + +#other MANO parameters +# Folder where the VNF descriptors will be stored +# The folder will be created in the execution folder if it does not exist +#vnf_repository: "./vnfrepo" # Use an absolute path to avoid misunderstandings + +# Indicates if at VNF onboarding, flavors and images are loaded at all related VIMs, +# in order to speed up the later instantiation. +auto_push_VNF_to_VIMs: False # by default True + +#general logging parameters + #choose among: DEBUG, INFO, WARNING, ERROR, CRITICAL +log_level: DEBUG #general log levels for internal logging +#standard output is used unless 'log_file' is specify +#log_file: /var/log/openmano/openmano.log + +#individual logging settings +#log_level_db: DEBUG #database log levels +#log_file_db: /opt/openmano/logs/openmano_db.log +#log_level_vim: DEBUG #VIM connection log levels +#log_file_vim: /opt/openmano/logs/openmano_vimconn.log +#log_level_nfvo: DEBUG #Main engine log levels +#log_file_nfvo: /opt/openmano/logs/openmano_nfvo.log +#log_level_http: DEBUG #Main engine log levels +#log_file_http: /opt/openmano/logs/openmano_http.log +#log_level_console: DEBUG #proxy console log levels +#log_file_console: /opt/openmano/logs/openmano_console.log + +#Uncomment to send logs via IP to an external host +#log_socket_host: localhost +log_socket_port: 9022 +log_socket_level: DEBUG #general log levels for socket logging diff --git a/osm_ro/osm-ro.service b/osm_ro/osm-ro.service new file mode 100644 index 00000000..cc8966c8 --- /dev/null +++ b/osm_ro/osm-ro.service @@ -0,0 +1,11 @@ +[Unit] +Description=openmano server (OSM RO) + +[Service] +User=${USER_OWNER} +ExecStart=openmanod -c /etc/osm/openmanod.cfg --log-file=/var/log/osm/openmano.log +Restart=always + +[Install] +WantedBy=multi-user.target + diff --git a/scripts/openmano-report b/scripts/openmano-report new file mode 100755 index 00000000..9402facc --- /dev/null +++ b/scripts/openmano-report @@ -0,0 +1,170 @@ +#!/bin/bash + +## +# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U. +# This file is part of openmano +# All Rights Reserved. +# +# 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: nfvlabs@tid.es +## + +#It generates a report for debugging + +DIRNAME=$(readlink -f ${BASH_SOURCE[0]}) +DIRNAME=$(dirname $DIRNAME ) +OMCLIENT=$DIRNAME/../openmano/openmano +OVCLIENT=$DIRNAME/../openvim/openvim + +#get screen log files at the beginning +echo +echo "-------------------------------" +echo "log files" +echo "-------------------------------" +echo "-------------------------------" +echo "OPENMANO" +echo "-------------------------------" +echo "cat $DIRNAME/../logs/openmano.log*" +cat $DIRNAME/../logs/openmano.log* +echo +echo "-------------------------------" +echo "OPENVIM" +echo "-------------------------------" +echo "cat $DIRNAME/../logs/openvim.?" +cat $DIRNAME/../logs/openvim.? +echo +echo "-------------------------------" +echo + +#get version +echo +echo "-------------------------------" +echo "version" +echo "-------------------------------" +echo "-------------------------------" +echo "OPENMANO" +echo "-------------------------------" +echo "cat $DIRNAME/../openmano/openmanod.py|grep ^__version__" +cat $DIRNAME/../openmano/openmanod.py|grep ^__version__ +echo +echo "-------------------------------" +echo "OPENVIM" +echo "-------------------------------" +echo "cat $DIRNAME/../openvim/openvimd.py|grep ^__version__" +cat $DIRNAME/../openvim/openvimd.py|grep ^__version__ +echo +echo "-------------------------------" +echo + +#get configuration files +echo "-------------------------------" +echo "Configuration files" +echo "-------------------------------" +echo "-------------------------------" +echo "OPENMANO" +echo "-------------------------------" +echo "cat $DIRNAME/../openmano/openmanod.cfg" +cat $DIRNAME/../openmano/openmanod.cfg +echo "-------------------------------" +echo "OPENVIM" +echo "-------------------------------" +echo "cat $DIRNAME/../openvim/openvimd.cfg" +cat $DIRNAME/../openvim/openvimd.cfg +echo "-------------------------------" +echo + +#get list of items +for verbose in "" "-vvv" +do + echo "-------------------------------" + echo "OPENMANO$verbose" + echo "-------------------------------" + echo "$OMCLIENT config $verbose" + $OMCLIENT config + echo "-------------------------------" + echo "$OMCLIENT tenant-list $verbose" + $OMCLIENT tenant-list $verbose + echo "-------------------------------" + echo "$OMCLIENT datacenter-list --all" + $OMCLIENT datacenter-list --all + echo "-------------------------------" + echo "$OMCLIENT datacenter-list $verbose" + $OMCLIENT datacenter-list $verbose + echo "-------------------------------" + dclist=`$OMCLIENT datacenter-list |awk '{print $1}'` + for dc in $dclist; do + echo "$OMCLIENT datacenter-net-list $dc $verbose" + $OMCLIENT datacenter-net-list $dc $verbose + echo "-------------------------------" + done + echo "$OMCLIENT vnf-list $verbose" + $OMCLIENT vnf-list $verbose + echo "-------------------------------" + vnflist=`$OMCLIENT vnf-list |awk '$1!="No" {print $1}'` + for vnf in $vnflist; do + echo "$OMCLIENT vnf-list $vnf $verbose" + $OMCLIENT vnf-list $vnf $verbose + echo "-------------------------------" + done + echo "$OMCLIENT scenario-list $verbose" + $OMCLIENT scenario-list $verbose + echo "-------------------------------" + scenariolist=`$OMCLIENT scenario-list |awk '$1!="No" {print $1}'` + for sce in $scenariolist; do + echo "$OMCLIENT scenario-list $sce $verbose" + $OMCLIENT scenario-list $sce $verbose + echo "-------------------------------" + done + echo "$OMCLIENT instance-scenario-list $verbose" + $OMCLIENT instance-scenario-list $verbose + echo "-------------------------------" + instancelist=`$OMCLIENT instance-scenario-list |awk '$1!="No" {print $1}'` + for i in $instancelist; do + echo "$OMCLIENT instance-scenario-list $i $verbose" + $OMCLIENT instance-scenario-list $i $verbose + echo "-------------------------------" + done + echo + echo "-------------------------------" + echo "OPENVIM$verbose" + echo "-------------------------------" + echo "$OVCLIENT config" + $OVCLIENT config + echo "-------------------------------" + echo "$OVCLIENT tenant-list $verbose" + $OVCLIENT tenant-list $verbose + echo "-------------------------------" + echo "$OVCLIENT host-list $verbose" + $OVCLIENT host-list $verbose + echo "-------------------------------" + echo "$OVCLIENT net-list $verbose" + $OVCLIENT net-list $verbose + echo "-------------------------------" + echo "$OVCLIENT port-list $verbose" + $OVCLIENT port-list $verbose + echo "-------------------------------" + echo "$OVCLIENT flavor-list $verbose" + $OVCLIENT flavor-list $verbose + echo "-------------------------------" + echo "$OVCLIENT image-list $verbose" + $OVCLIENT image-list $verbose + echo "-------------------------------" + echo "$OVCLIENT vm-list $verbose" + $OVCLIENT vm-list $verbose + echo "-------------------------------" + echo + +done +echo diff --git a/scripts/openmano-report.sh b/scripts/openmano-report.sh deleted file mode 100755 index 9402facc..00000000 --- a/scripts/openmano-report.sh +++ /dev/null @@ -1,170 +0,0 @@ -#!/bin/bash - -## -# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U. -# This file is part of openmano -# All Rights Reserved. -# -# 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: nfvlabs@tid.es -## - -#It generates a report for debugging - -DIRNAME=$(readlink -f ${BASH_SOURCE[0]}) -DIRNAME=$(dirname $DIRNAME ) -OMCLIENT=$DIRNAME/../openmano/openmano -OVCLIENT=$DIRNAME/../openvim/openvim - -#get screen log files at the beginning -echo -echo "-------------------------------" -echo "log files" -echo "-------------------------------" -echo "-------------------------------" -echo "OPENMANO" -echo "-------------------------------" -echo "cat $DIRNAME/../logs/openmano.log*" -cat $DIRNAME/../logs/openmano.log* -echo -echo "-------------------------------" -echo "OPENVIM" -echo "-------------------------------" -echo "cat $DIRNAME/../logs/openvim.?" -cat $DIRNAME/../logs/openvim.? -echo -echo "-------------------------------" -echo - -#get version -echo -echo "-------------------------------" -echo "version" -echo "-------------------------------" -echo "-------------------------------" -echo "OPENMANO" -echo "-------------------------------" -echo "cat $DIRNAME/../openmano/openmanod.py|grep ^__version__" -cat $DIRNAME/../openmano/openmanod.py|grep ^__version__ -echo -echo "-------------------------------" -echo "OPENVIM" -echo "-------------------------------" -echo "cat $DIRNAME/../openvim/openvimd.py|grep ^__version__" -cat $DIRNAME/../openvim/openvimd.py|grep ^__version__ -echo -echo "-------------------------------" -echo - -#get configuration files -echo "-------------------------------" -echo "Configuration files" -echo "-------------------------------" -echo "-------------------------------" -echo "OPENMANO" -echo "-------------------------------" -echo "cat $DIRNAME/../openmano/openmanod.cfg" -cat $DIRNAME/../openmano/openmanod.cfg -echo "-------------------------------" -echo "OPENVIM" -echo "-------------------------------" -echo "cat $DIRNAME/../openvim/openvimd.cfg" -cat $DIRNAME/../openvim/openvimd.cfg -echo "-------------------------------" -echo - -#get list of items -for verbose in "" "-vvv" -do - echo "-------------------------------" - echo "OPENMANO$verbose" - echo "-------------------------------" - echo "$OMCLIENT config $verbose" - $OMCLIENT config - echo "-------------------------------" - echo "$OMCLIENT tenant-list $verbose" - $OMCLIENT tenant-list $verbose - echo "-------------------------------" - echo "$OMCLIENT datacenter-list --all" - $OMCLIENT datacenter-list --all - echo "-------------------------------" - echo "$OMCLIENT datacenter-list $verbose" - $OMCLIENT datacenter-list $verbose - echo "-------------------------------" - dclist=`$OMCLIENT datacenter-list |awk '{print $1}'` - for dc in $dclist; do - echo "$OMCLIENT datacenter-net-list $dc $verbose" - $OMCLIENT datacenter-net-list $dc $verbose - echo "-------------------------------" - done - echo "$OMCLIENT vnf-list $verbose" - $OMCLIENT vnf-list $verbose - echo "-------------------------------" - vnflist=`$OMCLIENT vnf-list |awk '$1!="No" {print $1}'` - for vnf in $vnflist; do - echo "$OMCLIENT vnf-list $vnf $verbose" - $OMCLIENT vnf-list $vnf $verbose - echo "-------------------------------" - done - echo "$OMCLIENT scenario-list $verbose" - $OMCLIENT scenario-list $verbose - echo "-------------------------------" - scenariolist=`$OMCLIENT scenario-list |awk '$1!="No" {print $1}'` - for sce in $scenariolist; do - echo "$OMCLIENT scenario-list $sce $verbose" - $OMCLIENT scenario-list $sce $verbose - echo "-------------------------------" - done - echo "$OMCLIENT instance-scenario-list $verbose" - $OMCLIENT instance-scenario-list $verbose - echo "-------------------------------" - instancelist=`$OMCLIENT instance-scenario-list |awk '$1!="No" {print $1}'` - for i in $instancelist; do - echo "$OMCLIENT instance-scenario-list $i $verbose" - $OMCLIENT instance-scenario-list $i $verbose - echo "-------------------------------" - done - echo - echo "-------------------------------" - echo "OPENVIM$verbose" - echo "-------------------------------" - echo "$OVCLIENT config" - $OVCLIENT config - echo "-------------------------------" - echo "$OVCLIENT tenant-list $verbose" - $OVCLIENT tenant-list $verbose - echo "-------------------------------" - echo "$OVCLIENT host-list $verbose" - $OVCLIENT host-list $verbose - echo "-------------------------------" - echo "$OVCLIENT net-list $verbose" - $OVCLIENT net-list $verbose - echo "-------------------------------" - echo "$OVCLIENT port-list $verbose" - $OVCLIENT port-list $verbose - echo "-------------------------------" - echo "$OVCLIENT flavor-list $verbose" - $OVCLIENT flavor-list $verbose - echo "-------------------------------" - echo "$OVCLIENT image-list $verbose" - $OVCLIENT image-list $verbose - echo "-------------------------------" - echo "$OVCLIENT vm-list $verbose" - $OVCLIENT vm-list $verbose - echo "-------------------------------" - echo - -done -echo 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 b/scripts/service-openmano new file mode 100755 index 00000000..0224d20f --- /dev/null +++ b/scripts/service-openmano @@ -0,0 +1,212 @@ +#!/bin/bash + +## +# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U. +# This file is part of openmano +# All Rights Reserved. +# +# 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: nfvlabs@tid.es +## + + +#launch openmano inside a screen. +#or call service if it is installed on systemd + + +DIRNAME=$(readlink -f ${BASH_SOURCE[0]}) +DIRNAME=$(dirname $DIRNAME ) +DIR_OM=$(dirname $DIRNAME ) + +function usage(){ + echo -e "Usage: $0 [openmano/mano] start|stop|restart|status" + echo -e " Launch|Removes|Restart|Getstatus openmano on a screen/service" + echo -e " -n --screen-name NAME : name of screen to launch openmano (default mano or service)" + echo -e " -h --help: shows this help" + echo -e " -- PARAMS use to separate PARAMS that will be send to the service. e.g. -pPORT -PADMINPORT --dbname=DDBB" +} + + +function kill_pid(){ + #send TERM signal and wait 5 seconds and send KILL signal ir still running + #PARAMS: $1: PID of process to terminate + kill $1 #send TERM signal + WAIT=5 + while [ $WAIT -gt 0 ] && ps -o pid -U $USER -u $USER | grep -q $1 + do + sleep 1 + WAIT=$((WAIT-1)) + [ $WAIT -eq 0 ] && echo -n "sending SIGKILL... " && kill -9 $1 #kill when count reach 0 + done + echo "done" +} + +#process options +source ${DIRNAME}/get-options.sh "screen-name:n= help:h --" $* || exit 1 + +#help +[ -n "$option_help" ] && usage && exit 0 + + +#obtain parameters +om_list="" +#om_action="start" #uncoment to get a default action +action_list="" +om_params="$option__" + +for param in $params +do + [ "$param" == "start" -o "$param" == "stop" -o "$param" == "restart" -o "$param" == "status" ] && om_action=$param && continue + [ "$param" == "openmano" -o "$param" == "mano" ] && om_list="$om_list mano" && continue + #short options + echo "invalid argument '$param'? Type -h for help" >&2 && exit 1 +done + +[[ -n $option_screen_name ]] && option_screen_name=${option_screen_name#*.} #allow the format 'pid.name' and keep only name +#check action is provided +[ -z "$om_action" ] && usage >&2 && exit -1 + +#if no componenets supplied assume all +[ -z "$om_list" ] && om_list="mano" + +function find_process_id(){ #PARAMS: command screen-name + for process_id in `ps -o pid,cmd -U $USER -u $USER | grep -v grep | grep "${1}" | awk '{print $1}'` + do + scname=$(ps wwep $process_id | grep -o 'STY=\S*') + scname=${scname#STY=} + [[ -n "$2" ]] && [[ "${scname#*.}" != "$2" ]] && continue + echo -n "${process_id} " + done + echo +} + +for om_component in $om_list +do + screen_name="${om_component}" + [[ -n "$option_screen_name" ]] && screen_name=$option_screen_name + [ "${om_component}" == "mano" ] && om_cmd="./openmanod.py" && om_name="openmano " && om_dir=$(readlink -f ${DIR_OM}) + #obtain PID of program + component_id=`find_process_id "${om_cmd}" $option_screen_name` + processes=$(echo $component_id | wc -w) + + #status + if [ "$om_action" == "status" ] + then + running="" + for process_id in $component_id + do + scname=$(ps wwep $process_id | grep -o 'STY=\S*') + scname=${scname#STY=} + [[ -n "$option_screen_name" ]] && [[ "${scname#*.}" != "$option_screen_name" ]] && continue + printf "%-15s" "pid: ${process_id}," + [[ -n "$scname" ]] && printf "%-25s" "screen: ${scname}," + echo cmd: $(ps -o cmd p $process_id | tail -n1 ) + running=y + done + #if installed as a service and it is not provided a screen name call service + [[ -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 + fi + fi + + #if installed as a service and it is not provided a screen name call service + [[ -f /etc/systemd/system/osm-ro.service ]] && [[ -z $option_screen_name ]] && service osm-ro $om_action && ( [[ $om_action == status ]] || sleep 5 ) && exit $? + + + #stop + if [ "$om_action" == "stop" -o "$om_action" == "restart" ] + then + #terminates program + [ $processes -gt 1 ] && echo "$processes processes are running, specify with --screen-name" && continue + [ $processes -eq 1 ] && echo -n " stopping $om_name ... " && kill_pid $component_id + component_id="" + #terminates screen + if screen -wipe | grep -q -e "\.${screen_name}\b" + then + screen -S $screen_name -p 0 -X stuff "exit\n" || echo + sleep 1 + fi + fi + + #start + if [ "$om_action" == "start" -o "$om_action" == "restart" ] + then + #calculates log file name + logfile="" + mkdir -p $DIR_OM/logs && logfile=$DIR_OM/logs/open${screen_name}.log || echo "can not create logs directory $DIR_OM/logs" + #check already running + [ -n "$component_id" ] && echo " $om_name is already running. Skipping" && continue + #create screen if not created + echo -n " starting $om_name ... " + if ! screen -wipe | grep -q -e "\.${screen_name}\b" + then + pushd ${om_dir} > /dev/null + screen -dmS ${screen_name} bash + sleep 1 + popd > /dev/null + else + echo -n " using existing screen '${screen_name}' ... " + screen -S ${screen_name} -p 0 -X log off + screen -S ${screen_name} -p 0 -X stuff "cd ${om_dir}\n" + sleep 1 + fi + #move old log file index one number up and log again in index 0 + if [[ -n $logfile ]] + then + for index in 8 7 6 5 4 3 2 1 + do + [[ -f ${logfile}.${index} ]] && mv ${logfile}.${index} ${logfile}.$((index+1)) + done + [[ -f ${logfile} ]] && mv ${logfile} ${logfile}.1 + screen -S ${screen_name} -p 0 -X logfile ${logfile} + screen -S ${screen_name} -p 0 -X log on + fi + #launch command to screen + screen -S ${screen_name} -p 0 -X stuff "${om_cmd}${om_params}\n" + #check if is running + [[ -n $logfile ]] && timeout=120 #2 minute + [[ -z $logfile ]] && timeout=20 + while [[ $timeout -gt 0 ]] + do + #check if is running + #echo timeout $timeout + #if ! ps -f -U $USER -u $USER | grep -v grep | grep -q ${om_cmd} + log_lines=0 + [[ -n $logfile ]] && log_lines=`head ${logfile} | wc -l` + component_id=`find_process_id "${om_cmd}${om_params}" $screen_name` + if [[ -z $component_id ]] + then #process not started or finished + [[ $log_lines -ge 2 ]] && echo -n "ERROR, it has exited." && break + #started because writted serveral lines at log so report error + fi + [[ -n $logfile ]] && grep -q "open${om_component}d ready" ${logfile} && break + sleep 1 + timeout=$((timeout -1)) + done + if [[ -n $logfile ]] && [[ $timeout == 0 ]] + then + echo -n "timeout!" + else + echo -n "running on 'screen -x ${screen_name}'." + fi + [[ -n $logfile ]] && echo " Logging at '${logfile}'" || echo + fi +done + + + + diff --git a/scripts/service-openmano.sh b/scripts/service-openmano.sh deleted file mode 100755 index 0224d20f..00000000 --- a/scripts/service-openmano.sh +++ /dev/null @@ -1,212 +0,0 @@ -#!/bin/bash - -## -# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U. -# This file is part of openmano -# All Rights Reserved. -# -# 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: nfvlabs@tid.es -## - - -#launch openmano inside a screen. -#or call service if it is installed on systemd - - -DIRNAME=$(readlink -f ${BASH_SOURCE[0]}) -DIRNAME=$(dirname $DIRNAME ) -DIR_OM=$(dirname $DIRNAME ) - -function usage(){ - echo -e "Usage: $0 [openmano/mano] start|stop|restart|status" - echo -e " Launch|Removes|Restart|Getstatus openmano on a screen/service" - echo -e " -n --screen-name NAME : name of screen to launch openmano (default mano or service)" - echo -e " -h --help: shows this help" - echo -e " -- PARAMS use to separate PARAMS that will be send to the service. e.g. -pPORT -PADMINPORT --dbname=DDBB" -} - - -function kill_pid(){ - #send TERM signal and wait 5 seconds and send KILL signal ir still running - #PARAMS: $1: PID of process to terminate - kill $1 #send TERM signal - WAIT=5 - while [ $WAIT -gt 0 ] && ps -o pid -U $USER -u $USER | grep -q $1 - do - sleep 1 - WAIT=$((WAIT-1)) - [ $WAIT -eq 0 ] && echo -n "sending SIGKILL... " && kill -9 $1 #kill when count reach 0 - done - echo "done" -} - -#process options -source ${DIRNAME}/get-options.sh "screen-name:n= help:h --" $* || exit 1 - -#help -[ -n "$option_help" ] && usage && exit 0 - - -#obtain parameters -om_list="" -#om_action="start" #uncoment to get a default action -action_list="" -om_params="$option__" - -for param in $params -do - [ "$param" == "start" -o "$param" == "stop" -o "$param" == "restart" -o "$param" == "status" ] && om_action=$param && continue - [ "$param" == "openmano" -o "$param" == "mano" ] && om_list="$om_list mano" && continue - #short options - echo "invalid argument '$param'? Type -h for help" >&2 && exit 1 -done - -[[ -n $option_screen_name ]] && option_screen_name=${option_screen_name#*.} #allow the format 'pid.name' and keep only name -#check action is provided -[ -z "$om_action" ] && usage >&2 && exit -1 - -#if no componenets supplied assume all -[ -z "$om_list" ] && om_list="mano" - -function find_process_id(){ #PARAMS: command screen-name - for process_id in `ps -o pid,cmd -U $USER -u $USER | grep -v grep | grep "${1}" | awk '{print $1}'` - do - scname=$(ps wwep $process_id | grep -o 'STY=\S*') - scname=${scname#STY=} - [[ -n "$2" ]] && [[ "${scname#*.}" != "$2" ]] && continue - echo -n "${process_id} " - done - echo -} - -for om_component in $om_list -do - screen_name="${om_component}" - [[ -n "$option_screen_name" ]] && screen_name=$option_screen_name - [ "${om_component}" == "mano" ] && om_cmd="./openmanod.py" && om_name="openmano " && om_dir=$(readlink -f ${DIR_OM}) - #obtain PID of program - component_id=`find_process_id "${om_cmd}" $option_screen_name` - processes=$(echo $component_id | wc -w) - - #status - if [ "$om_action" == "status" ] - then - running="" - for process_id in $component_id - do - scname=$(ps wwep $process_id | grep -o 'STY=\S*') - scname=${scname#STY=} - [[ -n "$option_screen_name" ]] && [[ "${scname#*.}" != "$option_screen_name" ]] && continue - printf "%-15s" "pid: ${process_id}," - [[ -n "$scname" ]] && printf "%-25s" "screen: ${scname}," - echo cmd: $(ps -o cmd p $process_id | tail -n1 ) - running=y - done - #if installed as a service and it is not provided a screen name call service - [[ -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 - fi - fi - - #if installed as a service and it is not provided a screen name call service - [[ -f /etc/systemd/system/osm-ro.service ]] && [[ -z $option_screen_name ]] && service osm-ro $om_action && ( [[ $om_action == status ]] || sleep 5 ) && exit $? - - - #stop - if [ "$om_action" == "stop" -o "$om_action" == "restart" ] - then - #terminates program - [ $processes -gt 1 ] && echo "$processes processes are running, specify with --screen-name" && continue - [ $processes -eq 1 ] && echo -n " stopping $om_name ... " && kill_pid $component_id - component_id="" - #terminates screen - if screen -wipe | grep -q -e "\.${screen_name}\b" - then - screen -S $screen_name -p 0 -X stuff "exit\n" || echo - sleep 1 - fi - fi - - #start - if [ "$om_action" == "start" -o "$om_action" == "restart" ] - then - #calculates log file name - logfile="" - mkdir -p $DIR_OM/logs && logfile=$DIR_OM/logs/open${screen_name}.log || echo "can not create logs directory $DIR_OM/logs" - #check already running - [ -n "$component_id" ] && echo " $om_name is already running. Skipping" && continue - #create screen if not created - echo -n " starting $om_name ... " - if ! screen -wipe | grep -q -e "\.${screen_name}\b" - then - pushd ${om_dir} > /dev/null - screen -dmS ${screen_name} bash - sleep 1 - popd > /dev/null - else - echo -n " using existing screen '${screen_name}' ... " - screen -S ${screen_name} -p 0 -X log off - screen -S ${screen_name} -p 0 -X stuff "cd ${om_dir}\n" - sleep 1 - fi - #move old log file index one number up and log again in index 0 - if [[ -n $logfile ]] - then - for index in 8 7 6 5 4 3 2 1 - do - [[ -f ${logfile}.${index} ]] && mv ${logfile}.${index} ${logfile}.$((index+1)) - done - [[ -f ${logfile} ]] && mv ${logfile} ${logfile}.1 - screen -S ${screen_name} -p 0 -X logfile ${logfile} - screen -S ${screen_name} -p 0 -X log on - fi - #launch command to screen - screen -S ${screen_name} -p 0 -X stuff "${om_cmd}${om_params}\n" - #check if is running - [[ -n $logfile ]] && timeout=120 #2 minute - [[ -z $logfile ]] && timeout=20 - while [[ $timeout -gt 0 ]] - do - #check if is running - #echo timeout $timeout - #if ! ps -f -U $USER -u $USER | grep -v grep | grep -q ${om_cmd} - log_lines=0 - [[ -n $logfile ]] && log_lines=`head ${logfile} | wc -l` - component_id=`find_process_id "${om_cmd}${om_params}" $screen_name` - if [[ -z $component_id ]] - then #process not started or finished - [[ $log_lines -ge 2 ]] && echo -n "ERROR, it has exited." && break - #started because writted serveral lines at log so report error - fi - [[ -n $logfile ]] && grep -q "open${om_component}d ready" ${logfile} && break - sleep 1 - timeout=$((timeout -1)) - done - if [[ -n $logfile ]] && [[ $timeout == 0 ]] - then - echo -n "timeout!" - else - echo -n "running on 'screen -x ${screen_name}'." - fi - [[ -n $logfile ]] && echo " Logging at '${logfile}'" || echo - fi -done - - - - 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 +