aboutsummaryrefslogtreecommitdiffstats
path: root/bootstrap/vagrant-onap/lib/_onap_functions
diff options
context:
space:
mode:
Diffstat (limited to 'bootstrap/vagrant-onap/lib/_onap_functions')
-rwxr-xr-xbootstrap/vagrant-onap/lib/_onap_functions87
1 files changed, 87 insertions, 0 deletions
diff --git a/bootstrap/vagrant-onap/lib/_onap_functions b/bootstrap/vagrant-onap/lib/_onap_functions
new file mode 100755
index 000000000..0d421552f
--- /dev/null
+++ b/bootstrap/vagrant-onap/lib/_onap_functions
@@ -0,0 +1,87 @@
+#!/bin/bash
+
+# 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
+}
+
+# TODO(electrocucaracha): Determine how to use this behind a proxy
+# docker_openecomp_login() - Login to OpenECOMP Docker Hub
+function docker_openecomp_login {
+ install_docker
+ docker login -u $nexus_username -p $nexus_password $nexus_docker_repo
+}
+
+# pull_openecomp_image() - Pull Docker container image from a Docker Registry Hub
+function pull_openecomp_image {
+ local image=$1
+ local tag=$2
+ docker_openecomp_login
+ pull_docker_image $nexus_docker_repo/openecomp/${image}:$docker_version $tag
+ docker logout
+}
+
+# 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
+}
+
+# _configure_maven() - This function creates a maven configuration file in case that doesn't exist
+function _configure_maven {
+ local proxies_start=" <!--"
+ local proxies=" \|"
+ local proxies_end=" \|-->"
+ local mvn_http=""
+ local mvn_https=""
+
+ if [ $http_proxy ] | [ $https_proxy ]; then
+ proxies_start=" "
+ proxies=" "
+ proxies_end=" "
+ if [ $http_proxy ]; then
+ proxy_domain=`echo $http_proxy | awk -F/ '{print $3}' | awk -F: '{print $1}'`
+ proxy_port=`echo $http_proxy | awk -F/ '{print $3}' | awk -F: '{print $2}'`
+ mvn_http="<proxy>\n <id>http</id>\n <active>true</active>\n <protocol>http</protocol>\n <host>$proxy_domain</host>\n <port>$proxy_port</port>\n <nonProxyHosts>${no_proxy}</nonProxyHosts>\n </proxy>"
+ fi
+ if [ $https_proxy ]; then
+ proxy_domain=`echo $https_proxy | awk -F/ '{print $3}' | awk -F: '{print $1}'`
+ proxy_port=`echo $https_proxy | awk -F/ '{print $3}' | awk -F: '{print $2}'`
+ mvn_https="<proxy>\n <id>https</id>\n <active>true</active>\n <protocol>https</protocol>\n <host>$proxy_domain</host>\n <port>$proxy_port</port>\n <nonProxyHosts>${no_proxy}</nonProxyHosts>\n </proxy>"
+ fi
+ fi
+
+ if [ ! -f $mvn_conf_file ]; then
+ cp /var/onap/files/settings.template $mvn_conf_file
+ sed -e "
+ s|%PROXIES_START%|$proxies_start|g;
+ s|%PROXIES%|$proxies|g;
+ s|%HTTP_PROXY%|$mvn_http|g;
+ s|%HTTPS_PROXY%|$mvn_https|g;
+ s|%PROXIES_END%|$proxies_end|g
+ " -i $mvn_conf_file
+ 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
+}