diff options
author | 2018-03-13 12:26:08 -0700 | |
---|---|---|
committer | 2018-03-13 12:26:08 -0700 | |
commit | 4d7590ed7425a94c0f87a8461548c2461d79a710 (patch) | |
tree | 083ffc33a4cd6d8eff42deeea1da0b50c49efdfe /tools | |
parent | ceb22354fcb078e8991a66dc9bc11dd5f21e77f4 (diff) |
Migrate vagrant-onap to devtool repo
This change covers the migration of the vagrant-onap tool's code
which was located under integration repo to devtool's repository.
The tool was renamed to avoid misunderstandings about its goals.
Change-Id: I79df8c35fccaa266a789217d441a6cf1183bd42a
Signed-off-by: Victor Morales <victor.morales@intel.com>
Issue-ID: INT-441
Diffstat (limited to 'tools')
-rw-r--r-- | tools/Run.ps1 | 120 | ||||
-rwxr-xr-x | tools/get_repos.sh | 38 | ||||
-rwxr-xr-x | tools/run.sh | 100 | ||||
-rwxr-xr-x | tools/setup.sh | 133 | ||||
-rwxr-xr-x | tools/setup_openstack.sh | 23 | ||||
-rwxr-xr-x | tools/update_project_list.sh | 5 |
6 files changed, 419 insertions, 0 deletions
diff --git a/tools/Run.ps1 b/tools/Run.ps1 new file mode 100644 index 0000000..de57a15 --- /dev/null +++ b/tools/Run.ps1 @@ -0,0 +1,120 @@ +<# +.SYNOPSIS +This script helps to configure its environment variables based on the component selected. + +.EXAMPLE +.\tools\Run.ps1 testing -s functions -c install_maven -y + +.EXAMPLE +.\tools\Run.ps1 all_in_one + +.EXAMPLE +.\tools\Run.ps1 aai + +.PARAMETER s +Test suite to use in testing mode. + +.PARAMETER c +Test case to use in testing mode. + +.PARAMETER y +Skips warning prompt. + +.PARAMETER g +Skips creation or retrieve image process. + +.PARAMETER i +Skips installation service process. + +.LINK +https://wiki.onap.org/display/DW/ONAP+on+Vagrant +#> + +Param( + [ValidateSet("all_in_one","dns", "mr", "sdc", "aai", "mso", "robot", "vid", "sdnc", "portal", "dcae", "policy", "appc", "vfc", "multicloud", "ccsdk", "vnfsdk", "vvp", "openstack", "msb", "oom", "testing")] + + [Parameter(Mandatory=$True,Position=0)] + [ValidateNotNullOrEmpty()] + [String] + $Command +, + [Parameter(Mandatory=$False,HelpMessage="Test suite to use in testing mode.")] + [Alias("suite")] + [String] + $s = "*" +, + [Parameter(Mandatory=$False,HelpMessage="Test case to sue in testing mode.")] + [Alias("case")] + [String] + $c = "*" +, + [Parameter(Mandatory=$False,HelpMessage="Skips warning prompt.")] + [AllowNull()] + [Switch] + $y = $True +, + [Parameter(Mandatory=$False,HelpMessage="Skips creation or retrieve image process.")] + [AllowNull()] + [Switch] + $skip_get_images = $True +, + [Parameter(Mandatory=$False,HelpMessage="Skips warning prompt.")] + [AllowNull()] + [Switch] + $skip_install = $True +) + +if ( -Not "testing".Equals($Command) ) + { + if($PsBoundParameters.ContainsKey('s')) + { + Write-Host "Test suite should only be specified in testing mode." + Write-Host ".\tools\Run.ps1 -?" + exit 1 + } + if($PsBoundParameters.ContainsKey('c')) + { + Write-Host "Test case should only be specified in testing mode." + Write-Host ".\tools\Run.ps1 -?" + exit 1 + } + } + +$env:SKIP_GET_IMAGES=$skip_get_images +$env:SKIP_INSTALL=$skip_install + +switch ($Command) + { + "all_in_one" { $env:DEPLOY_MODE="all-in-one" } + { @("dns", "mr", "sdc", "aai", "mso", "robot", "vid", "sdnc", "portal", "dcae", "policy", "appc", "vfc", "multicloud", "ccsdk", "vnfsdk", "vvp", "openstack", "msb", "oom") -contains $_ } { $env:DEPLOY_MODE="individual" } + "testing" + { + $env:DEPLOY_MODE="testing" + If(-Not $y) + { + Write-Host "Warning: This test script will delete the contents of ../opt/ and ~/.m2." + $yn = Read-Host "Would you like to continue? [y]es/[n]o: " + switch ($yn) + { + { @("n", "N") -contains $_ } + { + Write-Host "Exiting." + exit 0 + } + } + } + $env:TEST_SUITE=$s + $env:TEST_CASE=$c + + &cmd.exe /c rd /s /q .\opt\ + &cmd.exe /c rd /s /q $HOME\.m2\ + } + default + { + Write-Output $"Usage: $0 {all_in_one|dns|mr|sdc|aai|mso|robot|vid|sdnc|portal|dcae|policy|appc|vfc|multicloud|ccsdk|vnfsdk|vvp|testing}" + exit 1 + } + } + +vagrant destroy -f $Command +vagrant up $Command diff --git a/tools/get_repos.sh b/tools/get_repos.sh new file mode 100755 index 0000000..ae5d4e0 --- /dev/null +++ b/tools/get_repos.sh @@ -0,0 +1,38 @@ +#!/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 + popd > /dev/null +} + +for repo in ${repos[@]}; do + echo "Working on $repo repository..." + git_clone_or_pull $repo +done diff --git a/tools/run.sh b/tools/run.sh new file mode 100755 index 0000000..27e0aa3 --- /dev/null +++ b/tools/run.sh @@ -0,0 +1,100 @@ +#!/bin/bash + +function usage { + cat <<EOF +Usage: run.sh Command [-y] [-?] +Optional arguments: + -y + Skips warning prompt. + -g + Skips creation or retrieve image process. + -i + Skips installation service process. + -s <suite> + Test suite to use in testing mode. + -c <case> + Test case to use in testing mode. +Commands: + all_in_one Deploy in all-in-one mode. + dns|mr|sdc|aai|mso|robot|vid|sdnc|portal|dcae|policy|appc|vfc|vnfsdk|multicloud|ccsdk|vvp|openstack|msb|oom Deploy chosen service. + testing Deploy in testing mode. +EOF +} + +run=false +test_suite="*" +test_case="*" + +COMMAND=$1 + +while getopts "ygis:c:" OPTION "${@:2}"; do + case "$OPTION" in + y) + run=true + ;; + g) + export SKIP_GET_IMAGES="True" + ;; + i) + export SKIP_INSTALL="True" + ;; + s) + if [ "$COMMAND" != "testing" ] ; then + echo "Test suite should only be specified in testing mode." + echo "./tools/run.sh -? for usage." + exit 1 + fi + test_suite=$OPTARG + ;; + c) + if [ "$COMMAND" != "testing" ] ; then + echo "Test case should only be specified in testing mode." + echo "./tools/run.sh -? for usage." + exit 1 + fi + test_case=$OPTARG + ;; + \?) + usage + exit 1 + ;; + esac +done + +case $COMMAND in + "all_in_one" ) + export DEPLOY_MODE='all-in-one' + ;; + "dns" | "mr" | "sdc" | "aai" | "mso" | "robot" | "vid" | "sdnc" | "portal" | "dcae" | "policy" | "appc" | "vfc" | "vnfsdk"| "multicloud" | "ccsdk" | "vvp" | "openstack" | "msb" | "oom" ) + export DEPLOY_MODE='individual' + ;; + "testing" ) + export DEPLOY_MODE='testing' + if [ "$run" == false ] ; then + while true ; do + echo "Warning: This test script will delete the contents of ../opt/ and ~/.m2." + read -p "Would you like to continue? [y]es/[n]o: " yn + case $yn in + [Yy]*) + break + ;; + [Nn]*) + echo "Exiting." + exit 0 + ;; + esac + done + fi + + export TEST_SUITE=$test_suite + export TEST_CASE=$test_case + rm -rf ./opt/ + rm -rf ~/.m2/ + ;; + * ) + usage + exit 1 +esac + +vagrant destroy -f $COMMAND +vagrant up $COMMAND diff --git a/tools/setup.sh b/tools/setup.sh new file mode 100755 index 0000000..fe3a3fc --- /dev/null +++ b/tools/setup.sh @@ -0,0 +1,133 @@ +#!/bin/bash +# SPDX-license-identifier: Apache-2.0 +############################################################################## +# Copyright (c) 2017-2018 +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +vagrant_version=2.0.2 + +function usage { + cat <<EOF +usage: setup.sh -p <PROVIDER> +Argument: + -p Vagrant provider +EOF +} + +while getopts ":p:" OPTION; do + case $OPTION in + p) + provider=$OPTARG + ;; + \?) + usage + exit 1 + ;; + esac +done + +case $provider in + "virtualbox" | "libvirt" ) + export VAGRANT_DEFAULT_PROVIDER=${provider} + ;; + * ) + usage + exit 1 +esac +source /etc/os-release || source /usr/lib/os-release + +packages=() +case ${ID,,} in + *suse) + INSTALLER_CMD="sudo -H -E zypper -q install -y --no-recommends" + + # Vagrant installation + vagrant_pgp="pgp_keys.asc" + wget -q https://keybase.io/hashicorp/$vagrant_pgp + wget -q https://releases.hashicorp.com/vagrant/$vagrant_version/vagrant_${vagrant_version}_x86_64.rpm + gpg --quiet --with-fingerprint $vagrant_pgp + sudo rpm --import $vagrant_pgp + sudo rpm --checksig vagrant_${vagrant_version}_x86_64.rpm + sudo rpm --install vagrant_${vagrant_version}_x86_64.rpm + rm vagrant_${vagrant_version}_x86_64.rpm + rm $vagrant_pgp + + case $VAGRANT_DEFAULT_PROVIDER in + virtualbox) + wget -q http://download.virtualbox.org/virtualbox/rpm/opensuse/$VERSION/virtualbox.repo -P /etc/zypp/repos.d/ + $INSTALLER_CMD --enablerepo=epel dkms + wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | rpm --import - + packages+=(VirtualBox-5.1) + ;; + libvirt) + # vagrant-libvirt dependencies + packages+=(qemu libvirt libvirt-devel ruby-devel gcc qemu-kvm zlib-devel libxml2-devel libxslt-devel make) + # NFS + packages+=(nfs-kernel-server) + ;; + esac + sudo zypper -n ref + ;; + + ubuntu|debian) + INSTALLER_CMD="sudo -H -E apt-get -y -q=3 install" + + # Vagrant installation + wget -q https://releases.hashicorp.com/vagrant/$vagrant_version/vagrant_${vagrant_version}_x86_64.deb + sudo dpkg -i vagrant_${vagrant_version}_x86_64.deb + rm vagrant_${vagrant_version}_x86_64.deb + + case $VAGRANT_DEFAULT_PROVIDER in + virtualbox) + echo "deb http://download.virtualbox.org/virtualbox/debian trusty contrib" >> /etc/apt/sources.list + wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add - + wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add - + packages+=(virtualbox-5.1 dkms) + ;; + libvirt) + # vagrant-libvirt dependencies + packages+=(qemu libvirt-bin ebtables dnsmasq libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev) + # NFS + packages+=(nfs-kernel-server) + ;; + esac + sudo apt-get update + ;; + + rhel|centos|fedora) + PKG_MANAGER=$(which dnf || which yum) + sudo $PKG_MANAGER updateinfo + INSTALLER_CMD="sudo -H -E ${PKG_MANAGER} -q -y install" + + # Vagrant installation + wget -q https://releases.hashicorp.com/vagrant/$vagrant_version/vagrant_${vagrant_version}_x86_64.rpm + $INSTALLER_CMD vagrant_${vagrant_version}_x86_64.rpm + rm vagrant_${vagrant_version}_x86_64.rpm + + case $VAGRANT_DEFAULT_PROVIDER in + virtualbox) + wget -q http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo -P /etc/yum.repos.d + $INSTALLER_CMD --enablerepo=epel dkms + wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | rpm --import - + packages+=(VirtualBox-5.1) + ;; + libvirt) + # vagrant-libvirt dependencies + packages+=(qemu libvirt libvirt-devel ruby-devel gcc qemu-kvm) + # NFS + packages+=(nfs-utils nfs-utils-lib) + ;; + esac + ;; + +esac + +${INSTALLER_CMD} ${packages[@]} +if [ $VAGRANT_DEFAULT_PROVIDER == libvirt ]; then + vagrant plugin install vagrant-libvirt + sudo usermod -a -G libvirt $USER +fi diff --git a/tools/setup_openstack.sh b/tools/setup_openstack.sh new file mode 100755 index 0000000..765ad94 --- /dev/null +++ b/tools/setup_openstack.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +ubuntu_name=${OS_IMAGE:-"trusty-server-cloudimg-amd64-disk1"} +export OS_IMAGE=$ubuntu_name +ubuntu_glance=`openstack image list -c Name -f value | grep "$ubuntu_name"` +ubuntu_file=/tmp/ubuntu.img + +sec_group_name=${OS_SEC_GROUP:-"onap-ssh-secgroup"} +export OS_SEC_GROUP=$sec_group_name +sec_group_list=`openstack security group list -c Name -f value | grep "$sec_group_name"` + +if [[ -z $ubuntu_glance ]]; then + if [ ! -f $ubuntu_file ]; then + curl http://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img -o "$ubuntu_file" + fi + + openstack image create --disk-format raw --container-format bare --public --file $ubuntu_file "$ubuntu_name" +fi + +if [[ -z $sec_group_list ]]; then + openstack security group create "$sec_group_name" + openstack security group rule create --protocol tcp --remote-ip 0.0.0.0/0 --dst-port 22:22 "$sec_group_name" +fi diff --git a/tools/update_project_list.sh b/tools/update_project_list.sh new file mode 100755 index 0000000..2f0ebb9 --- /dev/null +++ b/tools/update_project_list.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +ssh $1@gerrit.onap.org -p 29418 gerrit ls-projects > projects.tmp +tail -n +2 projects.tmp > tests/projects.txt +rm projects.tmp |