prepare:
pip install setuptools
mkdir -p build/
- #git describe | sed -e 's/^v//' > build/RO_VERSION
- echo "1.1.5" > build/RO_VERSION
+ VER1=$(shell git describe | sed -e 's/^v//' |cut -d- -f1); \
+ VER2=$(shell git describe | cut -d- -f2); \
+ VER3=$(shell git describe | cut -d- -f3); \
+ echo "$$VER1.dev$$VER2+$$VER3" > build/RO_VERSION
cp MANIFEST.in build/
cp requirements.txt build/
cp README.rst build/
cd build && ./setup.py sdist
package: prepare
+ #apt-get install -y python-stdeb
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
clean:
rm -rf build
- #find build -name '*.pyc' -delete
- #find build -name '*.pyo' -delete
+ find osm_ro -name '*.pyc' -delete
+ find osm_ro -name '*.pyo' -delete
--- /dev/null
+#!/bin/bash
+
+function usage(){
+ echo -e "usage: sudo $0 [OPTIONS]"
+ echo -e "Install openmano database server"
+ echo -e "On a Ubuntu 16.04 it configures openmano as a service"
+ echo -e " OPTIONS"
+ echo -e " -u USER: database admin user. 'root' by default. Prompts if needed"
+ echo -e " -p PASS: database admin password to be used or installed. Prompts if needed"
+ echo -e " -q --quiet: install in unattended mode"
+ echo -e " -h --help: show this help"
+ echo -e " --forcedb: reinstall mano_db DB, deleting previous database if exists and creating a new one"
+ echo -e " --no-install-packages: use this option to skip updating and installing the requires packages. This avoid wasting time if you are sure requires packages are present e.g. because of a previous installation"
+}
+
+function install_packages(){
+ [ -x /usr/bin/apt-get ] && apt-get install -y $*
+ [ -x /usr/bin/yum ] && yum install -y $*
+
+ #check properly installed
+ for PACKAGE in $*
+ do
+ PACKAGE_INSTALLED="no"
+ [ -x /usr/bin/apt-get ] && dpkg -l $PACKAGE &>> /dev/null && PACKAGE_INSTALLED="yes"
+ [ -x /usr/bin/yum ] && yum list installed $PACKAGE &>> /dev/null && PACKAGE_INSTALLED="yes"
+ if [ "$PACKAGE_INSTALLED" = "no" ]
+ then
+ echo "failed to install package '$PACKAGE'. Revise network connectivity and try again" >&2
+ exit 1
+ fi
+ done
+}
+
+function db_exists() {
+ RESULT=`mysqlshow --defaults-extra-file="$2" | grep -v Wildcard | grep -o $1`
+ if [ "$RESULT" == "$1" ]; then
+ echo " DB $1 exists"
+ return 0
+ fi
+ echo " DB $1 does not exist"
+ return 1
+}
+
+
+DBUSER="root"
+DBPASSWD=""
+DBPASSWD_PARAM=""
+QUIET_MODE=""
+FORCEDB=""
+NO_PACKAGES=""
+while getopts ":u:p:hiq-:" o; do
+ case "${o}" in
+ u)
+ export DBUSER="$OPTARG"
+ ;;
+ p)
+ export DBPASSWD="$OPTARG"
+ export DBPASSWD_PARAM="-p$OPTARG"
+ ;;
+ q)
+ export QUIET_MODE=yes
+ export DEBIAN_FRONTEND=noninteractive
+ ;;
+ h)
+ usage && exit 0
+ ;;
+ -)
+ [ "${OPTARG}" == "help" ] && usage && exit 0
+ [ "${OPTARG}" == "forcedb" ] && FORCEDB="y" && continue
+ [ "${OPTARG}" == "quiet" ] && export QUIET_MODE=yes && export DEBIAN_FRONTEND=noninteractive && continue
+ [ "${OPTARG}" == "no-install-packages" ] && export NO_PACKAGES=yes && continue
+ echo -e "Invalid option: '--$OPTARG'\nTry $0 --help for more information" >&2
+ exit 1
+ ;;
+ \?)
+ echo -e "Invalid option: '-$OPTARG'\nTry $0 --help for more information" >&2
+ exit 1
+ ;;
+ :)
+ echo -e "Option '-$OPTARG' requires an argument\nTry $0 --help for more information" >&2
+ exit 1
+ ;;
+ *)
+ usage >&2
+ exit 1
+ ;;
+ esac
+done
+
+HERE=$(realpath $(dirname $0))
+OPENMANO_BASEFOLDER=$(dirname $HERE)
+
+#Discover Linux distribution
+#try redhat type
+[ -f /etc/redhat-release ] && _DISTRO=$(cat /etc/redhat-release 2>/dev/null | cut -d" " -f1)
+#if not assuming ubuntu type
+[ -f /etc/redhat-release ] || _DISTRO=$(lsb_release -is 2>/dev/null)
+
+if [[ -z "$NO_PACKAGES" ]]
+then
+ echo '
+#################################################################
+##### INSTALL REQUIRED PACKAGES #####
+#################################################################'
+ [ "$_DISTRO" == "Ubuntu" ] && install_packages "mysql-server"
+ [ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ] && install_packages "mariadb mariadb-server"
+
+ if [[ "$_DISTRO" == "Ubuntu" ]]
+ then
+ #start services. By default CentOS does not start services
+ service mysql start >> /dev/null
+ # try to set admin password, ignore if fails
+ [[ -n $DBPASSWD ]] && mysqladmin -u $DBUSER -s password $DBPASSWD
+ fi
+
+ if [ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ]
+ then
+ #start services. By default CentOS does not start services
+ service mariadb start
+ service httpd start
+ systemctl enable mariadb
+ systemctl enable httpd
+ read -e -p "Do you want to configure mariadb (recommended if not done before) (Y/n)" KK
+ [ "$KK" != "n" -a "$KK" != "no" ] && mysql_secure_installation
+
+ read -e -p "Do you want to set firewall to grant web access port 80,443 (Y/n)" KK
+ [ "$KK" != "n" -a "$KK" != "no" ] &&
+ firewall-cmd --permanent --zone=public --add-service=http &&
+ firewall-cmd --permanent --zone=public --add-service=https &&
+ firewall-cmd --reload
+ fi
+fi #[[ -z "$NO_PACKAGES" ]]
+
+#check and ask for database user password. Must be done after database installation
+if [[ -n $QUIET_MODE ]]
+then
+ echo -e "\nCheking database connection and ask for credentials"
+ while ! mysqladmin -s -u$DBUSER $DBPASSWD_PARAM status >/dev/null
+ do
+ [ -n "$logintry" ] && echo -e "\nInvalid database credentials!!!. Try again (Ctrl+c to abort)"
+ [ -z "$logintry" ] && echo -e "\nProvide database credentials"
+ read -e -p "database user? ($DBUSER) " DBUSER_
+ [ -n "$DBUSER_" ] && DBUSER=$DBUSER_
+ read -e -s -p "database password? (Enter for not using password) " DBPASSWD_
+ [ -n "$DBPASSWD_" ] && DBPASSWD="$DBPASSWD_" && DBPASSWD_PARAM="-p$DBPASSWD_"
+ [ -z "$DBPASSWD_" ] && DBPASSWD="" && DBPASSWD_PARAM=""
+ logintry="yes"
+ done
+fi
+
+echo '
+#################################################################
+##### CREATE DATABASE #####
+#################################################################'
+echo -e "\nCreating temporary file for MYSQL installation and initialization"
+TEMPFILE="$(mktemp -q --tmpdir "installopenmano.XXXXXX")"
+trap 'rm -f "$TEMPFILE"' EXIT
+chmod 0600 "$TEMPFILE"
+echo -e "[client]\n user='$DBUSER'\n password='$DBPASSWD'">"$TEMPFILE"
+
+if db_exists "mano_db" $TEMPFILE ; then
+ if [[ -n $FORCEDB ]]; then
+ echo " Deleting previous database mano_db"
+ DBDELETEPARAM=""
+ [[ -n $QUIET_MODE ]] && DBDELETEPARAM="-f"
+ mysqladmin --defaults-extra-file=$TEMPFILE -s drop mano_db $DBDELETEPARAM || ! echo "Could not delete mano_db database" || exit 1
+ #echo "REVOKE ALL PRIVILEGES ON mano_db.* FROM 'mano'@'localhost';" | mysql --defaults-extra-file=$TEMPFILE -s || ! echo "Failed while creating user mano at database" || exit 1
+ #echo "DELETE USER 'mano'@'localhost';" | mysql --defaults-extra-file=$TEMPFILE -s || ! echo "Failed while creating user mano at database" || exit 1
+ mysqladmin --defaults-extra-file=$TEMPFILE -s create mano_db || ! echo "Error creating mano_db database" || exit 1
+ echo "CREATE USER 'mano'@'localhost' identified by 'manopw';" | mysql --defaults-extra-file=$TEMPFILE -s || ! echo "Failed while creating user mano at database"
+ echo "GRANT ALL PRIVILEGES ON mano_db.* TO 'mano'@'localhost';" | mysql --defaults-extra-file=$TEMPFILE -s || ! echo "Failed while creating user mano at database" || exit 1
+ echo " Database 'mano_db' created, user 'mano' password 'manopw'"
+ else
+ echo "Database exists. Use option '--forcedb' to force the deletion of the existing one" && exit 1
+ fi
+else
+ mysqladmin -u$DBUSER $DBPASSWD_PARAM -s create mano_db || ! echo "Error creating mano_db database" || exit 1
+ echo "CREATE USER 'mano'@'localhost' identified by 'manopw';" | mysql --defaults-extra-file=$TEMPFILE -s || ! echo "Failed while creating user mano at database" || exit 1
+ echo "GRANT ALL PRIVILEGES ON mano_db.* TO 'mano'@'localhost';" | mysql --defaults-extra-file=$TEMPFILE -s || ! echo "Failed while creating user mano at database" || exit 1
+ echo " Database 'mano_db' created, user 'mano' password 'manopw'"
+fi
+
+
+echo '
+#################################################################
+##### INIT DATABASE #####
+#################################################################'
+su $SUDO_USER -c "${OPENMANO_BASEFOLDER}/database_utils/init_mano_db.sh -u mano -p manopw -d mano_db" || ! echo "Failed while initializing database" || exit 1
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
+import osm_ro
global global_config
global logger
opts, args = getopt.getopt(sys.argv[1:], "hvc:V:p:P:", ["config=", "help", "version", "port=", "vnf-repository=", "adminport=", "log-socket-host=", "log-socket-port=", "log-file="])
port=None
port_admin = None
- config_file = 'openmanod.cfg'
+ config_file = 'osm_ro/openmanod.cfg'
vnf_repository = None
log_file = None
log_socket_host = None
r = mydb.get_db_version()
if r[1] != database_version:
logger.critical("DATABASE wrong version '%s'. \
- Try to upgrade/downgrade to version '%s' with './database_utils/migrate_mano_db.sh'",
- r[1], database_version)
+ Try to upgrade/downgrade to version '%s' with '%s/database_utils/migrate_mano_db.sh'",
+ r[1], database_version, osm_ro.__path__[0])
exit(-1)
except db_base_Exception as e:
logger.critical("DATABASE is not a MANO one or it is a '0.0' version. Try to upgrade to version '%s' with \
+++ /dev/null
-#!/bin/bash
-
-function usage(){
- echo -e "usage: sudo $0 [OPTIONS]"
- echo -e "Install openmano database server"
- echo -e "On a Ubuntu 16.04 it configures openmano as a service"
- echo -e " OPTIONS"
- echo -e " -u USER: database admin user. 'root' by default. Prompts if needed"
- echo -e " -p PASS: database admin password to be used or installed. Prompts if needed"
- echo -e " -q --quiet: install in unattended mode"
- echo -e " -h --help: show this help"
- echo -e " --forcedb: reinstall mano_db DB, deleting previous database if exists and creating a new one"
- echo -e " --no-install-packages: use this option to skip updating and installing the requires packages. This avoid wasting time if you are sure requires packages are present e.g. because of a previous installation"
-}
-
-function install_packages(){
- [ -x /usr/bin/apt-get ] && apt-get install -y $*
- [ -x /usr/bin/yum ] && yum install -y $*
-
- #check properly installed
- for PACKAGE in $*
- do
- PACKAGE_INSTALLED="no"
- [ -x /usr/bin/apt-get ] && dpkg -l $PACKAGE &>> /dev/null && PACKAGE_INSTALLED="yes"
- [ -x /usr/bin/yum ] && yum list installed $PACKAGE &>> /dev/null && PACKAGE_INSTALLED="yes"
- if [ "$PACKAGE_INSTALLED" = "no" ]
- then
- echo "failed to install package '$PACKAGE'. Revise network connectivity and try again" >&2
- exit 1
- fi
- done
-}
-
-function db_exists() {
- RESULT=`mysqlshow --defaults-extra-file="$2" | grep -v Wildcard | grep -o $1`
- if [ "$RESULT" == "$1" ]; then
- echo " DB $1 exists"
- return 0
- fi
- echo " DB $1 does not exist"
- return 1
-}
-
-
-DBUSER="root"
-DBPASSWD=""
-DBPASSWD_PARAM=""
-QUIET_MODE=""
-FORCEDB=""
-NO_PACKAGES=""
-while getopts ":u:p:hiq-:" o; do
- case "${o}" in
- u)
- export DBUSER="$OPTARG"
- ;;
- p)
- export DBPASSWD="$OPTARG"
- export DBPASSWD_PARAM="-p$OPTARG"
- ;;
- q)
- export QUIET_MODE=yes
- export DEBIAN_FRONTEND=noninteractive
- ;;
- h)
- usage && exit 0
- ;;
- -)
- [ "${OPTARG}" == "help" ] && usage && exit 0
- [ "${OPTARG}" == "forcedb" ] && FORCEDB="y" && continue
- [ "${OPTARG}" == "quiet" ] && export QUIET_MODE=yes && export DEBIAN_FRONTEND=noninteractive && continue
- [ "${OPTARG}" == "no-install-packages" ] && export NO_PACKAGES=yes && continue
- echo -e "Invalid option: '--$OPTARG'\nTry $0 --help for more information" >&2
- exit 1
- ;;
- \?)
- echo -e "Invalid option: '-$OPTARG'\nTry $0 --help for more information" >&2
- exit 1
- ;;
- :)
- echo -e "Option '-$OPTARG' requires an argument\nTry $0 --help for more information" >&2
- exit 1
- ;;
- *)
- usage >&2
- exit 1
- ;;
- esac
-done
-
-HERE=$(realpath $(dirname $0))
-OPENMANO_BASEFOLDER=$(dirname $HERE)
-
-#Discover Linux distribution
-#try redhat type
-[ -f /etc/redhat-release ] && _DISTRO=$(cat /etc/redhat-release 2>/dev/null | cut -d" " -f1)
-#if not assuming ubuntu type
-[ -f /etc/redhat-release ] || _DISTRO=$(lsb_release -is 2>/dev/null)
-
-if [[ -z "$NO_PACKAGES" ]]
-then
- echo '
-#################################################################
-##### INSTALL REQUIRED PACKAGES #####
-#################################################################'
- [ "$_DISTRO" == "Ubuntu" ] && install_packages "mysql-server"
- [ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ] && install_packages "mariadb mariadb-server"
-
- if [[ "$_DISTRO" == "Ubuntu" ]]
- then
- #start services. By default CentOS does not start services
- service mysql start >> /dev/null
- # try to set admin password, ignore if fails
- [[ -n $DBPASSWD ]] && mysqladmin -u $DBUSER -s password $DBPASSWD
- fi
-
- if [ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ]
- then
- #start services. By default CentOS does not start services
- service mariadb start
- service httpd start
- systemctl enable mariadb
- systemctl enable httpd
- read -e -p "Do you want to configure mariadb (recommended if not done before) (Y/n)" KK
- [ "$KK" != "n" -a "$KK" != "no" ] && mysql_secure_installation
-
- read -e -p "Do you want to set firewall to grant web access port 80,443 (Y/n)" KK
- [ "$KK" != "n" -a "$KK" != "no" ] &&
- firewall-cmd --permanent --zone=public --add-service=http &&
- firewall-cmd --permanent --zone=public --add-service=https &&
- firewall-cmd --reload
- fi
-fi #[[ -z "$NO_PACKAGES" ]]
-
-#check and ask for database user password. Must be done after database installation
-if [[ -n $QUIET_MODE ]]
-then
- echo -e "\nCheking database connection and ask for credentials"
- while ! mysqladmin -s -u$DBUSER $DBPASSWD_PARAM status >/dev/null
- do
- [ -n "$logintry" ] && echo -e "\nInvalid database credentials!!!. Try again (Ctrl+c to abort)"
- [ -z "$logintry" ] && echo -e "\nProvide database credentials"
- read -e -p "database user? ($DBUSER) " DBUSER_
- [ -n "$DBUSER_" ] && DBUSER=$DBUSER_
- read -e -s -p "database password? (Enter for not using password) " DBPASSWD_
- [ -n "$DBPASSWD_" ] && DBPASSWD="$DBPASSWD_" && DBPASSWD_PARAM="-p$DBPASSWD_"
- [ -z "$DBPASSWD_" ] && DBPASSWD="" && DBPASSWD_PARAM=""
- logintry="yes"
- done
-fi
-
-echo '
-#################################################################
-##### CREATE DATABASE #####
-#################################################################'
-echo -e "\nCreating temporary file for MYSQL installation and initialization"
-TEMPFILE="$(mktemp -q --tmpdir "installopenmano.XXXXXX")"
-trap 'rm -f "$TEMPFILE"' EXIT
-chmod 0600 "$TEMPFILE"
-echo -e "[client]\n user='$DBUSER'\n password='$DBPASSWD'">"$TEMPFILE"
-
-if db_exists "mano_db" $TEMPFILE ; then
- if [[ -n $FORCEDB ]]; then
- echo " Deleting previous database mano_db"
- DBDELETEPARAM=""
- [[ -n $QUIET_MODE ]] && DBDELETEPARAM="-f"
- mysqladmin --defaults-extra-file=$TEMPFILE -s drop mano_db $DBDELETEPARAM || ! echo "Could not delete mano_db database" || exit 1
- #echo "REVOKE ALL PRIVILEGES ON mano_db.* FROM 'mano'@'localhost';" | mysql --defaults-extra-file=$TEMPFILE -s || ! echo "Failed while creating user mano at database" || exit 1
- #echo "DELETE USER 'mano'@'localhost';" | mysql --defaults-extra-file=$TEMPFILE -s || ! echo "Failed while creating user mano at database" || exit 1
- mysqladmin --defaults-extra-file=$TEMPFILE -s create mano_db || ! echo "Error creating mano_db database" || exit 1
- echo "CREATE USER 'mano'@'localhost' identified by 'manopw';" | mysql --defaults-extra-file=$TEMPFILE -s || ! echo "Failed while creating user mano at database"
- echo "GRANT ALL PRIVILEGES ON mano_db.* TO 'mano'@'localhost';" | mysql --defaults-extra-file=$TEMPFILE -s || ! echo "Failed while creating user mano at database" || exit 1
- echo " Database 'mano_db' created, user 'mano' password 'manopw'"
- else
- echo "Database exists. Use option '--forcedb' to force the deletion of the existing one" && exit 1
- fi
-else
- mysqladmin -u$DBUSER $DBPASSWD_PARAM -s create mano_db || ! echo "Error creating mano_db database" || exit 1
- echo "CREATE USER 'mano'@'localhost' identified by 'manopw';" | mysql --defaults-extra-file=$TEMPFILE -s || ! echo "Failed while creating user mano at database" || exit 1
- echo "GRANT ALL PRIVILEGES ON mano_db.* TO 'mano'@'localhost';" | mysql --defaults-extra-file=$TEMPFILE -s || ! echo "Failed while creating user mano at database" || exit 1
- echo " Database 'mano_db' created, user 'mano' password 'manopw'"
-fi
-
-
-echo '
-#################################################################
-##### INIT DATABASE #####
-#################################################################'
-su $SUDO_USER -c "${OPENMANO_BASEFOLDER}/database_utils/init_mano_db.sh -u mano -p manopw -d mano_db" || ! echo "Failed while initializing database" || exit 1
DIRNAME=$(readlink -f ${BASH_SOURCE[0]})
DIRNAME=$(dirname $DIRNAME )
-OMCLIENT=$DIRNAME/../openmano/openmano
-OVCLIENT=$DIRNAME/../openvim/openvim
+OMCLIENT=openmano
#get screen log files at the beginning
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 "cat /var/log/osm/openmano.log*"
+cat /var/log/osm/openmano.log*
echo
echo "-------------------------------"
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 "openmanod --version"
+openmanod --version
echo
echo "-------------------------------"
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 "cat /etc/osm/openmanod.cfg"
+cat /etc/osm/openmanod.cfg
echo "-------------------------------"
echo
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
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 " ${OSMRO_PATH}/database_utils/install-db-server.sh # -h for help"
echo ' service openmano start'
#import glob
_name = 'osm_ro'
-_version = open('RO_VERSION').read()
+_version = open('RO_VERSION').read().strip()
_description = 'OSM Resource Orchestrator'
_author = 'ETSI OSM'
_author_email = 'alfonso.tiernosepulveda@telefonica.com'