diff options
-rw-r--r-- | bootstrap/vagrant-onap/CONTRIBUTING.md | 14 | ||||
-rw-r--r-- | bootstrap/vagrant-onap/README.md | 73 | ||||
-rw-r--r-- | bootstrap/vagrant-onap/Vagrantfile | 55 | ||||
-rw-r--r-- | bootstrap/vagrant-onap/doc/source/index.rst | 3 | ||||
-rw-r--r-- | bootstrap/vagrant-onap/doc/source/install/index.rst | 33 | ||||
-rw-r--r-- | bootstrap/vagrant-onap/doc/source/install/known_issues.rst | 50 | ||||
-rwxr-xr-x | bootstrap/vagrant-onap/lib/aai | 1 | ||||
-rw-r--r-- | bootstrap/vagrant-onap/tools/Run.ps1 | 98 | ||||
-rwxr-xr-x | bootstrap/vagrant-onap/tools/run.sh | 88 | ||||
-rwxr-xr-x | bootstrap/vagrant-onap/vagrant_utils/postinstall.sh (renamed from bootstrap/vagrant-onap/postinstall.sh) | 0 | ||||
-rwxr-xr-x | bootstrap/vagrant-onap/vagrant_utils/unit_testing.sh (renamed from bootstrap/vagrant-onap/unit_testing.sh) | 5 |
11 files changed, 320 insertions, 100 deletions
diff --git a/bootstrap/vagrant-onap/CONTRIBUTING.md b/bootstrap/vagrant-onap/CONTRIBUTING.md index 6f2897ce3..7341a10db 100644 --- a/bootstrap/vagrant-onap/CONTRIBUTING.md +++ b/bootstrap/vagrant-onap/CONTRIBUTING.md @@ -12,19 +12,19 @@ Unit Testing The **_tests_** folder contains ~~scripts~~ _test suites_ that ensure the proper implementation of the _functions_ created on **_lib_** folder. In order to -execute the Unit Tests defined for this project, you must run the following -command: +display the Usage information you must execute the script with question mark as +an argument like follows: - $ ./tools/run.sh testing [test_suite] [function] + $ ./tools/run.sh or using PowerShell PS C:\> Set-ExecutionPolicy Bypass -Scope CurrentUser - PS C:\> .\tools\Run.ps1 testing [test_suite] [function] + PS C:\> .\tools\Run.ps1 testing -? Examples -------- - $ ./tools/run.sh testing # Executes all the Unit Tests - $ ./tools/run.sh testing functions # Executes all the Unit Tests of Functions Test Suite - $ ./tools/run.sh testing functions install_maven # Executes the install_maven Unit Test of Functions Test Suite + $ ./tools/run.sh -y testing # Executes all the Unit Tests unattended mode + $ ./tools/run.sh -s functions testing # Executes all the Unit Tests of Functions Test Suite + $ ./tools/run.sh -s functions -c install_maven testing # Executes the install_maven Unit Test of Functions Test Suite diff --git a/bootstrap/vagrant-onap/README.md b/bootstrap/vagrant-onap/README.md index 99d2de177..cab72c5e9 100644 --- a/bootstrap/vagrant-onap/README.md +++ b/bootstrap/vagrant-onap/README.md @@ -30,53 +30,46 @@ questions faced by new developers * Windows - C:\> vagrant up <app_name> + PS C:\> cd integration\bootstrap\vagrant-onap + PS C:\integration\bootstrap\vagrant-onap> Set-ExecutionPolicy Bypass -Scope CurrentUser + PS C:\integration\bootstrap\vagrant-onap> .\tools\Run.ps1 <app_name> * Linux or Mac OS + $ cd integration/bootstrap/vagrant-onap $ ./tools/run.sh <app_name> current options include: -| app_name | description | -|:---------:|-------------------------------------| -| aai | Active and Available Inventory | -| appc | Application Controller | -| dcae | Data Collection Analytics & Events | -| mr | Message Router | -| mso | Master Service Orchestrator | -| policy | Policy | -| portal | Portal | -| robot | Robot | -| sdc | Service Design & Creation | -| sdnc | Software Defined Network Controller | -| vid | Virtual Infrastructure Development | -| vfc | Virtual Function Controller (WIP) | - -#### setting up proxy in case you are behind a firewall - -add http_proxy and https_proxy to your environment variables - -Linux or Mac - - $ export http_proxy=<proxy> - $ export https_proxy=<proxy> - $ export no_proxy=<no_proxy_urls> - -Windows - - C:\> setx http_proxy <proxy> - C:\> setx https_proxy <proxy> - C:\> setx no_proxy <no_proxy_urls> - -##### choosing vagrant provider -force VirtualBox provider - - C:\> vagrant up --provider=virtualbox - -setup the default provider on Windows - - C:\> setx VAGRANT_DEFAULT_PROVIDER=virtualbox +| app_name | description | +|:----------:|-------------------------------------| +| aai | Active and Available Inventory | +| appc | Application Controller | +| dcae | Data Collection Analytics & Events | +| mr | Message Router | +| mso | Master Service Orchestrator | +| policy | Policy | +| portal | Portal | +| robot | Robot | +| sdc | Service Design & Creation | +| sdnc | Software Defined Network Controller | +| vid | Virtual Infrastructure Development | +| vfc | Virtual Function Controller (WIP) | +| all_in_one | All ONAP services in a VM | +| testing | Unit Test VM | + +#### Generating documentation + +The documentation of this project was written in reStructuredText +format which is located under the [docs folder](../blob/master/doc/source/index.rst). +It's possible to format this documents to HTML using Sphinix python +tool. + + $ tox -e docs + +This results in the creation of a new *doc/build/html* folder with +the documentation converted in HTML pages that can be viewed through +the prefered Web Browser. ## Contributing diff --git a/bootstrap/vagrant-onap/Vagrantfile b/bootstrap/vagrant-onap/Vagrantfile index 0e8e1da1c..50c18c76b 100644 --- a/bootstrap/vagrant-onap/Vagrantfile +++ b/bootstrap/vagrant-onap/Vagrantfile @@ -81,6 +81,11 @@ Vagrant.configure("2") do |config| config.proxy.no_proxy = ENV['no_proxy'] end + if Vagrant.has_plugin?('vagrant-vbguest') + puts 'vagrant-vbguest auto_update feature will be disable to avoid sharing conflicts' + config.vbguest.auto_update = false + end + config.vm.box = 'ubuntu/trusty64' if provider == :libvirt config.vm.box = 'sputnik13/trusty64' @@ -152,7 +157,7 @@ Vagrant.configure("2") do |config| v.flavor = 'm1.xlarge' end all_in_one.vm.provision 'shell' do |s| - s.path = 'postinstall.sh' + s.path = 'vagrant_utils/postinstall.sh' s.args = ['mr', 'sdc', 'aai', 'mso', 'robot', 'vid', 'sdnc', 'portal', 'dcae', 'policy', 'appc', 'vfc'] s.env = conf end @@ -175,7 +180,7 @@ Vagrant.configure("2") do |config| v.flavor = 'm1.small' end dns.vm.provision 'shell' do |s| - s.path = 'postinstall.sh' + s.path = 'vagrant_utils/postinstall.sh' s.env = conf end end @@ -187,7 +192,7 @@ Vagrant.configure("2") do |config| v.server_name = 'message-router' end mr.vm.provision 'shell' do |s| - s.path = 'postinstall.sh' + s.path = 'vagrant_utils/postinstall.sh' s.args = ['mr'] s.env = conf end @@ -209,33 +214,33 @@ Vagrant.configure("2") do |config| v.server_name = 'sdc' end sdc.vm.provision 'shell' do |s| - s.path = 'postinstall.sh' + s.path = 'vagrant_utils/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.provider "openstack" do |v| v.server_name = 'aai' end - aai.vm.provision 'shell' do |s| - s.path = 'postinstall.sh' + aai.vm.provision 'shell' do |s| + s.path = 'vagrant_utils/postinstall.sh' s.args = ['aai'] s.env = conf end end - + config.vm.define :mso do |mso| mso.vm.hostname = 'mso' mso.vm.network :private_network, ip: '192.168.50.7' mso.vm.provider "openstack" do |v| v.server_name = 'mso' end - mso.vm.provision 'shell' do |s| - s.path = 'postinstall.sh' + mso.vm.provision 'shell' do |s| + s.path = 'vagrant_utils/postinstall.sh' s.args = ['mso'] s.env = conf end @@ -248,12 +253,12 @@ Vagrant.configure("2") do |config| v.server_name = 'robot' end robot.vm.provision 'shell' do |s| - s.path = 'postinstall.sh' + s.path = 'vagrant_utils/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' @@ -261,12 +266,12 @@ Vagrant.configure("2") do |config| v.server_name = 'vid' end vid.vm.provision 'shell' do |s| - s.path = 'postinstall.sh' + s.path = 'vagrant_utils/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' @@ -274,12 +279,12 @@ Vagrant.configure("2") do |config| v.server_name = 'sdnc' end sdnc.vm.provision 'shell' do |s| - s.path = 'postinstall.sh' + s.path = 'vagrant_utils/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' @@ -287,12 +292,12 @@ Vagrant.configure("2") do |config| v.server_name = 'portal' end portal.vm.provision 'shell' do |s| - s.path = 'postinstall.sh' + s.path = 'vagrant_utils/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' @@ -300,12 +305,12 @@ Vagrant.configure("2") do |config| v.server_name = 'dcae' end dcae.vm.provision 'shell' do |s| - s.path = 'postinstall.sh' + s.path = 'vagrant_utils/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' @@ -313,12 +318,12 @@ Vagrant.configure("2") do |config| v.server_name = 'policy' end policy.vm.provision 'shell' do |s| - s.path = 'postinstall.sh' + s.path = 'vagrant_utils/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' @@ -326,7 +331,7 @@ Vagrant.configure("2") do |config| v.server_name = 'appc' end appc.vm.provision 'shell' do |s| - s.path = 'postinstall.sh' + s.path = 'vagrant_utils/postinstall.sh' s.args = ['appc'] s.env = conf end @@ -339,7 +344,7 @@ Vagrant.configure("2") do |config| v.server_name = 'vfc' end vfc.vm.provision 'shell' do |s| - s.path = 'postinstall.sh' + s.path = 'vagrant_utils/postinstall.sh' s.args = ['vfc'] s.env = conf end @@ -366,7 +371,7 @@ Vagrant.configure("2") do |config| v.flavor = 'm1.small' end testing.vm.provision 'shell' do |s| - s.path = 'unit_testing.sh' + s.path = 'vagrant_utils/unit_testing.sh' s.args = [test_suite, test_case] s.env = conf end diff --git a/bootstrap/vagrant-onap/doc/source/index.rst b/bootstrap/vagrant-onap/doc/source/index.rst index 509f3483f..af5777ccd 100644 --- a/bootstrap/vagrant-onap/doc/source/index.rst +++ b/bootstrap/vagrant-onap/doc/source/index.rst @@ -11,12 +11,13 @@ using different providers like VirtualBox, Libvirt or OpenStack. __ https://wiki.onap.org/display/DW/ONAP+on+Vagrant -Advanced features +Table of contents ----------------- .. toctree:: :maxdepth: 2 Installation Guide <install/index> + Known Issues <install/known_issues> Advanced Features <features/features> diff --git a/bootstrap/vagrant-onap/doc/source/install/index.rst b/bootstrap/vagrant-onap/doc/source/install/index.rst index 248c956bb..6691b4f0d 100644 --- a/bootstrap/vagrant-onap/doc/source/install/index.rst +++ b/bootstrap/vagrant-onap/doc/source/install/index.rst @@ -61,3 +61,36 @@ Windows 7+ (PowerShell v2+) PS C:\> choco install virtualbox .. end + +.. note:: + + Some corporations use Proxy Servers to protect their assets + from security threats. This project uses the Proxy Environment + variables to connect to those servers in order to download the + content required during the setup. The methods to setup these + variables depends on the Operating system that is used. + + * Linux or Mac OS + + .. code-block:: console + + $ export http_proxy=<proxy> + $ export https_proxy=<proxy> + $ export no_proxy=<no_proxy_urls> + + .. end + + * Windows + + .. code-block:: console + + C:\> setx http_proxy <proxy> + C:\> setx https_proxy <proxy> + C:\> setx no_proxy <no_proxy_urls> + + .. end + +.. note:: + + Vagrant can be configured to use a different default provider + through the environment variable **VAGRANT_DEFAULT_PROVIDER**. diff --git a/bootstrap/vagrant-onap/doc/source/install/known_issues.rst b/bootstrap/vagrant-onap/doc/source/install/known_issues.rst new file mode 100644 index 000000000..84d50940b --- /dev/null +++ b/bootstrap/vagrant-onap/doc/source/install/known_issues.rst @@ -0,0 +1,50 @@ +============ +Known Issues +============ + +Virtualbox guest additions conflict with shared directories +----------------------------------------------------------- + +If the **vagrant-vbguest** plugin is installed on the host, then an +updated version of the Virtualbox guest additions will be installed +on the guest in the /opt directory. Once this projects Vagrantfile +mounts the ./opt directory on the host to the /opt directory on the +guest during the provisioning process, the guest addtions on the +guest are hidden and subsequent mounts of shared directories with the +host will fail. + +The simplest workaround appears to be uninstalling the +*vagrant-vbguest* plugin on the host system. This has been observed +to work on a Windows 10 host using virtualbox 5.1.26. + +Check if vagrant-vbguest plugin is installed + +- Linux or Mac + +.. code-block:: console + + $ vagrant plugin list +.. end + +- Windows + +.. code-block:: console + + C:\> vagrant plugin list +.. end + +Remove vagrant-vbguest plugin + +- Linux or Mac + +.. code-block:: console + + $ vagrant plugin uninstall vagrant-vbguest +.. end + +- Windows + +.. code-block:: console + + C:\> vagrant plugin uninstall vagrant-vbguest +.. end diff --git a/bootstrap/vagrant-onap/lib/aai b/bootstrap/vagrant-onap/lib/aai index df903fd7b..4d828557f 100755 --- a/bootstrap/vagrant-onap/lib/aai +++ b/bootstrap/vagrant-onap/lib/aai @@ -3,7 +3,6 @@ set -o xtrace source /var/onap/functions -source /var/onap/asserts hbase_version=1.2.3 src_folder=$git_src_folder/aai diff --git a/bootstrap/vagrant-onap/tools/Run.ps1 b/bootstrap/vagrant-onap/tools/Run.ps1 index 5469abfd7..4d70140c2 100644 --- a/bootstrap/vagrant-onap/tools/Run.ps1 +++ b/bootstrap/vagrant-onap/tools/Run.ps1 @@ -1,19 +1,93 @@ -switch ($args[0]) +<# +.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. + +.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", "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 = $false +) + +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 + } + } + +switch ($Command) { "all_in_one" { $env:DEPLOY_MODE="all-in-one" } { @("dns", "mr", "sdc", "aai", "mso", "robot", "vid", "sdnc", "portal", "dcae", "policy", "appc") -contains $_ } { $env:DEPLOY_MODE="individual" } "testing" { $env:DEPLOY_MODE="testing" - $test_suite="*" - if (!$args[1]) { $test_suite=$args[1] } - $env:TEST_SUITE=$test_suite - $test_case="*" - if (!$args[2]) { $test_case=$args[2] } - $env:TEST_CASE=$test_case - - Remove-Item ./opt/ -Recurse -Force - Remove-Item $HOME/.m2/ -Recurse -Force + 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 { @@ -22,5 +96,5 @@ switch ($args[0]) } } -vagrant destroy -f $args[0] -vagrant up $args[0] +vagrant destroy -f $Command +vagrant up $Command diff --git a/bootstrap/vagrant-onap/tools/run.sh b/bootstrap/vagrant-onap/tools/run.sh index b9a4a4311..cf31fe4c7 100755 --- a/bootstrap/vagrant-onap/tools/run.sh +++ b/bootstrap/vagrant-onap/tools/run.sh @@ -1,20 +1,90 @@ #!/bin/bash -case $1 in +function usage { + cat <<EOF +Usage: run.sh Command [-y] [-?] +Optional arguments: + -y + Skips warning prompt. + -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 Deploy chosen service. + testing Deploy in testing mode. +EOF +} + +run=false +test_suite="*" +test_case="*" + +COMMAND=$1 + +while getopts "ys:c:" OPTION "${@:2}"; do + case "$OPTION" in + y) + run=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' ;; + export DEPLOY_MODE='all-in-one' + ;; "dns" | "mr" | "sdc" | "aai" | "mso" | "robot" | "vid" | "sdnc" | "portal" | "dcae" | "policy" | "appc" ) - export DEPLOY_MODE='individual' ;; + export DEPLOY_MODE='individual' + ;; "testing" ) export DEPLOY_MODE='testing' - export TEST_SUITE=${2:-*} - export TEST_CASE=${3:-*} + 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/;; + rm -rf ~/.m2/ + ;; * ) - echo $"Usage: $0 {all_in_one|dns|mr|sdc|aai|mso|robot|vid|sdnc|portal|dcae|policy|appc|testing}" + usage exit 1 esac -vagrant destroy -f $1 -vagrant up $1 + +vagrant destroy -f $COMMAND +vagrant up $COMMAND diff --git a/bootstrap/vagrant-onap/postinstall.sh b/bootstrap/vagrant-onap/vagrant_utils/postinstall.sh index f5a7ac684..f5a7ac684 100755 --- a/bootstrap/vagrant-onap/postinstall.sh +++ b/bootstrap/vagrant-onap/vagrant_utils/postinstall.sh diff --git a/bootstrap/vagrant-onap/unit_testing.sh b/bootstrap/vagrant-onap/vagrant_utils/unit_testing.sh index 360d28bc7..a378ad0cd 100755 --- a/bootstrap/vagrant-onap/unit_testing.sh +++ b/bootstrap/vagrant-onap/vagrant_utils/unit_testing.sh @@ -1,10 +1,5 @@ #!/bin/bash -set -o xtrace - -rm -rf /opt/ -rm -rf /root/.m2/ - set -o errexit TEST_SUITE=${1:-*} |