From a7f744d3f1a2aa124ccb6a471b25199fc7e7f31b Mon Sep 17 00:00:00 2001 From: tierno Date: Mon, 10 Sep 2018 11:04:31 +0200 Subject: [PATCH] install-openmano.sh change to install osm-im, lib-osm-openvim in pure python2 without calling make that imposes many unneeded packages Change-Id: I3149a1b7656a2adb5b1a4ffbb973e49a6a00d0e0 Signed-off-by: tierno --- scripts/install-lib-osm-openvim.sh | 51 +++++++++++++++++++ scripts/install-openmano.sh | 79 +++++------------------------- scripts/install-osm-im.sh | 67 +++++++++++++++++++++++++ 3 files changed, 131 insertions(+), 66 deletions(-) create mode 100755 scripts/install-lib-osm-openvim.sh create mode 100755 scripts/install-osm-im.sh diff --git a/scripts/install-lib-osm-openvim.sh b/scripts/install-lib-osm-openvim.sh new file mode 100755 index 00000000..b43f6fe3 --- /dev/null +++ b/scripts/install-lib-osm-openvim.sh @@ -0,0 +1,51 @@ +#!/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. +# +## + +# author: Alfonso Tierno + +# It uses following env, if not provided filling by default +[ -z "$GIT_OVIM_URL" ] && GIT_OVIM_URL=https://osm.etsi.org/gerrit/osm/openvim.git +[ -z "$DEVELOP" ] && DEVELOP="" +# folder where RO is installed +[ -z "$BASEFOLDER" ] && HERE=$(dirname $(readlink -f ${BASH_SOURCE[0]})) && BASEFOLDER=$(dirname $HERE) +[ -z "$SUDO_USER" ] && SUDO_USER="$USER" +[ -z "$NO_PACKAGES" ] && NO_PACKAGES="" +[ -z "$_DISTRO" ] && _DISTRO="Ubuntu" + + +su $SUDO_USER -c "git -C '${BASEFOLDER}' clone ${GIT_OVIM_URL} lib-openvim" || + ! echo "Error cannot clone from '${GIT_OVIM_URL}'" >&2 || exit 1 +if [[ -n $COMMIT_ID ]] ; then + echo -e "Installing lib-osm-openvim from refspec: $COMMIT_ID" + su $SUDO_USER -c "git -C '${BASEFOLDER}/lib-openvim' checkout $COMMIT_ID" || + ! echo "Error cannot checkout '$COMMIT_ID' from '${GIT_OVIM_URL}'" >&2 || exit 1 +elif [[ -z $DEVELOP ]]; then + LATEST_STABLE_TAG=`git -C "${BASEFOLDER}/lib-openvim" tag -l "v[0-9]*" | sort -V | tail -n1` + echo -e "Installing lib-osm-openvim from refspec: tags/${LATEST_STABLE_TAG}" + su $SUDO_USER -c "git -C '${BASEFOLDER}/lib-openvim' checkout tags/${LATEST_STABLE_TAG}" || + ! echo "Error cannot checkout 'tags/${LATEST_STABLE_TAG}' from '${GIT_OVIM_URL}'" >&2 || exit 1 +else + echo -e "Installing lib-osm-openvim from refspec: master" +fi + +make -C "${BASEFOLDER}/lib-openvim" prepare_lite +export LANG="en_US.UTF-8" +pip2 install -e "${BASEFOLDER}/lib-openvim/build" diff --git a/scripts/install-openmano.sh b/scripts/install-openmano.sh index 3056efd9..9a361165 100755 --- a/scripts/install-openmano.sh +++ b/scripts/install-openmano.sh @@ -81,8 +81,8 @@ function ask_user(){ } GIT_URL=https://osm.etsi.org/gerrit/osm/RO.git -GIT_OVIM_URL=https://osm.etsi.org/gerrit/osm/openvim.git -GIT_OSMIM_URL=https://osm.etsi.org/gerrit/osm/IM.git +export GIT_OVIM_URL=https://osm.etsi.org/gerrit/osm/openvim.git +export GIT_OSMIM_URL=https://osm.etsi.org/gerrit/osm/IM.git DBUSER="root" DBPASSWD="" DBPASSWD_PARAM="" @@ -117,7 +117,7 @@ while getopts ":u:p:b:hiq-:" o; do ;; -) [ "${OPTARG}" == "help" ] && usage && exit 0 - [ "${OPTARG}" == "develop" ] && DEVELOP="y" && continue + [ "${OPTARG}" == "develop" ] && export DEVELOP="y" && continue [ "${OPTARG}" == "forcedb" ] && DB_FORCE_UPDATE="${DB_FORCE_UPDATE}--forcedb" && continue [ "${OPTARG}" == "updatedb" ] && DB_FORCE_UPDATE="${DB_FORCE_UPDATE}--updatedb" && continue [ "${OPTARG}" == "force" ] && FORCE="y" && continue @@ -200,6 +200,7 @@ else #[ "$_DISTRO" != "Ubuntu" -a "$_DISTRO" != "CentOS" -a "$_DISTRO" != "Red" echo "Cancelled" && exit 1 fi +export _DISTRO="$_DISTRO" #check if installed as a service INSTALL_AS_A_SERVICE="" [[ "$_DISTRO" == "Ubuntu" ]] && [[ ${_RELEASE%%.*} == 16 ]] && [[ -z $DEVELOP ]] && INSTALL_AS_A_SERVICE="y" @@ -207,14 +208,14 @@ INSTALL_AS_A_SERVICE="" # Next operations require knowing BASEFOLDER if [[ -z "$NOCLONE" ]]; then if [[ -n "$INSTALL_AS_A_SERVICE" ]] ; then - BASEFOLDER=__openmano__${RANDOM} + export BASEFOLDER=__openmano__${RANDOM} else - BASEFOLDER="${PWD}/openmano" + export BASEFOLDER="${PWD}/openmano" fi [[ -n "$FORCE" ]] && rm -rf $BASEFOLDER #make idempotent else HERE=$(dirname $(readlink -f ${BASH_SOURCE[0]})) - BASEFOLDER=$(dirname $HERE) + export BASEFOLDER=$(dirname $HERE) fi if [[ -z "$NO_PACKAGES" ]] @@ -311,71 +312,17 @@ echo -e "\n"\ "#################################################################\n"\ "##### INSTALLING OSM-IM LIBRARY #####\n"\ "#################################################################" -su $SUDO_USER -c "git -C ${BASEFOLDER} clone ${GIT_OSMIM_URL} IM" || - ! echo "Error cannot clone from '${GIT_OSMIM_URL}'" >&2 || exit 1 -if [[ -n $COMMIT_ID ]] ; then - echo -e "Installing osm-IM from refspec: $COMMIT_ID" - su $SUDO_USER -c "git -C ${BASEFOLDER}/IM checkout $COMMIT_ID" || - ! echo "Error cannot checkout '$COMMIT_ID' from '${GIT_OSMIM_URL}'" >&2 || exit 1 -elif [[ -z $DEVELOP ]]; then - LATEST_STABLE_TAG=`git -C "${BASEFOLDER}/IM" tag -l "v[0-9]*" | sort -V | tail -n1` - echo -e "Installing osm-IM from refspec: tags/${LATEST_STABLE_TAG}" - su $SUDO_USER -c "git -C ${BASEFOLDER}/IM checkout tags/${LATEST_STABLE_TAG}" || - ! echo "Error cannot checkout 'tags/${LATEST_STABLE_TAG}' from '${GIT_OSMIM_URL}'" >&2 || exit 1 -else - echo -e "Installing osm-IM from refspec: master" -fi - -# Install debian dependencies before setup.py -if [[ -z "$NO_PACKAGES" ]] -then - [ "$_DISTRO" == "Ubuntu" ] && install_packages "tox debhelper python-bitarray python-lxml python-six" - # TODO check packages for CentOS and RedHat - [ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ] && install_packages "tox debhelper python-bitarray python-lxml python-six" - pip2 install --upgrade stdeb pyangbind || exit 1 -fi -su $SUDO_USER -c "make -C ${BASEFOLDER}/IM all" -dpkg -i ${BASEFOLDER}/IM/deb_dist/python-osm-im*.deb ${BASEFOLDER}/IM/pyangbind/deb_dist/*.deb \ - ${BASEFOLDER}/IM/pyang/deb_dist/*.deb -rm -rf "${BASEFOLDER}/IM" -OSM_IM_PATH=`python -c 'import osm_im; print osm_im.__path__[0]'` || - ! echo "ERROR installing python-osm-im library!!!" >&2 || exit 1 - + ${BASEFOLDER}/scripts/install-osm-im.sh + OSM_IM_PATH=`python -c 'import osm_im; print osm_im.__path__[0]'` || + ! echo "ERROR installing python-osm-im library!!!" >&2 || exit 1 echo -e "\n"\ "#################################################################\n"\ "##### INSTALLING OVIM LIBRARY #####\n"\ "#################################################################" -su $SUDO_USER -c "git -C ${BASEFOLDER} clone ${GIT_OVIM_URL} openvim" || - ! echo "Error cannot clone from '${GIT_OVIM_URL}'" || exit 1 -if [[ -n $COMMIT_ID ]] ; then - echo -e "Installing lib_osm_openvim from refspec: $COMMIT_ID" - su $SUDO_USER -c "git -C ${BASEFOLDER}/openvim checkout $COMMIT_ID" || - ! echo "Error cannot checkout '$COMMIT_ID' from '${GIT_OVIM_URL}'" || exit 1 -elif [[ -z $DEVELOP ]]; then - LATEST_STABLE_TAG=`git -C "${BASEFOLDER}/openvim" tag -l "v[0-9]*" | sort -V | tail -n1` - echo -e "Installing lib_osm_openvim from refspec: tags/${LATEST_STABLE_TAG}" - su $SUDO_USER -c "git -C ${BASEFOLDER}/openvim checkout tags/${LATEST_STABLE_TAG}" || - ! echo "Error cannot checkout 'tags/${LATEST_STABLE_TAG}' from '${GIT_OVIM_URL}'" || exit 1 -else - echo -e "Installing lib_osm_openvim from refspec: master" -fi - -# Install debian dependencies before setup.py -if [[ -z "$NO_PACKAGES" ]] -then - [ "$_DISTRO" == "Ubuntu" ] && install_packages \ - "libmysqlclient-dev python-cffi python-packaging python-pkgconfig python-pycparser libssl-dev libffi-dev" - # TODO check if that is the name in CentOS and RedHat - [ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ] && install_packages \ - "libmysqlclient-dev python-cffi python-packaging python-pkgconfig python-pycparser libssl-dev libffi-dev" - pip2 install --upgrade stdeb setuptools-version-command || exit 1 -fi -su $SUDO_USER -c "make -C ${BASEFOLDER}/openvim lite" -dpkg -i ${BASEFOLDER}/openvim/.build/python-lib-osm-openvim*.deb -rm -rf "${BASEFOLDER}/openvim" -OSMLIBOVIM_PATH=`python -c 'import lib_osm_openvim; print lib_osm_openvim.__path__[0]'` || - ! echo "ERROR installing python-lib-osm-openvim library!!!" >&2 || exit 1 + ${BASEFOLDER}/scripts/install-lib-osm-openvim.sh + OSMLIBOVIM_PATH=`python -c 'import lib_osm_openvim; print lib_osm_openvim.__path__[0]'` || + ! echo "ERROR installing python-lib-osm-openvim library!!!" >&2 || exit 1 if [ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ] then diff --git a/scripts/install-osm-im.sh b/scripts/install-osm-im.sh new file mode 100755 index 00000000..0f9a6c6d --- /dev/null +++ b/scripts/install-osm-im.sh @@ -0,0 +1,67 @@ +#!/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. +# +## + +# author: Alfonso Tierno + +# It uses following env, if not provided filling by default +[ -z "$GIT_OSMIM_URL" ] && GIT_OSMIM_URL=https://osm.etsi.org/gerrit/osm/IM.git +[ -z "$DEVELOP" ] && DEVELOP="" +# folder where RO is installed +[ -z "$BASEFOLDER" ] && HERE=$(dirname $(readlink -f ${BASH_SOURCE[0]})) && BASEFOLDER=$(dirname $HERE) +[ -z "$SUDO_USER" ] && SUDO_USER="$USER" +[ -z "$NO_PACKAGES" ] && NO_PACKAGES="" +[ -z "$_DISTRO" ] && _DISTRO="Ubuntu" + + +su $SUDO_USER -c "git -C ${BASEFOLDER} clone ${GIT_OSMIM_URL} IM" || + ! echo "Error cannot clone from '${GIT_OSMIM_URL}'" >&2 || exit 1 +if [[ -n $COMMIT_ID ]] ; then + echo -e "Installing osm-IM from refspec: $COMMIT_ID" + su $SUDO_USER -c "git -C ${BASEFOLDER}/IM checkout $COMMIT_ID" || + ! echo "Error cannot checkout '$COMMIT_ID' from '${GIT_OSMIM_URL}'" >&2 || exit 1 +elif [[ -z $DEVELOP ]]; then + LATEST_STABLE_TAG=`git -C "${BASEFOLDER}/IM" tag -l "v[0-9]*" | sort -V | tail -n1` + echo -e "Installing osm-IM from refspec: tags/${LATEST_STABLE_TAG}" + su $SUDO_USER -c "git -C ${BASEFOLDER}/IM checkout tags/${LATEST_STABLE_TAG}" || + ! echo "Error cannot checkout 'tags/${LATEST_STABLE_TAG}' from '${GIT_OSMIM_URL}'" >&2 || exit 1 +else + echo -e "Installing osm-IM from refspec: master" +fi + +# Install debian dependencies before setup.py +if [[ -z "$NO_PACKAGES" ]] +then + # apt-get update + # apt-get install -y git python-pip + # pip2 install pip==9.0.3 + pip2 install pyangbind || exit 1 +fi + +PYBINDPLUGIN=$(python2 -c 'import pyangbind; import os; print "%s/plugin" % os.path.dirname(pyangbind.__file__)') +su $SUDO_USER -c 'mkdir -p "'${BASEFOLDER}/IM/osm_im'"' +su $SUDO_USER -c 'touch "'${BASEFOLDER}/IM/osm_im/__init__.py'"' +# wget -q https://raw.githubusercontent.com/RIFTIO/RIFT.ware/RIFT.ware-4.4.1/modules/core/util/yangtools/yang/rw-pb-ext.yang -O "${BASEFOLDER}/IM/models/yang/rw-pb-ext.yang" +for target in vnfd nsd ; do + pyang -Werror --path "${BASEFOLDER}/IM/models/yang" --plugindir "${PYBINDPLUGIN}" -f pybind \ + -o "${BASEFOLDER}/IM/osm_im/${target}.py" "${BASEFOLDER}/IM/models/yang/${target}.yang" +done + +pip2 install -e "${BASEFOLDER}/IM" || ! echo "ERROR installing python-osm-im library!!!" >&2 || exit 1 \ No newline at end of file -- 2.17.1