CSIT-1416 Remove installation of vpp from containers
[csit.git] / resources / libraries / bash / function / device.sh
index e4ed319..7d175a9 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2018 Cisco and/or its affiliates.
+# Copyright (c) 2019 Cisco and/or its affiliates.
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at:
@@ -108,8 +108,8 @@ function bind_interfaces_to_driver () {
 
 
 function clean_environment () {
-    # Cleanup environment by removing topology containers and binding
-    # interfaces back to original driver.
+    # Cleanup environment by removing topology containers and shared volumes
+    # and binding interfaces back to original driver.
     #
     # Variables read:
     # - DCR_UUIDS - Docker Container UUIDs.
@@ -124,6 +124,12 @@ function clean_environment () {
     # Kill docker containers.
     docker rm --force "${DCR_UUIDS[@]}" || die "Cleanup containers failed!"
 
+    # Check if there are some leftover containers and remove all. Command will
+    # not fail in case there are no containers to remove.
+    docker rm --force $(docker ps -q --filter name=${DCR_UUIDS[dut1]}) || {
+        warn "Failed to remove hanged containers or nothing to remove!"
+    }
+
     # Rebind interfaces back to kernel drivers.
     for ADDR in ${TG_PCIDEVS[@]}; do
         DRIVER="${TG_DRIVERS[0]}"
@@ -517,6 +523,10 @@ function start_topology_containers () {
     # Mount vfio to be able to bind to see binded interfaces. We cannot use
     # --device=/dev/vfio as this does not see newly binded interfaces.
     dcr_stc_params+="--volume /dev/vfio:/dev/vfio "
+    # Mount nested_vm image to be able to run VM tests.
+    dcr_stc_params+="--volume /var/lib/vm/vhost-nested.img:/var/lib/vm/vhost-nested.img "
+    # Mount docker.sock to be able to use docker deamon of the host.
+    dcr_stc_params+="--volume /var/run/docker.sock:/var/run/docker.sock "
 
     # Docker Container UUIDs.
     declare -gA DCR_UUIDS