Merge "[opendaylight] Update SQLAlchemy library"
[fuel.git] / ci / deploy.sh
index ede930b..a61946e 100755 (executable)
@@ -32,7 +32,7 @@ usage ()
 {
 cat << EOF
 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-$(notify "$(basename "$0"): Deploy the Fuel@OPNFV MCP stack" 3)
+$(notify "$(basename "$0"): Deploy the OPNFV Fuel MCP stack" 3)
 
 $(notify "USAGE:" 2)
   $(basename "$0") -l lab-name -p pod-name -s deploy-scenario \\
@@ -59,9 +59,9 @@ $(notify "OPTIONS:" 2)
   -N  Experimental: Do not virtualize control plane (novcp)
 
 $(notify_i "Description:" 2)
-Deploys the Fuel@OPNFV stack on the indicated lab resource.
+Deploys the OPNFV Fuel stack on the indicated lab resource.
 
-This script provides the Fuel@OPNFV deployment abstraction.
+This script provides the OPNFV Fuel deployment abstraction.
 It depends on the OPNFV official configuration directory/file structure
 and provides a fairly simple mechanism to execute a deployment.
 
@@ -74,8 +74,6 @@ $(notify_i "Input parameters to the build script are:" 2)
    <base-uri>/labs/<lab-name>/idf-<pod-name>.yaml
    The default is using the git submodule tracking 'OPNFV Pharos' in
    <./mcp/scripts/pharos>.
-   An example config is provided inside current repo in
-   <./mcp/config>, automatically linked as <./mcp/scripts/pharos/labs/local>.
 -d Dry-run - Produce deploy config files, but do not execute deploy
 -D Debug logging - Enable extra logging in sh deploy scripts (set -x)
 -e Do not launch environment deployment
@@ -92,10 +90,7 @@ $(notify_i "Input parameters to the build script are:" 2)
 -h Print this message and exit
 -L Deployment log path and name, eg. -L /home/jenkins/job.log.tar.gz
 -l Lab name as defined in the configuration directory, e.g. lf
-   For the sample configuration in <./mcp/config>, lab name is 'local'.
 -p POD name as defined in the configuration directory, e.g. pod2
-   For the sample configuration in <./mcp/config>, POD name is 'virtual1'
-   for virtual deployments or 'pod1' for baremetal (based on lf-pod2).
 -m Use single socket compute nodes. Instead of using default NUMA-enabled
    topology for virtual compute nodes created via libvirt, configure a
    single guest CPU socket.
@@ -107,7 +102,9 @@ $(notify_i "Input parameters to the build script are:" 2)
    Note that without the required packages, deploy will fail.
 -s Deployment-scenario, this points to a short deployment scenario name, which
    has to be defined in config directory (e.g. os-odl-nofeature-ha).
--S Storage dir for VM images, default is mcp/deploy/images
+-S Storage dir for VM images, default is /var/lib/opnfv/tmpdir
+   It is recommended to store the deploy artifacts on a fast disk, outside of
+   the current git repository (so clean operations won't erase it).
 
 $(notify_i "[NOTE] sudo & virsh priviledges are needed for this script to run" 3)
 
@@ -116,7 +113,8 @@ Example:
 $(notify_i "sudo $(basename "$0") \\
   -b file:///home/jenkins/securedlab \\
   -l lf -p pod2 \\
-  -s os-odl-nofeature-ha" 2)
+  -s os-odl-nofeature-ha \\
+  -S /home/jenkins/tmpdir" 2)
 EOF
 }
 
@@ -130,7 +128,7 @@ EOF
 CI_DEBUG=${CI_DEBUG:-0}; [[ "${CI_DEBUG}" =~ (false|0) ]] || set -x
 MCP_REPO_ROOT_PATH=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")/..")
 DEPLOY_DIR=$(cd "${MCP_REPO_ROOT_PATH}/mcp/scripts"; pwd)
-MCP_STORAGE_DIR=$(cd "${MCP_REPO_ROOT_PATH}/mcp/deploy/images"; pwd)
+MCP_STORAGE_DIR='/var/lib/opnfv/tmpdir'
 URI_REGEXP='(file|https?|ftp)://.*'
 BASE_CONFIG_URI="file://${MCP_REPO_ROOT_PATH}/mcp/scripts/pharos"
 
@@ -147,6 +145,8 @@ MCP_CMP_SS=${MCP_CMP_SS:-0}
 source "${DEPLOY_DIR}/globals.sh"
 source "${DEPLOY_DIR}/lib.sh"
 source "${DEPLOY_DIR}/lib_template.sh"
+source "${DEPLOY_DIR}/lib_jump_common.sh"
+source "${DEPLOY_DIR}/lib_jump_deploy.sh"
 
 #
 # END of variables to customize
@@ -242,6 +242,8 @@ pushd "${DEPLOY_DIR}" > /dev/null
 # scenario, etc.
 
 # Install required packages on jump server
+sudo mkdir -p "${MCP_STORAGE_DIR}"
+sudo chown -R "${USER}:${USER}" "${MCP_STORAGE_DIR}"
 if [ ${USE_EXISTING_PKGS} -eq 1 ]; then
     notify "[NOTE] Skipping distro pkg installation" 2
 else
@@ -251,7 +253,7 @@ else
     virtinst_install "${MCP_STORAGE_DIR}"
 fi
 
-if ! virsh list >/dev/null 2>&1; then
+if ! ${VIRSH} list >/dev/null 2>&1; then
     notify_e "[ERROR] This script requires hypervisor access"
 fi
 
@@ -272,16 +274,16 @@ fi
 generate_ssh_key
 export MAAS_SSH_KEY="$(cat "$(basename "${SSH_KEY}").pub")"
 
-MCP_DPDK_MODE=$([[ "$DEPLOY_SCENARIO" =~ ovs ]] && echo 1 || echo 0)
 # Expand jinja2 templates based on PDF data and env vars
-export MCP_REPO_ROOT_PATH MCP_VCP MCP_DPDK_MODE MCP_STORAGE_DIR MCP_DOCKER_TAG \
-       MCP_CMP_SS MCP_JUMP_ARCH=$(uname -i)
+[[ "${DEPLOY_SCENARIO}" =~ -ha$ ]] || MCP_VCP=0
+export MCP_REPO_ROOT_PATH MCP_VCP MCP_STORAGE_DIR MCP_DOCKER_TAG MCP_CMP_SS \
+       MCP_JUMP_ARCH=$(uname -i) MCP_DEPLOY_SCENARIO="${DEPLOY_SCENARIO}"
 do_templates_scenario "${MCP_STORAGE_DIR}" "${TARGET_LAB}" "${TARGET_POD}" \
-                      "${BASE_CONFIG_URI}" "${SCENARIO_DIR}"
+                      "${BASE_CONFIG_URI}" "${SCENARIO_DIR}" \
+                      "${SCENARIO_DIR}/${DEPLOY_SCENARIO}.yaml"
 do_templates_cluster  "${MCP_STORAGE_DIR}" "${TARGET_LAB}" "${TARGET_POD}" \
                       "${MCP_REPO_ROOT_PATH}" \
-                      "${SCENARIO_DIR}/defaults.yaml" \
-                      "${SCENARIO_DIR}/${DEPLOY_SCENARIO}.yaml"
+                      "${SCENARIO_DIR}/defaults.yaml"
 
 # Determine additional data (e.g. jump bridge names) based on XDF
 source "${DEPLOY_DIR}/xdf_data.sh"
@@ -300,13 +302,17 @@ elif [ ${USE_EXISTING_INFRA} -gt 0 ]; then
 else
     prepare_vms "${base_image}" "${MCP_STORAGE_DIR}" "${virtual_repos_pkgs}" \
       "${virtual_nodes[@]}"
-    prepare_containers "${MCP_STORAGE_DIR}"
     create_networks "${OPNFV_BRIDGES[@]}"
     do_sysctl_cfg
     do_udev_cfg
     create_vms "${MCP_STORAGE_DIR}" "${virtual_nodes_data}" "${OPNFV_BRIDGES[@]}"
     update_mcpcontrol_network
     start_vms "${virtual_nodes[@]}"
+
+    # https://github.com/docker/libnetwork/issues/1743
+    # rm -f /var/lib/docker/network/files/local-kv.db
+    sudo systemctl restart docker
+    prepare_containers "${MCP_STORAGE_DIR}"
 fi
 
 start_containers "${MCP_STORAGE_DIR}"
@@ -329,9 +335,9 @@ else
             reset_vms "${virtual_nodes[@]}"
         fi
     done
-fi
 
-./log.sh "${DEPLOY_LOG}"
+    ./log.sh "${DEPLOY_LOG}"
+fi
 
 popd > /dev/null