diff options
author | Victor Morales <victor.morales@intel.com> | 2017-06-16 18:32:48 -0500 |
---|---|---|
committer | Victor Morales <victor.morales@intel.com> | 2017-06-20 21:13:28 -0500 |
commit | 89ce3216514b002b725777d132df144b3838e42d (patch) | |
tree | fd1dcc35972c448a576265a7eb6381d8b89e115c /bootstrap/vagrant-onap/lib | |
parent | f5cd892f130bd6a8d0cdf44d705b966c3cee3499 (diff) |
Add vagrant-onap project
This commit contains the current state of the files and folders
imported from github repository[1]. Fixes and features are expected to
be implemented in this project.
[1] https://github.com/electrocucaracha/vagrant-onap
Change-Id: Ib1e8d264e9566c5e44454f5475b5da4638879cb7
Signed-off-by: Victor Morales <victor.morales@intel.com>
Issue-id: CIMAN-28
Diffstat (limited to 'bootstrap/vagrant-onap/lib')
-rwxr-xr-x | bootstrap/vagrant-onap/lib/aai | 92 | ||||
-rwxr-xr-x | bootstrap/vagrant-onap/lib/appc | 27 | ||||
-rwxr-xr-x | bootstrap/vagrant-onap/lib/asserts | 11 | ||||
-rwxr-xr-x | bootstrap/vagrant-onap/lib/commons | 28 | ||||
-rwxr-xr-x | bootstrap/vagrant-onap/lib/dcae | 103 | ||||
-rwxr-xr-x | bootstrap/vagrant-onap/lib/functions | 204 | ||||
-rwxr-xr-x | bootstrap/vagrant-onap/lib/mr | 18 | ||||
-rwxr-xr-x | bootstrap/vagrant-onap/lib/mso | 84 | ||||
-rwxr-xr-x | bootstrap/vagrant-onap/lib/policy | 25 | ||||
-rwxr-xr-x | bootstrap/vagrant-onap/lib/portal | 60 | ||||
-rwxr-xr-x | bootstrap/vagrant-onap/lib/robot | 31 | ||||
-rwxr-xr-x | bootstrap/vagrant-onap/lib/sdc | 79 | ||||
-rwxr-xr-x | bootstrap/vagrant-onap/lib/sdnc | 38 | ||||
-rwxr-xr-x | bootstrap/vagrant-onap/lib/vid | 29 |
14 files changed, 829 insertions, 0 deletions
diff --git a/bootstrap/vagrant-onap/lib/aai b/bootstrap/vagrant-onap/lib/aai new file mode 100755 index 000000000..1cb9e37e9 --- /dev/null +++ b/bootstrap/vagrant-onap/lib/aai @@ -0,0 +1,92 @@ +#!/bin/bash + +set -o xtrace + +source /var/onap/functions + +hbase_version=1.2.3 + +# pull_hbase_image() - Pull HBase container image from a Docker Registry Hub +function pull_hbase_image { + is_package_installed docker-ce || install_docker + docker login -u $nexus_username -p $nexus_password $nexus_docker_repo + docker pull $nexus_docker_repo/aaidocker/aai-hbase-${hbase_version} +} + +# install_hbase() - Install HBase Service +function install_hbase { + docker rm -f hbase + pull_hbase_image + docker run -d --net=host --name="hbase" $nexus_docker_repo/aaidocker/aai-hbase-${hbase_version} +} + +# install_ajsc() - Install ASJC Java service container +function install_ajsc_aai { + cat <<EOL > /etc/ajsc-aai.conf +AAI_REPO_PATH=r/aai +AAI_CHEF_ENV=simpledemo +AAI_CHEF_LOC=/var/chef/aai-data/environments +docker_gitbranch=master +EOL + docker rm -f aai-service + pull_openecomp_image ajsc-aai + docker run --env-file /etc/ajsc-aai.conf --name=aai-service --net=host -v /etc/ssl/certs/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt -it -d $nexus_docker_repo/openecomp/ajsc-aai:$docker_version +} + +# install_model_loader() Install Model Loader +function install_model_loader { + local src_folder=/opt/aai/model-loader/ + cat <<EOL > /etc/model-loader.conf +DISTR_CLIENT_ASDC_ADDRESS=${SDC_ADDRESS:-c2.vm1.sdc.simpledemo.openecomp.org:8443} +DISTR_CLIENT_CONSUMER_GROUP=${UEB_CONSUMER_GROUP:-SDCGroup} +DISTR_CLIENT_CONSUMER_ID=${UEB_CONSUMER_GROUP_ID:-UEB} +DISTR_CLIENT_ENVIRONMENT_NAME=${dmaap_topic} +DISTR_CLIENT_PASSWORD=${SDC_PASSWORD:-OBF:1ks51l8d1o3i1pcc1r2r1e211r391kls1pyj1z7u1njf1lx51go21hnj1y0k1mli1sop1k8o1j651vu91mxw1vun1mze1vv11j8x1k5i1sp11mjc1y161hlr1gm41m111nkj1z781pw31kku1r4p1e391r571pbm1o741l4x1ksp} +DISTR_CLIENT_USER=${SDC_USER:-aai} + +APP_SERVER_BASE_URL=${APP_SERVER_URL:-https://c1.vm1.aai.simpledemo.openecomp.org:8443} +APP_SERVER_AUTH_USER=${APP_USER:-ModelLoader} +APP_SERVER_KEYSTORE_PASSWORD=OBF:1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o +APP_SERVER_AUTH_PASSWORD=${APP_PASSWORD:-OBF:1qvu1v2h1sov1sar1wfw1j7j1wg21saj1sov1v1x1qxw} +EOL + + docker rm -f model-loader-service + if [[ "$build_image" == "True" ]]; then + clone_repo aai/model-loader $src_folder + build_docker_image $src_folder + docker run --env-file /etc/model-loader.conf model-loader + else + pull_openecomp_image model-loader + docker run --name=model-loader-service -it -d --env-file /etc/model-loader.conf $nexus_docker_repo/openecomp/model-loader:$docker_version + fi +} + +# wait_for_sdc() - Function that determines if SDC is up and running +function wait_for_sdc { + if [[ -s "/opt/config/sdc_ip_addr.txt" ]]; then + SDC_IP_ADDR=$(cat /opt/config/sdc_ip_addr.txt) + else + SDC_IP_ADDR="10.0.3.1" + fi + + # Run Health Check against SDC and verify that all five components are up + RES=$(curl http://$SDC_IP_ADDR:8181/sdc1/rest/healthCheck | grep -c "OK") + while [[ $RES -lt 5 ]]; do + RES=$(curl http://$SDC_IP_ADDR:8181/sdc1/rest/healthCheck | grep -c "OK") + done +} + +# init_aai() - Function that initialize AAI services +function init_aai { + mkdir -p /opt/openecomp/aai/logs + mkdir -p /opt/openecomp/aai/data + + install_hbase + + # Wait 3 minutes before instantiating the A&AI container + sleep 180 + + install_ajsc_aai + wait_for_sdc + install_model_loader +} diff --git a/bootstrap/vagrant-onap/lib/appc b/bootstrap/vagrant-onap/lib/appc new file mode 100755 index 000000000..ffec841f4 --- /dev/null +++ b/bootstrap/vagrant-onap/lib/appc @@ -0,0 +1,27 @@ +#!/bin/bash + +set -o xtrace + +source /var/onap/sdnc + +# install_appc() - Function that clones and installs the APPC services from source code +function install_appc { + local src_folder=/opt/appc + clone_repo appc/deployment $src_folder + if [[ "$build_image" == "True" ]]; then + build_sdnc_images + build_docker_image $src_folder/deployment/installation/appc docker + else + pull_openecomp_image appc-image openecomp/appc-image:latest + pull_openecomp_image dgbuilder-sdnc-image openecomp/dgbuilder-sdnc-image:latest + fi + pushd $src_folder + install_docker_compose + /opt/docker/docker-compose up -d + popd +} + +# init_appc() - Function that initialize APPC services +function init_appc { + install_appc +} diff --git a/bootstrap/vagrant-onap/lib/asserts b/bootstrap/vagrant-onap/lib/asserts new file mode 100755 index 000000000..0e455382a --- /dev/null +++ b/bootstrap/vagrant-onap/lib/asserts @@ -0,0 +1,11 @@ +#!/bin/bash + +set -o xtrace + +# asserts_image() - Function that verifies if a specific image was created +function asserts_image { + if [[ "$(docker images -q $1 2> /dev/null)" == "" ]]; then + echo "There is no $1 image" + exit 1 + fi +} diff --git a/bootstrap/vagrant-onap/lib/commons b/bootstrap/vagrant-onap/lib/commons new file mode 100755 index 000000000..783dc0b36 --- /dev/null +++ b/bootstrap/vagrant-onap/lib/commons @@ -0,0 +1,28 @@ +#!/bin/bash + +set -o xtrace + +# update_repos() - Function that updates linux repositories +function update_repos { + if [ -f /var/onap/files/sources.list ]; then + cp /var/onap/files/sources.list /etc/apt/sources.list + fi + apt-get update -y +} + +# is_package_installed() - Function to tell if a package is installed +function is_package_installed { + if [[ -z "$@" ]]; then + return 1 + fi + dpkg -s "$@" > /dev/null 2> /dev/null +} + +# install_package() - Install specific package if doesn't exist +function install_package { + local package=$1 + if ! is_package_installed $package; then + update_repos + apt-get install -y $package + fi +} diff --git a/bootstrap/vagrant-onap/lib/dcae b/bootstrap/vagrant-onap/lib/dcae new file mode 100755 index 000000000..0f6e27507 --- /dev/null +++ b/bootstrap/vagrant-onap/lib/dcae @@ -0,0 +1,103 @@ +#!/bin/bash + +set -o xtrace + +source /var/onap/functions +source /var/onap/asserts + +# create_config_file() - Creates a configuration yaml file for the controller +function create_config_file { + mkdir -p /opt/app/dcae-controller + cat > /opt/app/dcae-controller/config.yaml << EOL +ZONE: $dcae_zone +STATE: $dcae_state +DCAE-VERSION: $artifacts_version +HORIZON-URL: https://mycloud.rackspace.com/cloud/$tenant_id +KEYSTONE-URL: https://identity.api.rackspacecloud.com/v2.0 +OPENSTACK-TENANT-ID: $tenant_id +OPENSTACK-TENANT-NAME: OPEN-ECOMP +OPENSTACK-REGION: $openstack_region +OPENSTACK-PRIVATE-NETWORK: $openstack_private_network_name +OPENSTACK-USER: $openstack_user +OPENSTACK-PASSWORD: $openstack_password +OPENSTACK-KEYNAME: ${key_name}${rand_str}_dcae +OPENSTACK-PUBKEY: $pub_key + +NEXUS-URL-ROOT: $nexus_repo_root +NEXUS-USER: $nexus_username +NEXUS-PASSWORD: $nexus_password +NEXUS-URL-SNAPSHOTS: $nexus_url_snapshots +NEXUS-RAWURL: $nexus_repo + +DOCKER-REGISTRY: $nexus_docker_repo + +GIT-MR-REPO: http://gerrit.onap.org/r/dcae/demo/startup/message-router.git +EOL +} + +# compile_docker_image() - Function that clones, compiles and build a Docker image +function compile_docker_image { + local repo=$1 + local src_folder=$2 + local name=$3 + clone_repo dcae/dmaapbc $src_folder + compile_src $src_folder + pushd $src_folder + # TODO(electrocucaracha) Workaround for dmmapb images + sed -i '/LocalKey/d' Dockerfile + local docker_build="docker build -t $name -f ./Dockerfile ." + if [ $http_proxy ]; then + docker_build+=" --build-arg http_proxy=$http_proxy" + fi + if [ $https_proxy ]; then + docker_build+=" --build-arg https_proxy=$https_proxy" + fi + eval $docker_build + asserts_image $name + popd +} + +# install_dcae() - Function that clones and installs the DCAE controller services from source code +function install_dcae { + export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1) + local src_folder=/opt/dcae-startup-vm-controller + clone_repo dcae/demo/startup/controller $src_folder + pushd $src_folder + install_docker_compose + if [[ "$build_image" == "True" ]]; then + install_docker + src_folder=/opt/dcae + + compile_docker_image dcae/dmaapb $src_folder/dmaapbc openecomp/dcae-dmaapbc + compile_docker_image dcae/orch-dispatcher $src_folder/orch-dispatcher dcae/orch-dispatcher + + clone_repo dcae/demo $src_folder/demo + compile_src $src_folder/demo + pushd $src_folder/demo + bash dcae-demo-controller/src/main/docker-build/build.sh + asserts_image dcae-controller + popd + + clone_repo dcae/dcae-inventory $src_folder/dcae-inventory + compile_src $src_folder/dcae-inventory + build_docker_image $src_folder/dcae-inventory + asserts_image dcae-inventory + + dcae_image=`docker images | grep dcae-controller | awk '{print $1 ":" $2}'` + sed -i "s|DOCKER-REGISTRY/openecomp/dcae-controller:DCAE-VERSION|$dcae_image|g" docker-compose.yml + sed -i "s|MTU|$MTU|g" docker-compose.yml + /opt/docker/docker-compose up -d + else + bash init.sh + install_package make + make up + fi + + popd +} + +# init_dcae() - Function that initialize DCAE Controller services +function init_dcae { + create_config_file + install_dcae +} diff --git a/bootstrap/vagrant-onap/lib/functions b/bootstrap/vagrant-onap/lib/functions new file mode 100755 index 000000000..fddd49a2a --- /dev/null +++ b/bootstrap/vagrant-onap/lib/functions @@ -0,0 +1,204 @@ +#!/bin/bash + +set -o xtrace + +source /var/onap/commons + +# configure_dns() - DNS/GW IP address configuration +function configure_dns { + echo "nameserver 10.0.0.1" >> /etc/resolvconf/resolv.conf.d/head + 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 +# 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 { + local count=0 + local timeout=0 + + install_package git + until timeout -s SIGINT ${timeout} git "$@"; do + # 124 is timeout(1)'s special return code when it reached the + # timeout; otherwise assume fatal failure + if [[ $? -ne 124 ]]; then + exit 1 + fi + + count=$(($count + 1)) + if [ $count -eq 3 ]; then + exit 1 + fi + sleep 5 + done +} + +# clone_repo() - Clone Git repository into specific folder +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 + else + pushd $dest_folder + git_timed pull + popd + fi +} + +# install_dev_tools() - Install basic dependencies +function install_dev_tools { + install_package apt-transport-https + install_package ca-certificates + install_package curl +} + +# 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 + add-apt-repository -y ppa:openjdk-r/ppa + install_package openjdk-8-jdk +} + +# install_maven() - Install maven binaries +function install_maven { + if is_package_installed maven; then + return + fi + if ! is_package_installed openjdk-8-jdk; then + install_java + fi + install_package software-properties-common + add-apt-repository -y ppa:andrei-pozolotin/maven3 + install_package maven3 + + # Force Maven3 to use jdk8 + apt-get purge openjdk-7-jdk -y +} + +# 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 + if [ $https_proxy ]; then + echo "export https_proxy=$https_proxy" >> /etc/default/docker + 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" + fi + eval $mvn_docker + popd +} + +# 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_docker() - Download and install docker-engine +function install_docker { + if is_package_installed docker-ce; then + return + fi + install_package software-properties-common + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - + add-apt-repository \ + "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ + $(lsb_release -cs) \ + stable" + install_package docker-ce + configure_docker_proxy + service docker restart +} + +# install_docker_compose() - Download and install docker-engine +function install_docker_compose { + local docker_compose_version=${1:-1.12.0} + if [ ! -d /opt/docker ]; then + mkdir /opt/docker + curl -L https://github.com/docker/compose/releases/download/$docker_compose_version/docker-compose-`uname -s`-`uname -m` > /opt/docker/docker-compose + chmod +x /opt/docker/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 +} diff --git a/bootstrap/vagrant-onap/lib/mr b/bootstrap/vagrant-onap/lib/mr new file mode 100755 index 000000000..8b92bc9c8 --- /dev/null +++ b/bootstrap/vagrant-onap/lib/mr @@ -0,0 +1,18 @@ +#!/bin/bash + +set -o xtrace + +# install_message_router() - Downloads and configure message router source code +function install_message_router { + local src_folder=/opt/dcae/message-router + clone_repo dcae/demo/startup/message-router $src_folder + pushd $src_folder + is_package_installed docker-ce || install_docker + bash deploy.sh + popd +} + +# init_mr() - Function that initialize Message Router services +function init_mr { + install_message_router +} diff --git a/bootstrap/vagrant-onap/lib/mso b/bootstrap/vagrant-onap/lib/mso new file mode 100755 index 000000000..0cffbf0d4 --- /dev/null +++ b/bootstrap/vagrant-onap/lib/mso @@ -0,0 +1,84 @@ +#!/bin/bash + +set -o xtrace + +source /var/onap/functions + +# install_mso() - Installation of mso images +function install_mso { + local src_folder=/opt/mso + if [[ "$build_image" == "True" ]]; then + clone_repo mso $src_folder + export GIT_NO_PROJECT=/opt/ + build_docker_image $src_folder/packages/docker + fi +} + +# install_mso_docker_config() - Download and install MSO Docker configuration project +function install_mso_docker_config { + local src_folder=/opt/mso/docker-config + clone_repo mso/docker-config $src_folder + MSO_ENCRYPTION_KEY=$(cat /opt/mso/docker-config/encryption.key) + echo -n "$openstack_api_key" | openssl aes-128-ecb -e -K $MSO_ENCRYPTION_KEY -nosalt | xxd -c 256 -p > /opt/config/api_key.txt + + # Deployments in OpenStack require a keystone file + if [ -e /opt/config/keystone.txt ]; then + KEYSTONE_URL=$(cat /opt/config/keystone.txt) + DCP_CLLI="DEFAULT_KEYSTONE" + AUTH_TYPE="USERNAME_PASSWORD" + else + KEYSTONE_URL="https://identity.api.rackspacecloud.com/v2.0" + DCP_CLLI="RAX_KEYSTONE" + AUTH_TYPE="RACKSPACE_APIKEY" + fi + + # Update the MSO configuration file. + read -d '' MSO_CONFIG_UPDATES <<-EOF +{ +"default_attributes": + { + "asdc-connections": + { + "asdc-controller1": + { + "environmentName": "$dmaap_topic" + } + }, + "mso-po-adapter-config": + { + "identity_services": + [ + { + "dcp_clli": "$DCP_CLLI", + "identity_url": "$KEYSTONE_URL", + "mso_id": "$openstack_username", + "mso_pass": "$openstack_password", + "admin_tenant": "service", + "member_role": "admin", + "tenant_metadata": "true", + "identity_server_type": "KEYSTONE", + "identity_authentication_type": "$AUTH_TYPE" + } + ] + } + } +} +EOF + export MSO_CONFIG_UPDATES + export MSO_DOCKER_IMAGE_VERSION=$docker_version + + # Deploy the environment + pushd $src_folder + chmod +x deploy.sh + is_package_installed docker-ce || install_docker + install_docker_compose + # This script takes in input 2 nexus repos (the first one for the MSO image, the second one for mariadb) + ./deploy.sh $nexus_docker_repo $nexus_username $nexus_password $nexus_docker_repo $nexus_username $nexus_password + popd +} + +# init_mso() - Function that initialize MSO services +function init_mso { + install_mso + install_mso_docker_config +} diff --git a/bootstrap/vagrant-onap/lib/policy b/bootstrap/vagrant-onap/lib/policy new file mode 100755 index 000000000..270022d94 --- /dev/null +++ b/bootstrap/vagrant-onap/lib/policy @@ -0,0 +1,25 @@ +#!/bin/bash + +set -o xtrace + +# install_policy() - Function that clones and installs the Policy services from source code +function install_policy { + local src_folder=/opt/policy + clone_repo policy/docker $src_folder + pushd $src_folder + chmod +x config/drools/drools-tweaks.sh + IP_ADDRESS=$(ifconfig eth0 | grep "inet addr" | tr -s ' ' | cut -d' ' -f3 | cut -d':' -f2) + echo $IP_ADDRESS > config/pe/ip_addr.txt + install_docker_compose + /opt/docker/docker-compose up -d + popd +} + +# init_policy() - Function that initialize Policy services +function init_policy { + pull_onap_image policy/policy-db onap/policy/policy-db:latest + pull_onap_image policy/policy-pe onap/policy/policy-pe:latest + pull_onap_image policy/policy-drools onap/policy/policy-drools:latest + pull_onap_image policy/policy-nexus onap/policy/policy-nexus:latest + install_policy +} diff --git a/bootstrap/vagrant-onap/lib/portal b/bootstrap/vagrant-onap/lib/portal new file mode 100755 index 000000000..bd9559313 --- /dev/null +++ b/bootstrap/vagrant-onap/lib/portal @@ -0,0 +1,60 @@ +#!/bin/bash + +set -o xtrace + +source /var/onap/functions + +# install_mariadb() - Pull and create a MariaDB container +function install_mariadb { + is_package_installed docker-ce || install_docker + docker pull mariadb + docker create --name data_vol_portal -v /var/lib/mysql mariadb +} + +# install_portal() - Function that pulls and install the source code of Portal +function install_portal { + local src_folder=/opt/portal + clone_repo portal $src_folder + install_docker + docker rm -f ecompdb_portal + docker rm -f 1610-1 + if [[ "$build_image" == "True" ]]; then + # Build locally + install_maven + + clone_repo ecompsdkos $src_folder/ecompsdkos + clone_repo "ui/dmaapbc" $src_folder/dmaapbc + pushd $src_folder/deliveries + chmod +x *.sh + bash run.sh + popd + else + pull_openecomp_image portaldb ecompdb:portal + pull_openecomp_image portalapps ep:1610-1 + + chmod +x $src_folder/deliveries/new_start.sh + chmod +x $src_folder/deliveries/new_stop.sh + chmod +x $src_folder/deliveries/dbstart.sh + mkdir -p /PROJECT/OpenSource/UbuntuEP/logs + install_package unzip + unzip -o $src_folder/deliveries/etc.zip -d /PROJECT/OpenSource/UbuntuEP/ + + bash $src_folder/deliveries/dbstart.sh + bash $src_folder/deliveries/new_start.sh + + sleep 180 + + if [ ! -e /opt/config/boot.txt ]; then + IP_ADDRESS=$(ifconfig eth0 | grep "inet addr" | tr -s ' ' | cut -d' ' -f3 | cut -d':' -f2) + install_package mysql-client + mysql -u root -p'Aa123456' -h $IP_ADDRESS < $src_folder/deliveries/Apps_Users_OnBoarding_Script.sql + echo "yes" > /opt/config/boot.txt + fi + fi +} + +# init_portal() - Function that initialize Portal services +function init_portal { + install_mariadb + install_portal +} diff --git a/bootstrap/vagrant-onap/lib/robot b/bootstrap/vagrant-onap/lib/robot new file mode 100755 index 000000000..75a361f4d --- /dev/null +++ b/bootstrap/vagrant-onap/lib/robot @@ -0,0 +1,31 @@ +#!/bin/bash + +set -o xtrace + +# install_testsuite_properties() - Download and install testsuite properties +function install_testsuite_properties { + mkdir -p /opt/eteshare/config + + local $src_folder=/opt/testsuite/properties + clone_repo testsuite/properties $src_folder + cp $src_folder/integration_* /opt/eteshare/config + cp $src_folder/vm_config2robot.sh /opt/eteshare/config + cp $src_folder/ete.sh /opt + cp $src_folderdemo.sh /opt + + chmod +x /opt/ete.sh + chmod +x /opt/demo.sh +} + +# run_testsuite_image() - Pull and run testsuite docker image +function run_testsuite_image { + pull_openecomp_image testsuite + docker rm -f openecompete_container + docker run -d --name openecompete_container -v /opt/eteshare:/share -p 88:88 $nexus_docker_repo/openecomp/testsuite:$docker_version +} + +# init_robot() - Function that initialize Robot services +function init_robot { + install_testsuite_properties + run_testsuite_image +} diff --git a/bootstrap/vagrant-onap/lib/sdc b/bootstrap/vagrant-onap/lib/sdc new file mode 100755 index 000000000..15787b064 --- /dev/null +++ b/bootstrap/vagrant-onap/lib/sdc @@ -0,0 +1,79 @@ +#!/bin/bash + +set -o xtrace + +# mount_external_partition() - Create partition and mount the external volume +function mount_external_partition { + cat <<EOL > /tmp/asdc_ext_volume_partitions.txt +# partition table of /dev/sdb +unit: sectors + +/dev/sdb1 : start= 2048, size=209713152, Id=83 +/dev/sdb2 : start= 0, size= 0, Id= 0 +/dev/sdb3 : start= 0, size= 0, Id= 0 +/dev/sdb4 : start= 0, size= 0, Id= 0 +EOL + sfdisk --force /dev/sdb < /tmp/asdc_ext_volume_partitions.txt + mkfs -t ext4 /dev/sdb1 + mkdir -p /data + mount /dev/sdb1 /data + echo "/dev/sdb1 /data ext4 errors=remount-ro,noatime,barrier=0 0 1" >> /etc/fstab +} + +# init_data_folders() - Function that initialize the data folders +function init_data_folders { + mkdir -p /data/environments + mkdir -p /data/scripts + mkdir -p /data/logs/BE + mkdir -p /data/logs/FE + chmod 777 /data + chmod 777 /data/logs/BE + chmod 777 /data/logs/FE +} + +# setup_docker_aliases() - Function that setups the aliases required by sdc scripts +function setup_docker_aliases { + cat <<EOL > /root/.bash_aliases +alias dcls='/data/scripts/docker_clean.sh \$1' +alias dlog='/data/scripts/docker_login.sh \$1' +alias rund='/data/scripts/docker_run.sh' +alias health='/data/scripts/docker_health.sh' +EOL +} + +# install_sdc() - Function that pull templates and executes +function install_sdc { + IP_ADDRESS=$(ifconfig eth0 | grep "inet addr" | tr -s ' ' | cut -d' ' -f3 | cut -d':' -f2) + local ENV_NAME=$dmaap_topic + local MR_IP_ADDR='10.0.11.1' + local RELEASE=$docker_version + NEXUS_DOCKER_PORT=$(echo $nexus_docker_repo | cut -d':' -f2) + local src_folder=/opt/sdc + clone_repo sdc $src_folder + if [[ "$build_image" == "True" ]]; then + compile_src $src_folder + build_docker_image $src_folder/sdc-os-chef + fi + cp $src_folder/sdc-os-chef/environments/Template.json /data/environments + cp $src_folder/sdc-os-chef/scripts/docker_run.sh /data/scripts + cp $src_folder/sdc-os-chef/scripts/docker_health.sh /data/scripts + chmod +x /data/scripts/docker_run.sh + chmod +x /data/scripts/docker_health.sh + + cat /data/environments/Template.json | sed "s/yyy/"$IP_ADDRESS"/g" > /data/environments/$ENV_NAME.json + sed -i "s/xxx/"$ENV_NAME"/g" /data/environments/$ENV_NAME.json + sed -i "s/\"ueb_url_list\":.*/\"ueb_url_list\": \""$MR_IP_ADDR","$MR_IP_ADDR"\",/g" /data/environments/$ENV_NAME.json + sed -i "s/\"fqdn\":.*/\"fqdn\": [\""$MR_IP_ADDR"\", \""$MR_IP_ADDR"\"]/g" /data/environments/$ENV_NAME.json + + is_package_installed docker-ce || install_docker + docker login -u $nexus_username -p $nexus_password $nexus_docker_repo + bash /data/scripts/docker_run.sh -e $ENV_NAME -r $RELEASE -p $NEXUS_DOCKER_PORT +} + +# init_sdc() - Function that initialize SDC services +function init_sdc { + mount_external_partition + init_data_folders + setup_docker_aliases + install_sdc +} diff --git a/bootstrap/vagrant-onap/lib/sdnc b/bootstrap/vagrant-onap/lib/sdnc new file mode 100755 index 000000000..b3c64f90e --- /dev/null +++ b/bootstrap/vagrant-onap/lib/sdnc @@ -0,0 +1,38 @@ +#!/bin/bash + +set -o xtrace + +# build_sdnc_images() - Builds SDNC images from source code +function build_sdnc_images { + local src_folder=/opt/sdnc/oam + clone_repo sdnc/oam $src_folder + build_docker_image $src_folder/installation/ubuntu + /var/lib/dpkg/info/ca-certificates-java.postinst configure + build_docker_image $src_folder/installation/sdnc + build_docker_image $src_folder/installation/admportal + build_docker_image $src_folder/installation/dgbuilder +} + +# install_sdnc() - Download and install SDNC services from source code +function install_sdnc { + install_package unzip + local src_folder=/opt/sdnc/oam + export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1) + clone_repo sdnc/oam $src_folder + if [[ "$build_image" == "True" ]]; then + build_sdnc_images + else + pull_openecomp_image sdnc-image openecomp/sdnc-image:latest + pull_openecomp_image admportal-sdnc-image openecomp/admportal-sdnc-image:latest + pull_openecomp_image dgbuilder-sdnc-image openecomp/dgbuilder-sdnc-image:latest + fi + pushd $src_folder/installation/src/main/yaml + install_docker_compose + /opt/docker/docker-compose up -d + popd +} + +# init_sdnc() - Function that initialize SDNC services +function init_sdnc { + install_sdnc +} diff --git a/bootstrap/vagrant-onap/lib/vid b/bootstrap/vagrant-onap/lib/vid new file mode 100755 index 000000000..25d2c68f6 --- /dev/null +++ b/bootstrap/vagrant-onap/lib/vid @@ -0,0 +1,29 @@ +#!/bin/bash + +set -o xtrace + +# pull_mariadb_image() - Pull MariaDB container image from a Docker Registry Hub +function pull_mariadb_image { + is_package_installed docker-ce || install_docker + docker login -u $nexus_username -p $nexus_password $nexus_docker_repo + docker pull $nexus_docker_repo/library/mariadb:10 +} + +# install_vid() - Download and configure Vid source code +function install_vid { + local src_folder=/opt/vid + clone_repo vid $src_folder + pull_openecomp_image vid + pull_mariadb_image + + docker rm -f vid-mariadb + docker rm -f vid-server + + docker run --name vid-mariadb -e MYSQL_DATABASE=vid_openecomp -e MYSQL_USER=vidadmin -e MYSQL_PASSWORD=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U -e MYSQL_ROOT_PASSWORD=LF+tp_1WqgSY -v /opt/vid/lf_config/vid-my.cnf:/etc/mysql/my.cnf -v /opt/vid/lf_config/vid-pre-init.sql:/docker-entrypoint-initdb.d/vid-pre-init.sql -v /var/lib/mysql -d mariadb:10 + docker run -e VID_MYSQL_DBNAME=vid_openecomp -e VID_MYSQL_PASS=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U --name vid-server -p 8080:8080 --link vid-mariadb:vid-mariadb-docker-instance -d $nexus_docker_repo/openecomp/vid:$docker_version +} + +# init_vid() - Function that initialize Vid services +function init_vid { + install_vid +} |