Add OOM provisioning script
[integration.git] / bootstrap / vagrant-onap / lib / functions
index 08c6d91..9531fc7 100755 (executable)
@@ -139,6 +139,7 @@ function _configure_docker_settings {
     local docker_conf_backup=/tmp/docker.backup
     local docker_conf=/etc/default/docker
     local chameleonsocks_filename=chameleonsocks.sh
+    local max_concurrent_downloads=${1:-3}
 
     cp $docker_conf $docker_conf_backup
     if [ $http_proxy ]; then
@@ -160,7 +161,20 @@ function _configure_docker_settings {
     fi
     rm $docker_conf_backup
 
-    echo "DOCKER_OPTS=\"-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock\"" >> $docker_conf
+    echo "DOCKER_OPTS=\"-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --max-concurrent-downloads $max_concurrent_downloads \"" >> $docker_conf
+    usermod -aG docker $USER
+
+    source /etc/os-release || source /usr/lib/os-release
+    case ${ID,,} in
+        *suse)
+        ;;
+        ubuntu|debian)
+            service docker restart
+            sleep 10
+        ;;
+        rhel|centos|fedora)
+        ;;
+    esac
 }
 
 # install_nodejs() - Download and install NodeJS
@@ -208,7 +222,7 @@ function install_python_requirements {
 
 # install_docker() - Download and install docker-engine
 function install_docker {
-    if is_package_installed docker-ce; then
+    if $(docker version &>/dev/null); then
         return
     fi
     source /etc/os-release || source /usr/lib/os-release
@@ -229,8 +243,6 @@ function install_docker {
 
     install_package docker-ce
     _configure_docker_settings
-    service docker restart
-    sleep 10
 }
 
 # pull_docker_image() - Pull Docker container image from the Public Docker Registry Hub
@@ -265,8 +277,8 @@ function _install_ODL {
     if [ ! -d /opt/opendaylight/current ]; then
         mkdir -p /opt/opendaylight/
         wget "https://nexus.opendaylight.org/content/repositories/public/org/opendaylight/integration/distribution-karaf/"$odl_version"/distribution-karaf-"$odl_version".tar.gz" -P /opt/
-        tar xvf "/opt/distribution-karaf-"$odl_version".tar.gz" -C /opt/
-        mv "/opt/distribution-karaf-"$odl_version /opt/opendaylight/current
+        tar xvf "/opt/distribution-karaf-"$odl_version".tar.gz" -C /tmp/
+        mv "/tmp/distribution-karaf-"$odl_version /opt/opendaylight/current
         rm -rf "/opt/distribution-karaf-"$odl_version".tar.gz"
     fi
 }
@@ -356,3 +368,17 @@ function build_docker_image {
     eval $docker_build
     popd
 }
+
+# mount_external_partition() - Create partition and mount the external volume
+function mount_external_partition {
+    local dev_name="/dev/$1"
+    local mount_dir=$2
+
+    sfdisk $dev_name << EOF
+;
+EOF
+    mkfs -t ext4 ${dev_name}1
+    mkdir -p $mount_dir
+    mount ${dev_name}1 $mount_dir
+    echo "${dev_name}1  $mount_dir           ext4    errors=remount-ro,noatime,barrier=0 0       1" >> /etc/fstab
+}