summaryrefslogtreecommitdiffstats
path: root/bootstrap/vagrant-onap/lib/functions
diff options
context:
space:
mode:
Diffstat (limited to 'bootstrap/vagrant-onap/lib/functions')
-rwxr-xr-xbootstrap/vagrant-onap/lib/functions204
1 files changed, 116 insertions, 88 deletions
diff --git a/bootstrap/vagrant-onap/lib/functions b/bootstrap/vagrant-onap/lib/functions
index fddd49a2a..b0c6e978d 100755
--- a/bootstrap/vagrant-onap/lib/functions
+++ b/bootstrap/vagrant-onap/lib/functions
@@ -3,6 +3,16 @@
set -o xtrace
source /var/onap/commons
+source /var/onap/_composed_functions
+source /var/onap/_onap_functions
+
+mvn_conf_file=/root/.m2/settings.xml
+git_src_folder=/opt
+
+# export_env_vars() - Export environment variables
+function export_env_vars {
+ export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' |sort -n | head -1)
+}
# configure_dns() - DNS/GW IP address configuration
function configure_dns {
@@ -10,35 +20,11 @@ function configure_dns {
resolvconf -u
}
-# create_configuration_files() - Store credentials in files
-function create_configuration_files {
- mkdir -p /opt/config
- echo $nexus_docker_repo > /opt/config/nexus_docker_repo.txt
- echo $nexus_username > /opt/config/nexus_username.txt
- echo $nexus_password > /opt/config/nexus_password.txt
- echo $openstack_username > /opt/config/openstack_username.txt
- echo $openstack_tenant_id > /opt/config/tenant_id.txt
- echo $dmaap_topic > /opt/config/dmaap_topic.txt
- echo $docker_version > /opt/config/docker_version.txt
-}
-
-# pull_openecomp_image() - Pull Docker container image from a Docker Registry Hub
-function pull_openecomp_image {
- install_docker
- local image=$1
- local tag=$2
- docker login -u $nexus_username -p $nexus_password $nexus_docker_repo
- docker pull $nexus_docker_repo/openecomp/${image}:$docker_version
- if [ ${tag} ]; then
- docker tag $nexus_docker_repo/openecomp/${image}:$docker_version $tag
- fi
-}
-
-# git_timed() - git can sometimes get itself infinitely stuck with transient network
+# _git_timed() - git can sometimes get itself infinitely stuck with transient network
# errors or other issues with the remote end. This wraps git in a
# timeout/retry loop and is intended to watch over non-local git
# processes that might hang.
-function git_timed {
+function _git_timed {
local count=0
local timeout=0
@@ -62,12 +48,12 @@ function git_timed {
function clone_repo {
local repo_url=https://git.onap.org/
local repo=$1
- local dest_folder=$2
- if [ ! -d $2 ]; then
- git_timed clone -b $gerrit_branch --single-branch ${repo_url}${repo} $dest_folder
+ local dest_folder=${2:-$git_src_folder/$repo}
+ if [ ! -d $dest_folder ]; then
+ _git_timed clone -b $gerrit_branch --single-branch ${repo_url}${repo} $dest_folder
else
pushd $dest_folder
- git_timed pull
+ _git_timed pull
popd
fi
}
@@ -79,26 +65,12 @@ function install_dev_tools {
install_package curl
}
-# install_bind() - Install bind utils
-function install_bind {
+# _install_bind() - Install bind utils
+function _install_bind {
install_package bind9
install_package bind9utils
}
-# configure_bind()- Configure bind utils
-function configure_bind {
- install_bind
- mkdir /etc/bind/zones
-
- curl -k $nexus_repo/org.openecomp.demo/boot/$artifacts_version/db_simpledemo_openecomp_org -o /etc/bind/zones/db.simpledemo.openecomp.org
- curl -k $nexus_repo/org.openecomp.demo/boot/$artifacts_version/named.conf.options -o /etc/bind/named.conf.options
- curl -k $nexus_repo/org.openecomp.demo/boot/$artifacts_version/named.conf.local -o /etc/bind/named.conf.local
-
- modprobe ip_gre
- sed -i "s/OPTIONS=.*/OPTIONS=\"-4 -u bind\"/g" /etc/default/bind9
- service bind9 restart
-}
-
# install_java() - Install java binaries
function install_java {
install_package software-properties-common
@@ -108,7 +80,7 @@ function install_java {
# install_maven() - Install maven binaries
function install_maven {
- if is_package_installed maven; then
+ if is_package_installed maven3; then
return
fi
if ! is_package_installed openjdk-8-jdk; then
@@ -120,10 +92,12 @@ function install_maven {
# Force Maven3 to use jdk8
apt-get purge openjdk-7-jdk -y
+
+ _configure_maven
}
-# configure_docker_proxy() - Configures proxy in Docker from ENV
-function configure_docker_proxy {
+# _configure_docker_proxy() - Configures proxy in Docker from ENV
+function _configure_docker_proxy {
if [ $http_proxy ]; then
echo "export http_proxy=$http_proxy" >> /etc/default/docker
fi
@@ -132,41 +106,24 @@ function configure_docker_proxy {
fi
}
-# build_docker_image() - Build Docker container image from source code
-function build_docker_image {
- local src_folder=$1
- local profile=$2
- install_maven
- install_docker
- pushd $src_folder
-
- # Cleanup external repo
- sed -i 's|${docker.push.registry}/||g' pom.xml
- local mvn_docker="mvn clean package docker:build"
- if [ $profile ]; then
- mvn_docker+=" -P $profile"
- fi
- if [ $http_proxy ]; then
- mvn_docker+=" -Ddocker.buildArg.http_proxy=$http_proxy"
- mvn_docker+=" -Ddocker.buildArg.HTTP_PROXY=$http_proxy"
- fi
- if [ $https_proxy ]; then
- mvn_docker+=" -Ddocker.buildArg.https_proxy=$https_proxy"
- mvn_docker+=" -Ddocker.buildArg.HTTPS_PROXY=$https_proxy"
+# install_nodejs() - Download and install NodeJS
+function install_nodejs {
+ if is_package_installed nodejs; then
+ return
fi
- eval $mvn_docker
- popd
+ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
+ install_package nodejs
+
+ # Update NPM to latest version
+ npm install npm -g
}
-# compile_src() - Function that compiles the java source code thru maven
-function compile_src {
- local src_folder=$1
- pushd $src_folder
- if [ -f pom.xml ]; then
- install_maven
- mvn clean install -DskipTests=true -Dmaven.test.skip=true -Dadditionalparam=-Xdoclint:none
- fi
- popd
+# install_python() - Install Python 2.7 and other tools necessary for development.
+function install_python {
+ install_package python2.7
+ install_package python-dev
+ curl -sL https://bootstrap.pypa.io/get-pip.py | python
+ pip install tox
}
# install_docker() - Download and install docker-engine
@@ -181,8 +138,20 @@ function install_docker {
$(lsb_release -cs) \
stable"
install_package docker-ce
- configure_docker_proxy
+ _configure_docker_proxy
service docker restart
+ sleep 10
+}
+
+# pull_docker_image() - Pull Docker container image from the Public Docker Registry Hub
+function pull_docker_image {
+ install_docker
+ local image=$1
+ local tag=$2
+ docker pull ${image}
+ if [ ${tag} ]; then
+ docker tag ${image} $tag
+ fi
}
# install_docker_compose() - Download and install docker-engine
@@ -195,10 +164,69 @@ function install_docker_compose {
fi
}
-# configure_service() - Download and configure a specific service in upstart
-function configure_service {
- local service_script=$1
- curl -k $nexus_repo/org.openecomp.demo/boot/$artifacts_version/$service_script -o /etc/init.d/$service_script
- chmod +x /etc/init.d/$service_script
- update-rc.d $service_script defaults
+# _install_ODL() - Download and Install OpenDayLight SDN controller
+function _install_ODL {
+ if [ ! -d /opt/opendaylight/current ]; then
+ mkdir -p /opt/opendaylight/
+ wget "https://nexus.opendaylight.org/content/repositories/public/org/opendaylight/integration/distribution-karaf/"$odl_version"/distribution-karaf-"$odl_version".tar.gz" -P /opt/
+ tar xvf "/opt/distribution-karaf-"$odl_version".tar.gz" -C /opt/
+ mv "/opt/distribution-karaf-"$odl_version /opt/opendaylight/current
+ rm -rf "/opt/distribution-karaf-"$odl_version".tar.gz"
+ fi
+}
+
+# start_ODL() - Start OpenDayLight SDN controller
+function start_ODL {
+ _install_ODL
+ if [ -d /opt/opendaylight ]; then
+ export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre
+ /opt/opendaylight/current/bin/start
+ sleep 180
+ /opt/opendaylight/current/bin/client feature:install odl-dlux-all
+ fi
+}
+
+# compile_src() - Function that compiles the java source code thru maven
+function compile_src {
+ local src_folder=$1
+ pushd $src_folder
+ if [ -f pom.xml ]; then
+ install_maven
+ mvn clean install -U -DskipTests=true -Dmaven.test.skip=true -Dmaven.javadoc.skip=true -Dadditionalparam=-Xdoclint:none
+ fi
+ popd
+}
+
+# build_docker_image() - Build Docker container image from source code
+function build_docker_image {
+ local src_folder=$1
+ local profile=$2
+ install_maven
+ install_docker
+ pushd $src_folder
+
+ # Cleanup external repo
+ sed -i 's|${docker.push.registry}/||g' pom.xml
+ local mvn_docker="mvn clean package docker:build"
+ if [ $profile ]; then
+ mvn_docker+=" -P $profile"
+ fi
+ if [ $http_proxy ]; then
+ if ! grep -ql "docker.buildArg.http_proxy" pom.xml ; then
+ mvn_docker+=" -Ddocker.buildArg.http_proxy=$http_proxy"
+ fi
+ if ! grep -ql "docker.buildArg.HTTP_PROXY" pom.xml ; then
+ mvn_docker+=" -Ddocker.buildArg.HTTP_PROXY=$http_proxy"
+ fi
+ fi
+ if [ $https_proxy ]; then
+ if ! grep -ql "docker.buildArg.https_proxy" pom.xml ; then
+ mvn_docker+=" -Ddocker.buildArg.https_proxy=$https_proxy"
+ fi
+ if ! grep -ql "docker.buildArg.HTTPS_PROXY" pom.xml ; then
+ mvn_docker+=" -Ddocker.buildArg.HTTPS_PROXY=$https_proxy"
+ fi
+ fi
+ eval $mvn_docker
+ popd
}