4 # Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
5 # This file is part of openmano
8 # Licensed under the Apache License, Version 2.0 (the "License"); you may
9 # not use this file except in compliance with the License. You may obtain
10 # a copy of the License at
12 # http://www.apache.org/licenses/LICENSE-2.0
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17 # License for the specific language governing permissions and limitations
22 # author: Alfonso Tierno
24 # It uses following env, if not provided filling by default
25 [ -z "$GIT_OSMIM_URL" ] && GIT_OSMIM_URL
=https
://osm.etsi.org
/gerrit
/osm
/IM.git
26 [ -z "$DEVELOP" ] && DEVELOP
=""
27 # folder where RO is installed
28 [ -z "$BASEFOLDER" ] && HERE
=$
(dirname $
(readlink
-f ${BASH_SOURCE[0]})) && BASEFOLDER
=$
(dirname $HERE)
29 [ -z "$SUDO_USER" ] && SUDO_USER
="$USER"
30 [ -z "$NO_PACKAGES" ] && NO_PACKAGES
=""
31 [ -z "$_DISTRO" ] && _DISTRO
="Ubuntu"
34 su
$SUDO_USER -c "git -C ${BASEFOLDER} clone ${GIT_OSMIM_URL} IM" ||
35 ! echo "Error cannot clone from '${GIT_OSMIM_URL}'" >&2 ||
exit 1
36 if [[ -n $COMMIT_ID ]] ; then
37 echo -e "Installing osm-IM from refspec: $COMMIT_ID"
38 su
$SUDO_USER -c "git -C ${BASEFOLDER}/IM checkout $COMMIT_ID" ||
39 ! echo "Error cannot checkout '$COMMIT_ID' from '${GIT_OSMIM_URL}'" >&2 ||
exit 1
40 elif [[ -z $DEVELOP ]]; then
41 LATEST_STABLE_TAG
=`git -C "${BASEFOLDER}/IM" tag -l "v[0-9]*" | sort -V | tail -n1`
42 echo -e "Installing osm-IM from refspec: tags/${LATEST_STABLE_TAG}"
43 su
$SUDO_USER -c "git -C ${BASEFOLDER}/IM checkout tags/${LATEST_STABLE_TAG}" ||
44 ! echo "Error cannot checkout 'tags/${LATEST_STABLE_TAG}' from '${GIT_OSMIM_URL}'" >&2 ||
exit 1
46 echo -e "Installing osm-IM from refspec: master"
49 # Install debian dependencies before setup.py
50 if [[ -z "$NO_PACKAGES" ]]
53 # apt-get install -y git python-pip
54 # pip2 install pip==9.0.3
55 pip2
install pyangbind ||
exit 1
58 PYBINDPLUGIN
=$
(python2
-c 'import pyangbind; import os; print "%s/plugin" % os.path.dirname(pyangbind.__file__)')
59 su
$SUDO_USER -c 'mkdir -p "'${BASEFOLDER}/IM
/osm_im
'"'
60 su
$SUDO_USER -c 'touch "'${BASEFOLDER}/IM
/osm_im
/__init__.py
'"'
61 # 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"
62 for target
in vnfd nsd
; do
63 pyang
-Werror --path "${BASEFOLDER}/IM/models/yang" --plugindir "${PYBINDPLUGIN}" -f pybind \
64 -o "${BASEFOLDER}/IM/osm_im/${target}.py" "${BASEFOLDER}/IM/models/yang/${target}.yang"
67 pip2
install -e "${BASEFOLDER}/IM" ||
! echo "ERROR installing python-osm-im library!!!" >&2 ||
exit 1