Merge branch 'master' into v2.0
[osm/RO.git] / scripts / install-openmano.sh
index 36f59d4..3492bcd 100755 (executable)
@@ -39,7 +39,7 @@ function usage(){
     echo -e "     --force:    makes idenpotent, delete previous installations folders if needed"
     echo -e "     --noclone:  assumes that openmano was cloned previously and that this script is run from the local repo"
     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"
-    echo -e "     --no-db: do not insall mysql server"
+    echo -e "     --no-db: do not install mysql server"
 }
 
 function install_packages(){
@@ -61,6 +61,7 @@ function install_packages(){
 }
 
 GIT_URL=https://osm.etsi.org/gerrit/osm/RO.git
+GIT_OVIM_URL=https://osm.etsi.org/gerrit/osm/openvim.git
 DBUSER="root"
 DBPASSWD=""
 DBPASSWD_PARAM=""
@@ -126,7 +127,7 @@ fi
 #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
+#else assuming ubuntu type
 [ -f /etc/redhat-release ] || _DISTRO=$(lsb_release -is  2>/dev/null)            
 if [ "$_DISTRO" == "Ubuntu" ]
 then
@@ -177,8 +178,7 @@ else
     OPENMANO_BASEFOLDER=$(dirname $HERE)
 fi
 
-
-if [[ -z "$NO_PACKAGES" ]]
+if [[ -z "$NO_PACKAGES" ]]  #if (UPDATE REPOS)
 then
 echo '
 #################################################################
@@ -192,17 +192,20 @@ echo '
   && sudo rpm -ivh epel-release-7-5.noarch.rpm && sudo yum install -y epel-release && rm -f epel-release-7-5.noarch.rpm
 [ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ] && sudo yum repolist
 
-fi
+fi #if (UPDATE REPOS)
 
-if [[ -z "$NO_PACKAGES" ]]
+if [[ -z "$NO_PACKAGES" ]] #if (INSTALL DEPENDENCIES)
 then
 echo '
 #################################################################
 #####               INSTALL REQUIRED PACKAGES               #####
 #################################################################'
-[ "$_DISTRO" == "Ubuntu" ] && install_packages "git screen wget mysql-client"
-[ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ] && install_packages "git screen wget mariadb-client"
+[ "$_DISTRO" == "Ubuntu" ] && install_packages "git make screen wget mysql-client"
+[ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ] && install_packages "git make screen wget mariadb-client"
+fi #if (INSTALL DEPENDENCIES)
 
+if [[ -z "$NO_PACKAGES" ]] #if (PYTHON PACKAGES AND PIP PACKAGES)
+then
 echo '
 #################################################################
 #####        INSTALL PYTHON PACKAGES                        #####
@@ -219,14 +222,14 @@ sudo pip install progressbar
 sudo pip install prettytable
 sudo pip install pyvmomi
 
-#requiered for AWS connector
+#required for AWS connector
 [ "$_DISTRO" == "Ubuntu" ] && install_packages "python-boto"
 [ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ] && install_packages "python-boto"  #TODO check if at Centos it exist with this name, or PIP should be used
 
 #install openstack client needed for using openstack as a VIM
 [ "$_DISTRO" == "Ubuntu" ] && install_packages "python-novaclient python-keystoneclient python-glanceclient python-neutronclient python-cinderclient"
 [ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ] && install_packages "python-devel" && easy_install python-novaclient python-keystoneclient python-glanceclient python-neutronclient python-cinderclient #TODO revise if gcc python-pip is needed
-fi  #[[ -z "$NO_PACKAGES" ]]
+fi #if (PYTHON PACKAGES AND PIP PACKAGES)
 
 if [[ -z $NOCLONE ]]; then
     echo '
@@ -235,9 +238,21 @@ if [[ -z $NOCLONE ]]; then
 #################################################################'
     su $SUDO_USER -c "git clone ${GIT_URL} ${OPENMANO_BASEFOLDER}"
     su $SUDO_USER -c "cp ${OPENMANO_BASEFOLDER}/.gitignore-common ${OPENMANO_BASEFOLDER}/.gitignore"
-    [[ -z $DEVELOP ]] && su $SUDO_USER -c "git -C  ${OPENMANO_BASEFOLDER} checkout tags/v1.0.2"
+    [[ -z $DEVELOP ]] && su $SUDO_USER -c "git -C ${OPENMANO_BASEFOLDER} checkout tags/v1.1.0"
 fi
 
+echo '
+#################################################################
+#####        INSTALLING OVIM LIBRARY                        #####
+#################################################################'
+su $SUDO_USER -c "git -C ${OPENMANO_BASEFOLDER} clone ${GIT_OVIM_URL} openvim"
+[[ -z $DEVELOP ]] && su $SUDO_USER -c "git -C ${OPENMANO_BASEFOLDER}/openvim checkout master"
+# Install debian dependencies before setup.py
+[ "$_DISTRO" == "Ubuntu" ] && install_packages "libmysqlclient-dev"
+[ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ] && install_packages "libmysqlclient-dev"  #TODO check if that's the name in CentOS and RedHat
+make -C ${OPENMANO_BASEFOLDER}/openvim lite
+OSMLIBOVIM_PATH=`python -c 'import lib_osm_openvim; print lib_osm_openvim.__path__[0]'`
+
 if [ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ]
 then
     echo '
@@ -323,7 +338,14 @@ echo '
     if [ -n "$FORCEDB" ]; then
         DB_FORCE='--forcedb'
     fi
-    ${OPENMANO_BASEFOLDER}/scripts/install-db-server.sh -u $DBUSER $DBPASSWD_PARAM $DB_QUIET $DB_FORCE || exit 1
+    ${OPENMANO_BASEFOLDER}/database_utils/install-db-server.sh -u $DBUSER $DBPASSWD_PARAM $DB_QUIET $DB_FORCE || exit 1
+echo '
+#################################################################
+#####        CREATE AND INIT MANO_VIM DATABASE              #####
+#################################################################'
+# Install mano_vim_db after setup
+    ${OSMLIBOVIM_PATH}/database_utils/install-db-server.sh -U $DBUSER ${DBPASSWD_PARAM/p/P} -u mano -p manopw -d mano_vim_db || exit 1
+
 fi
 
 if [[ -n "$INSTALL_AS_A_SERVICE"  ]]