Centralize src_folder and repos info

The configuration values that determines where the source code will
be cloned and the list of repos associated to specific project have
been included in a new global configuration file, which pretends to
facilitate their changes.

Change-Id: I700bfe02e6b2f8bf8eef763e44b5e037357ec892
Signed-off-by: Victor Morales <victor.morales@intel.com>
Issue-ID: INT-367
diff --git a/bootstrap/vagrant-onap/lib/aai b/bootstrap/vagrant-onap/lib/aai
index a3e5672..7a68fbb 100755
--- a/bootstrap/vagrant-onap/lib/aai
+++ b/bootstrap/vagrant-onap/lib/aai
@@ -3,12 +3,6 @@
 source /var/onap/functions
 
 hbase_version=1.2.3
-aai_src_folder=$git_src_folder/aai
-aai_repos=("aai/aai-common" "aai/aai-config" "aai/aai-data" "aai/aai-service" \
-"aai/babel" "aai/champ" "aai/data-router" "aai/esr-gui" "aai/esr-server" \
-"aai/gizmo" "aai/logging-service" "aai/model-loader" "aai/resources" \
-"aai/rest-client" "aai/router-core" "aai/search-data-service" \
-"aai/test-config" "aai/traversal" "aai/sparky-fe" "aai/sparky-be")
 
 # install_hadoop() - Function that installs Hadoop
 function install_hadoop {
@@ -54,9 +48,9 @@
 
 # compile_aai_repos() - Function that compiles AAI source repo.
 function compile_aai_repos {
-    local repos=("aai/aai-common" "aai/resources" "aai/logging-service" "aai/traversal")
+    local repos="aai/aai-common aai/resources aai/logging-service aai/traversal"
     if [[ "$compile_repo" == "True" ]]; then
-        repos=("${aai_repos[@]}")
+        repos="${repos[aai]}"
     fi
 
     for repo in ${repos[@]}; do
diff --git a/bootstrap/vagrant-onap/lib/appc b/bootstrap/vagrant-onap/lib/appc
index 14ba3cf..ad01ca5 100755
--- a/bootstrap/vagrant-onap/lib/appc
+++ b/bootstrap/vagrant-onap/lib/appc
@@ -3,9 +3,6 @@
 source /var/onap/sdnc
 source /var/onap/functions
 
-appc_src_folder=$git_src_folder/appc
-appc_repos=("appc" "appc/deployment")
-
 # _build_appc_images() - Function that creates APPC images from source code.
 function _build_appc_images {
     get_sdnc_images
diff --git a/bootstrap/vagrant-onap/lib/ccsdk b/bootstrap/vagrant-onap/lib/ccsdk
index 9f00e9a..112839c 100755
--- a/bootstrap/vagrant-onap/lib/ccsdk
+++ b/bootstrap/vagrant-onap/lib/ccsdk
@@ -2,13 +2,6 @@
 
 source /var/onap/functions
 
-ccsdk_src_folder=$git_src_folder/ccsdk
-ccsdk_repos=("ccsdk" "ccsdk/dashboard" "ccsdk/distribution" "ccsdk/parent"
-"ccsdk/platform/blueprints" "ccsdk/platform/nbapi" "ccsdk/platform/plugins"
-"ccsdk/sli" "ccsdk/sli/adaptors" "ccsdk/sli/core" "ccsdk/sli/northbound"
-"ccsdk/sli/plugins" "ccsdk/storage" "ccsdk/storage/esaas" "ccsdk/storage/pgaas"
-"ccsdk/utils")
-
 # _build_ccsdk_images() - Build CCSDK Docker images from source code
 function _build_ccsdk_images {
     install_package unzip
diff --git a/bootstrap/vagrant-onap/lib/config/env-vars b/bootstrap/vagrant-onap/lib/config/env-vars
new file mode 100755
index 0000000..1eddf67
--- /dev/null
+++ b/bootstrap/vagrant-onap/lib/config/env-vars
@@ -0,0 +1,77 @@
+#!/bin/bash
+
+# Source code destination folder
+git_src_folder=/opt
+
+declare -A src_folders
+src_folders=(
+["aai"]="$git_src_folder/aai"
+["appc"]="$git_src_folder/appc"
+["ccsdk"]="$git_src_folder/ccsdk"
+["dcae"]="$git_src_folder/dcae"
+["mr"]="$git_src_folder/dcae/message-router"
+["msb"]="$git_src_folder/msb"
+["mso"]="$git_src_folder/mso"
+["multicloud"]="$git_src_folder/multicloud"
+["policy"]="$git_src_folder/policy"
+["portal"]="$git_src_folder/portal"
+["robot"]="$git_src_folder/testsuite"
+["sdc"]="$git_src_folder/sdc"
+["sdnc"]="$git_src_folder/openecomp/sdnc"
+["vfc"]="$git_src_folder/vfc"
+["vid"]="$git_src_folder/vid"
+["vnfsdk"]="$git_src_folder/vnfsdk"
+["vvp"]="$git_src_folder/vvp"
+)
+
+# Repositories list
+declare -A repos
+repos=(
+["aai"]="aai/aai-common aai/aai-config aai/aai-data aai/aai-service \
+aai/babel aai/champ aai/data-router aai/esr-gui aai/esr-server aai/gizmo \
+aai/logging-service aai/model-loader aai/resources aai/rest-client \
+aai/router-core aai/search-data-service aai/test-config aai/traversal \
+aai/sparky-fe aai/sparky-be"
+["appc"]="appc appc/deployment"
+["ccsdk"]="ccsdk ccsdk/dashboard ccsdk/distribution ccsdk/parent \
+ccsdk/platform/blueprints ccsdk/platform/nbapi \
+ccsdk/platform/plugins ccsdk/sli ccsdk/sli/adaptors ccsdk/sli/core \
+ccsdk/sli/northbound ccsdk/sli/plugins ccsdk/storage \
+ccsdk/storage/esaas ccsdk/storage/pgaas ccsdk/utils"
+["dcae"]="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"
+["msb"]="msb/apigateway msb/discovery msb/java-sdk msb/swagger-sdk"
+["mso"]="mso mso/chef-repo mso/docker-config mso/libs mso/mso-config"
+["multicloud"]="multicloud multicloud/framework multicloud/openstack \
+multicloud/openstack/vmware multicloud/openstack/windriver \
+multicloud/azure"
+["policy"]="policy/api policy/common policy/docker \
+policy/drools-applications policy/drools-pdp policy/engine \
+policy/gui policy/pap policy/pdp"
+["portal"]="portal portal/sdk ecompsdkos ui/dmaapbc"
+["robot"]="testsuite testsuite/heatbridge testsuite/properties \
+testsuite/python-testing-utils"
+["sdc"]="sdc sdc/jtosca sdc/sdc-distribution-client \
+sdc/sdc-docker-base sdc/sdc-titan-cassandra sdc/sdc-tosca \
+sdc/sdc-vnfdesign sdc/sdc-workflow-designer sdc/sdc_common"
+["sdnc"]="sdnc/adaptors sdnc/architecture sdnc/core sdnc/features \
+sdnc/northbound sdnc/oam sdnc/parent sdnc/plugins"
+["vfc"]="vfc/gvnfm vfc/gvnfm/vnflcm vfc/gvnfm/vnfmgr \
+vfc/gvnfm/vnfres vfc/nfvo vfc/nfvo/catalog vfc/nfvo/driver \
+vfc/nfvo/driver/ems vfc/nfvo/driver/sfc vfc/nfvo/driver/vnfm \
+vfc/nfvo/driver/vnfm/gvnfm vfc/nfvo/driver/vnfm/svnfm vfc/nfvo/lcm \
+vfc/nfvo/resmanagement vfc/nfvo/wfengine"
+["vid"]="vid vid/asdcclient"
+["vnfsdk"]="vnfsdk/compliance vnfsdk/functest vnfsdk/lctest \
+vnfsdk/model vnfsdk/pkgtools vnfsdk/refrepo vnfsdk/validation"
+["vvp"]="vvp/ansible-ice-bootstrap vvp/cms vvp/devkit \
+vvp/documentation vvp/engagementmgr vvp/gitlab vvp/image-scanner \
+vvp/jenkins vvp/portal vvp/postgresql vvp/test-engine \
+vvp/validation-scripts"
+)
+
diff --git a/bootstrap/vagrant-onap/lib/dcae b/bootstrap/vagrant-onap/lib/dcae
index 9150b37..d6fdd89 100755
--- a/bootstrap/vagrant-onap/lib/dcae
+++ b/bootstrap/vagrant-onap/lib/dcae
@@ -2,14 +2,6 @@
 
 source /var/onap/functions
 
-dcae_src_folder=$git_src_folder/dcae
-dcae_repos=("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")
-
 # _create_config_file() - Creates a configuration yaml file for the controller
 function _create_config_file {
     cat > $dcae_src_folder/controller/config.yaml << EOL
diff --git a/bootstrap/vagrant-onap/lib/functions b/bootstrap/vagrant-onap/lib/functions
index 8d906dc..08c6d91 100755
--- a/bootstrap/vagrant-onap/lib/functions
+++ b/bootstrap/vagrant-onap/lib/functions
@@ -1,6 +1,7 @@
 #!/bin/bash
 
 source /var/onap/commons
+source /var/onap/config/env-vars
 source /var/onap/_composed_functions
 source /var/onap/_onap_functions
 
@@ -9,7 +10,6 @@
 export IP_ADDRESS=$(ifconfig $NIC | grep "inet addr" | tr -s ' ' | cut -d' ' -f3 | cut -d':' -f2)
 
 mvn_conf_file=/root/.m2/settings.xml
-git_src_folder=/opt
 
 # configure_dns() - DNS/GW IP address configuration
 function configure_dns {
@@ -71,13 +71,9 @@
 function clone_repos {
     local project=$1
     local repo_name=${2:-$project}
-    local name=${project}_repos[@]
-    local src_name=${project}_src_folder
-    local repos_list=("${!name}")
-    local dest_folder=${!src_name}
 
-    for repo in ${repos_list[@]}; do
-        clone_repo $repo $dest_folder${repo#*$repo_name}
+    for repo in ${repos[$project]}; do
+        clone_repo $repo ${src_folders[$project]}${repo#*$repo_name}
     done
 }
 
@@ -305,13 +301,9 @@
 # compile_repos() - Function that compiles source repositories for a given project
 function compile_repos {
     local project=$1
-    local name=${project}_repos[@]
-    local repos_list=("${!name}")
-    local dest_folder=${3:-$git_src_folder/$project}
 
-    install_package unzip
-    for repo in ${repos_list[@]}; do
-        compile_src $dest_folder${repo#*$project}
+    for repo in ${repos[$project]}; do
+        compile_src ${src_folders[$project]}${repo#*$project}
     done
 }
 
diff --git a/bootstrap/vagrant-onap/lib/mr b/bootstrap/vagrant-onap/lib/mr
index 2ffe69e..499f53f 100755
--- a/bootstrap/vagrant-onap/lib/mr
+++ b/bootstrap/vagrant-onap/lib/mr
@@ -2,8 +2,6 @@
 
 source /var/onap/functions
 
-mr_src_folder=$git_src_folder/dcae/message-router
-
 # get_mr_images() - Function that retrieves the Message Router Docker images
 function get_mr_images {
     pull_docker_image attos/dmaap
diff --git a/bootstrap/vagrant-onap/lib/msb b/bootstrap/vagrant-onap/lib/msb
index 262b29c..a14e8ea 100755
--- a/bootstrap/vagrant-onap/lib/msb
+++ b/bootstrap/vagrant-onap/lib/msb
@@ -2,9 +2,6 @@
 
 source /var/onap/functions
 
-msb_src_folder=$git_src_folder/msb
-msb_repos=("msb/apigateway" "msb/discovery" "msb/java-sdk" "msb/swagger-sdk")
-
 # _build_msb_images() - Function that creates Microservices Docker images from source code
 function _build_msb_images {
     if [[ "$compile_repo" != "True" ]]; then
diff --git a/bootstrap/vagrant-onap/lib/mso b/bootstrap/vagrant-onap/lib/mso
index e99bff9..44d4a7b 100755
--- a/bootstrap/vagrant-onap/lib/mso
+++ b/bootstrap/vagrant-onap/lib/mso
@@ -2,10 +2,6 @@
 
 source /var/onap/functions
 
-mso_src_folder=$git_src_folder/mso
-mso_repos=("mso" "mso/chef-repo" "mso/docker-config" "mso/libs"
-"mso/mso-config")
-
 # get_mso_images() - Function that retrieves or create MSO Docker images
 function get_mso_images {
     if [[ "$build_image" == "True" ]]; then
diff --git a/bootstrap/vagrant-onap/lib/multicloud b/bootstrap/vagrant-onap/lib/multicloud
index 4031956..377d4dc 100755
--- a/bootstrap/vagrant-onap/lib/multicloud
+++ b/bootstrap/vagrant-onap/lib/multicloud
@@ -2,12 +2,9 @@
 
 source /var/onap/functions
 
-multicloud_src_folder=$git_src_folder/multicloud
-multicloud_repos=("multicloud" "multicloud/framework" "multicloud/openstack" \
-"multicloud/openstack/vmware" "multicloud/openstack/windriver" \
-"multicloud/azure")
 openstack_release="newton"
 
+# _build_images() - Function that builds docker images from source code
 function _build_images {
     install_docker
     install_python_requirements $multicloud_src_folder/openstack/$openstack_release
diff --git a/bootstrap/vagrant-onap/lib/policy b/bootstrap/vagrant-onap/lib/policy
index 05ad320..ad982ad 100755
--- a/bootstrap/vagrant-onap/lib/policy
+++ b/bootstrap/vagrant-onap/lib/policy
@@ -2,11 +2,6 @@
 
 source /var/onap/functions
 
-policy_src_folder=$git_src_folder/policy
-policy_repos=("policy/api" "policy/common" "policy/docker" \
-"policy/drools-applications" "policy/drools-pdp" "policy/engine" \
-"policy/gui" "policy/pap" "policy/pdp")
-
 # _build_policy_images() - Function that build Policy docker images from source code
 function _build_policy_images {
     compile_src $policy_src_folder/docker
diff --git a/bootstrap/vagrant-onap/lib/portal b/bootstrap/vagrant-onap/lib/portal
index 915ccd5..fe54698 100755
--- a/bootstrap/vagrant-onap/lib/portal
+++ b/bootstrap/vagrant-onap/lib/portal
@@ -2,30 +2,27 @@
 
 source /var/onap/functions
 
-portal_src_folder=$git_src_folder/portal
-portal_repos=("portal" "portal/sdk" "ecompsdkos" "ui/dmaapbc")
-
 # clone_all_portal_repos() - Function that clones Portal source repo.
 function clone_all_portal_repos {
-    for repo in ${portal_repos[@]}; do
+    for repo in ${repos[portal]}; do
         if [[ "$repo" == "ui/dmaapbc" ]];then
             prefix="ui"
         else
             prefix="portal"
         fi
-        clone_repo $repo $portal_src_folder/${repo#*$prefix}
+        clone_repo $repo ${src_folders[portal]}/${repo#*$prefix}
     done
 }
 
 # compile_all_portal_repos() - Function that compiles Portal source repo.
 function compile_all_portal_repos {
-    for repo in ${portal_repos[@]}; do
+    for repo in ${repos[portal]}; do
         if [[ "$repo" == "ui/dmaapbc" ]];then
             prefix="ui"
         else
             prefix="portal"
         fi
-        compile_src $portal_src_folder/${repo#*$prefix}
+        compile_src ${src_folders[portal]}/${repo#*$prefix}
     done
 }
 
@@ -33,7 +30,7 @@
 function _build_portal_images {
     install_maven
 
-    pushd $portal_src_folder/deliveries
+    pushd ${src_folders[portal]}/deliveries
     chmod +x *.sh
     export MVN=$(which mvn)
     export GLOBAL_SETTINGS_FILE=/usr/share/maven3/conf/settings.xml
@@ -64,7 +61,7 @@
     docker rm -f ecompdb_portal
     docker rm -f 1610-1
 
-    pushd $portal_src_folder/deliveries
+    pushd ${src_folders[portal]}/deliveries
     mkdir -p /PROJECT/OpenSource/UbuntuEP/logs
     install_package unzip
     unzip -o etc.zip -d /PROJECT/OpenSource/UbuntuEP/
diff --git a/bootstrap/vagrant-onap/lib/robot b/bootstrap/vagrant-onap/lib/robot
index 588da6c..90fbcf8 100755
--- a/bootstrap/vagrant-onap/lib/robot
+++ b/bootstrap/vagrant-onap/lib/robot
@@ -2,10 +2,6 @@
 
 source /var/onap/functions
 
-robot_src_folder=$git_src_folder/testsuite
-robot_repos=("testsuite" "testsuite/heatbridge" "testsuite/properties" \
-"testsuite/python-testing-utils")
-
 # _setup_ete_folder() - Create and copy ete folder structure
 function _setup_ete_folder {
     mkdir -p /opt/eteshare/config
diff --git a/bootstrap/vagrant-onap/lib/sdc b/bootstrap/vagrant-onap/lib/sdc
index f99e8b2..9b0a69e 100755
--- a/bootstrap/vagrant-onap/lib/sdc
+++ b/bootstrap/vagrant-onap/lib/sdc
@@ -2,11 +2,6 @@
 
 source /var/onap/functions
 
-sdc_src_folder=$git_src_folder/sdc
-sdc_repos=("sdc" "sdc/jtosca" "sdc/sdc-distribution-client"
-"sdc/sdc-docker-base" "sdc/sdc-titan-cassandra" "sdc/sdc-tosca"
-"sdc/sdc-vnfdesign" "sdc/sdc-workflow-designer" "sdc/sdc_common")
-
 # _mount_external_partition() - Create partition and mount the external volume
 function _mount_external_partition {
     cat <<EOL > /tmp/sdc_ext_volume_partitions.txt
diff --git a/bootstrap/vagrant-onap/lib/sdnc b/bootstrap/vagrant-onap/lib/sdnc
index 05165b1..a8cf756 100755
--- a/bootstrap/vagrant-onap/lib/sdnc
+++ b/bootstrap/vagrant-onap/lib/sdnc
@@ -3,13 +3,9 @@
 source /var/onap/functions
 source /var/onap/ccsdk
 
-sdnc_src_folder=$git_src_folder/openecomp/sdnc
-sdnc_repos=("sdnc/adaptors" "sdnc/architecture" "sdnc/core" "sdnc/features" \
-"sdnc/northbound" "sdnc/oam" "sdnc/parent" "sdnc/plugins")
-
 # compile_all_sdnc_repos() - Function that compiles SDNC source repo.
 function compile_all_sdnc_repos {
-    for repo in ${sdnc_repos[@]}; do
+    for repo in ${repos[sdnc]}; do
         if [[ "$repo" == "sdnc/core" ]]; then
             compile_src $sdnc_src_folder/core/rootpom
         fi
diff --git a/bootstrap/vagrant-onap/lib/vfc b/bootstrap/vagrant-onap/lib/vfc
index 112f9a5..2b5407c 100755
--- a/bootstrap/vagrant-onap/lib/vfc
+++ b/bootstrap/vagrant-onap/lib/vfc
@@ -2,13 +2,6 @@
 
 source /var/onap/functions
 
-vfc_src_folder=$git_src_folder/vfc
-vfc_repos=("vfc/gvnfm" "vfc/gvnfm/vnflcm" "vfc/gvnfm/vnfmgr"  \
-"vfc/gvnfm/vnfres" "vfc/nfvo" "vfc/nfvo/catalog" "vfc/nfvo/driver" \
-"vfc/nfvo/driver/ems" "vfc/nfvo/driver/sfc" "vfc/nfvo/driver/vnfm" \
-"vfc/nfvo/driver/vnfm/gvnfm" "vfc/nfvo/driver/vnfm/svnfm" "vfc/nfvo/lcm" \
-"vfc/nfvo/resmanagement" "vfc/nfvo/wfengine")
-
 # compile_all_vfc_repos() - Function that compiles VF-C source repo.
 function compile_all_vfc_repos {
     install_python_package tox
diff --git a/bootstrap/vagrant-onap/lib/vid b/bootstrap/vagrant-onap/lib/vid
index f253fdb..f5ca9d2 100755
--- a/bootstrap/vagrant-onap/lib/vid
+++ b/bootstrap/vagrant-onap/lib/vid
@@ -2,9 +2,6 @@
 
 source /var/onap/functions
 
-vid_src_folder=$git_src_folder/vid
-vid_repos=("vid" "vid/asdcclient")
-
 # _build_vid_images() - Function that builds VID docker images
 function _build_vid_images {
     if [[ "$compile_repo" != "True" ]]; then
diff --git a/bootstrap/vagrant-onap/lib/vnfsdk b/bootstrap/vagrant-onap/lib/vnfsdk
index 020d437..58e3a9a 100755
--- a/bootstrap/vagrant-onap/lib/vnfsdk
+++ b/bootstrap/vagrant-onap/lib/vnfsdk
@@ -2,10 +2,6 @@
 
 source /var/onap/functions
 
-vnfsdk_src_folder=$git_src_folder/vnfsdk
-vnfsdk_repos=("vnfsdk/compliance" "vnfsdk/functest" "vnfsdk/lctest" \
-"vnfsdk/model" "vnfsdk/pkgtools" "vnfsdk/refrepo" "vnfsdk/validation")
-
 # _build_vnfsdk_images() - Builds VNFSDK images from source code
 function _build_vnfsdk_images {
     install_package unzip
diff --git a/bootstrap/vagrant-onap/lib/vvp b/bootstrap/vagrant-onap/lib/vvp
index a924e7a..f24431e 100755
--- a/bootstrap/vagrant-onap/lib/vvp
+++ b/bootstrap/vagrant-onap/lib/vvp
@@ -2,12 +2,6 @@
 
 source /var/onap/functions
 
-vvp_src_folder=$git_src_folder/vvp
-vvp_repos=("vvp/ansible-ice-bootstrap" "vvp/cms" "vvp/devkit" \
-"vvp/documentation" "vvp/engagementmgr" "vvp/gitlab" "vvp/image-scanner" \
-"vvp/jenkins" "vvp/portal" "vvp/postgresql" "vvp/test-engine" \
-"vvp/validation-scripts")
-
 # _build_vvp_images() - Builds VNFSDK images from source code
 function _build_vvp_images {
     echo "pass"