diff options
Diffstat (limited to 'bootstrap/vagrant-onap')
-rw-r--r-- | bootstrap/vagrant-onap/.gitignore | 4 | ||||
-rw-r--r-- | bootstrap/vagrant-onap/README.md | 20 | ||||
-rw-r--r-- | bootstrap/vagrant-onap/Vagrantfile | 234 | ||||
-rwxr-xr-x | bootstrap/vagrant-onap/get_repos.sh | 41 | ||||
-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 | ||||
-rwxr-xr-x | bootstrap/vagrant-onap/postinstall.sh | 16 | ||||
-rw-r--r-- | bootstrap/vagrant-onap/tox.ini | 26 |
20 files changed, 1170 insertions, 0 deletions
diff --git a/bootstrap/vagrant-onap/.gitignore b/bootstrap/vagrant-onap/.gitignore new file mode 100644 index 000000000..130fcae06 --- /dev/null +++ b/bootstrap/vagrant-onap/.gitignore @@ -0,0 +1,4 @@ +.vagrant/ +*.swp +.tox/ +opt/ diff --git a/bootstrap/vagrant-onap/README.md b/bootstrap/vagrant-onap/README.md new file mode 100644 index 000000000..86a5abd90 --- /dev/null +++ b/bootstrap/vagrant-onap/README.md @@ -0,0 +1,20 @@ +# Vagrant ONAP + +[![Build Status](https://api.travis-ci.org/electrocucaracha/vagrant-onap.svg?branch=master)](https://api.travis-ci.org/electrocucaracha/vagrant-onap) + +This vagrant project pretends to collect information about a way to deploy [ONAP project](https://www.onap.org/) into a development environment. It was created only for didactic purposes. + +## Requirements: + +* Vagrant +* VirtualBox or Libvirt + +## Steps for execution: + + git clone https://github.com/electrocucaracha/vagrant-onap.git + cd vagrant-onap + vagrant up + +## Destroy: + + vagrant destroy diff --git a/bootstrap/vagrant-onap/Vagrantfile b/bootstrap/vagrant-onap/Vagrantfile new file mode 100644 index 000000000..19c63cfe8 --- /dev/null +++ b/bootstrap/vagrant-onap/Vagrantfile @@ -0,0 +1,234 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +conf = { +# Generic parameters used across all ONAP components + 'public_net_id' => '00000000-0000-0000-0000-000000000000', + 'key_name' => 'ecomp_key', + 'pub_key' => '', + 'nexus_repo' => 'https://nexus.onap.org/content/sites/raw', + 'nexus_docker_repo' => 'nexus3.onap.org:10001', + 'nexus_username' => 'docker', + 'nexus_password' => 'docker', + 'dmaap_topic' => 'AUTO', + 'artifacts_version' => '1.0.0', + 'docker_version' => '1.0-STAGING-latest', + 'gerrit_branch' => 'master', +# Parameters for DCAE instantiation + 'dcae_zone' => 'iad4', + 'dcae_state' => 'vi', + 'openstack_tenant_id' => '', + 'openstack_username' => '', + 'openstack_api_key' => '', + 'openstack_password' => '', + 'nexus_repo_root' => 'https://nexus.onap.org', + 'nexus_url_snapshot' => 'https://nexus.onap.org/content/repositories/snapshots', + 'gitlab_branch' => 'master', + 'build_image' => 'True' +} + +vd_conf = ENV.fetch('VD_CONF', 'etc/settings.yaml') +if File.exist?(vd_conf) + require 'yaml' + user_conf = YAML.load_file(vd_conf) + conf.update(user_conf) +end + +deploy_mode = ENV.fetch('DEPLOY_MODE', 'individual') +sdc_volume='vol1-sdc-data.vdi' + +Vagrant.configure("2") do |config| + + if ENV['http_proxy'] != nil and ENV['https_proxy'] != nil and ENV['no_proxy'] != nil + if not Vagrant.has_plugin?('vagrant-proxyconf') + system 'vagrant plugin install vagrant-proxyconf' + raise 'vagrant-proxyconf was installed but it requires to execute again' + end + config.proxy.http = ENV['http_proxy'] + config.proxy.https = ENV['https_proxy'] + config.proxy.no_proxy = ENV['no_proxy'] + end + + #config.vm.box = 'sputnik13/trusty64' + config.vm.box = 'ubuntu/trusty64' + #config.vm.provision "docker" + config.vm.synced_folder './opt', '/opt/', create: true + config.vm.synced_folder './lib', '/var/onap/', create: true + config.vm.synced_folder '~/.m2', '/root/.m2/', create: true + + config.vm.provider "virtualbox" do |v| + v.customize ["modifyvm", :id, "--memory", 4 * 1024] + end + config.vm.provider "libvirt" do |v| + v.memory = 4 * 1024 + v.nested = true + end + + case deploy_mode + + when 'all-in-one' + + config.vm.define :all_in_one do |all_in_one| + all_in_one.vm.hostname = 'all-in-one' + all_in_one.vm.network :private_network, ip: '192.168.50.3' + all_in_one.vm.provider "virtualbox" do |v| + v.customize ["modifyvm", :id, "--memory", 12 * 1024] + unless File.exist?(sdc_volume) + v.customize ['createhd', '--filename', sdc_volume, '--size', 20 * 1024] + end + v.customize ['storageattach', :id, '--storagectl', 'SATAController', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', sdc_volume] + end + all_in_one.vm.provider "libvirt" do |v| + v.memory = 12 * 1024 + v.nested = true + v.storage :file, path: sdc_volume, bus: 'sata', device: 'vdb', size: '2G' + end + all_in_one.vm.provision 'shell' do |s| + s.path = 'postinstall.sh' + s.args = ['mr', 'sdc', 'aai', 'mso', 'robot', 'vid', 'sdnc', 'portal', 'dcae', 'policy', 'appc'] + s.env = conf + end + end + + when 'individual' + + config.vm.define :dns do |dns| + dns.vm.hostname = 'dns' + dns.vm.network :private_network, ip: '192.168.50.3' + dns.vm.provider "virtualbox" do |v| + v.customize ["modifyvm", :id, "--memory", 1 * 1024] + end + dns.vm.provider "libvirt" do |v| + v.memory = 1 * 1024 + v.nested = true + end + dns.vm.provision 'shell' do |s| + s.path = 'postinstall.sh' + s.env = conf + end + end + + config.vm.define :message_router do |message_router| + message_router.vm.hostname = 'message-router' + message_router.vm.network :private_network, ip: '192.168.50.4' + message_router.vm.provision 'shell' do |s| + s.path = 'postinstall.sh' + s.args = ['mr'] + s.env = conf + end + end + + config.vm.define :sdc do |sdc| + sdc.vm.hostname = 'sdc' + sdc.vm.network :private_network, ip: '192.168.50.5' + sdc.vm.provider "virtualbox" do |v| + v.customize ["modifyvm", :id, "--memory", 4 * 1024] + unless File.exist?(sdc_volume) + v.customize ['createhd', '--filename', sdc_volume, '--size', 20 * 1024] + end + v.customize ['storageattach', :id, '--storagectl', 'SATAController', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', sdc_volume] + end + sdc.vm.provider "libvirt" do |v| + v.memory = 4 * 1024 + v.nested = true + v.storage :file, path: sdc_volume, bus: 'sata', device: 'vdb', size: '2G' + end + sdc.vm.provision 'shell' do |s| + s.path = 'postinstall.sh' + s.args = ['sdc'] + s.env = conf + end + end + + config.vm.define :aai do |aai| + aai.vm.hostname = 'aai' + aai.vm.network :private_network, ip: '192.168.50.6' + aai.vm.provision 'shell' do |s| + s.path = 'postinstall.sh' + s.args = ['aai'] + s.env = conf + end + end + + config.vm.define :mso do |mso| + mso.vm.hostname = 'mso-server' + mso.vm.network :private_network, ip: '192.168.50.7' + mso.vm.provision 'shell' do |s| + s.path = 'postinstall.sh' + s.args = ['mso'] + s.env = conf + end + end + + config.vm.define :robot do |robot| + robot.vm.hostname = 'robot' + robot.vm.network :private_network, ip: '192.168.50.8' + robot.vm.provision 'shell' do |s| + s.path = 'postinstall.sh' + s.args = ['robot'] + s.env = conf + end + end + + config.vm.define :vid do |vid| + vid.vm.hostname = 'vid' + vid.vm.network :private_network, ip: '192.168.50.9' + vid.vm.provision 'shell' do |s| + s.path = 'postinstall.sh' + s.args = ['vid'] + s.env = conf + end + end + + config.vm.define :sdnc do |sdnc| + sdnc.vm.hostname = 'sdnc' + sdnc.vm.network :private_network, ip: '192.168.50.10' + sdnc.vm.provision 'shell' do |s| + s.path = 'postinstall.sh' + s.args = ['sdnc'] + s.env = conf + end + end + + config.vm.define :portal do |portal| + portal.vm.hostname = 'portal' + portal.vm.network :private_network, ip: '192.168.50.11' + portal.vm.provision 'shell' do |s| + s.path = 'postinstall.sh' + s.args = ['portal'] + s.env = conf + end + end + + config.vm.define :dcae do |dcae| + dcae.vm.hostname = 'dcae' + dcae.vm.network :private_network, ip: '192.168.50.12' + dcae.vm.provision 'shell' do |s| + s.path = 'postinstall.sh' + s.args = ['dcae'] + s.env = conf + end + end + + config.vm.define :policy do |policy| + policy.vm.hostname = 'policy' + policy.vm.network :private_network, ip: '192.168.50.13' + policy.vm.provision 'shell' do |s| + s.path = 'postinstall.sh' + s.args = ['policy'] + s.env = conf + end + end + + config.vm.define :appc do |appc| + appc.vm.hostname = 'appc' + appc.vm.network :private_network, ip: '192.168.50.14' + appc.vm.provision 'shell' do |s| + s.path = 'postinstall.sh' + s.args = ['appc'] + s.env = conf + end + end + + end +end diff --git a/bootstrap/vagrant-onap/get_repos.sh b/bootstrap/vagrant-onap/get_repos.sh new file mode 100755 index 000000000..1a98f5096 --- /dev/null +++ b/bootstrap/vagrant-onap/get_repos.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +repos=( +"aai/aai-data" "aai/aai-config" "aai/aai-service" "aai/data-router" "aai/logging-service" "aai/model-loader" "aai/resources" "aai/rest-client" "aai/router-core" "aai/search-data-service" "aai/sparky-be" "aai/sparky-fe" "aai/test-config" "aai/traversal" +"appc" "appc/deployment" +"ci-management" +"dcae" "dcae/apod" "dcae/apod/analytics" "dcae/apod/buildtools" "dcae/apod/cdap" "dcae/collectors" "dcae/collectors/ves" "dcae/controller" "dcae/controller/analytics" "dcae/dcae-inventory" "dcae/demo" "dcae/demo/startup" "dcae/demo/startup/aaf" "dcae/demo/startup/controller" "dcae/demo/startup/message-router" "dcae/dmaapbc" "dcae/operation" "dcae/operation/utils" "dcae/orch-dispatcher" "dcae/pgaas" "dcae/utils" "dcae/utils/buildtools" +"demo" +"ecompsdkos" +"mso" "mso/chef-repo" "mso/docker-config" "mso/libs" "mso/mso-config" +"ncomp" "ncomp/cdap" "ncomp/core" "ncomp/docker" "ncomp/maven" "ncomp/openstack" "ncomp/sirius" "ncomp/sirius/manager" "ncomp/utils" +"policy/common" "policy/docker" "policy/drools-applications" "policy/drools-pdp" "policy/engine" +"portal" +"sdc" "sdc/sdc-distribution-client" "sdc/sdc-titan-cassandra" "sdc/sdc_common" +"sdnc/adaptors" "sdnc/core" "sdnc/northbound" "sdnc/oam" "sdnc/plugins" +"testsuite" "testsuite/heatbridge" "testsuite/properties" "testsuite/python-testing-utils" +"ui" "ui/dmaapbc" +"vid" "vid/asdcclient") + +function git_clone_or_pull { + local repo=$1 + local folder="opt/$1" + local mvn_build=$2 + if [ ! -d $folder ]; then + git clone https://git.onap.org/$repo $folder + fi + pushd $folder > /dev/null + git pull -q + if [ -f .gitreview ]; then + git review -s + fi + #if [ -f pom.xml ] && [ -n ${mvn_build+x} ]; then + #mvn clean -q install -U -DskipTests=true -Dmaven.test.skip=true -Dadditionalparam=-Xdoclint:none + #fi + popd > /dev/null +} + +for repo in ${repos[@]}; do + echo "Working on $repo repository..." + git_clone_or_pull $repo +done 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 +} diff --git a/bootstrap/vagrant-onap/postinstall.sh b/bootstrap/vagrant-onap/postinstall.sh new file mode 100755 index 000000000..b0e64ad32 --- /dev/null +++ b/bootstrap/vagrant-onap/postinstall.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -o xtrace + +source /var/onap/functions + +create_configuration_files +install_dev_tools +install_java +configure_bind + +for serv in $@; do + source /var/onap/${serv} + configure_service ${serv}_serv.sh + init_${serv} +done diff --git a/bootstrap/vagrant-onap/tox.ini b/bootstrap/vagrant-onap/tox.ini new file mode 100644 index 000000000..141c151ee --- /dev/null +++ b/bootstrap/vagrant-onap/tox.ini @@ -0,0 +1,26 @@ +[tox] +minversion = 1.6 +skipsdist = True +envlist = bashate + +[testenv] +passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY +usedevelop = False +install_command = pip install {opts} {packages} + +[testenv:bashate] +# if you want to test out some changes you have made to bashate +# against devstack, just set BASHATE_INSTALL_PATH=/path/... to your +# modified bashate tree +deps = + {env:BASHATE_INSTALL_PATH:bashate==0.5.1} +whitelist_externals = bash +commands = bash -c "find {toxinidir}/{scripts,lib} \ + -not \( -type f -name *.swp -prune \) \ + -not \( -type f -name *.xml -prune \) \ + -type f \ +# E005 file does not begin with #! or have a .sh prefix +# E006 check for lines longer than 79 columns +# E042 local declaration hides errors +# E043 Arithmetic compound has inconsistent return semantics + -print0 | xargs -0 bashate -v -iE006 -eE005,E042,E043" |