Updated PDF and IDF for Ericsson Hardware
[kuberef.git] / functions.sh
index 03e2284..fce71f6 100755 (executable)
@@ -26,6 +26,9 @@ assert_non_empty() {
         error "$2"
     fi
 }
+if [ "${DEBUG:-false}" == "true" ]; then
+    set -o xtrace
+fi
 
 check_prerequisites() {
     info "Check prerequisites"
@@ -33,7 +36,6 @@ check_prerequisites() {
     #-------------------------------------------------------------------------------
     # Check for DEPLOYMENT type
     #-------------------------------------------------------------------------------
-    DEPLOYMENT=${DEPLOYMENT:-full}
     if ! [[ "$DEPLOYMENT" =~ ^(full|k8s)$ ]]; then
         error "Unsupported value for DEPLOYMENT ($DEPLOYMENT)"
     fi
@@ -65,7 +67,21 @@ check_prerequisites() {
     sudo sed -i "s/^Defaults.*env_reset/#&/" /etc/sudoers
 
     #-------------------------------------------------------------------------------
-    # Check if some tools are installed
+    # Check if Python Virtual Environment is installed
+    #-------------------------------------------------------------------------------
+    if ! command -v virtualenv &> /dev/null; then
+        error "VirtualEnv not found. Please install."
+    fi
+
+    #-------------------------------------------------------------------------------
+    # Check if PIP Installs Packages is installed
+    #-------------------------------------------------------------------------------
+    if ! command -v pip &> /dev/null; then
+        error "PIP not found. Please install."
+    fi
+
+    #-------------------------------------------------------------------------------
+    # Check is libvirt is installed
     #-------------------------------------------------------------------------------
     for tool in ansible yq virsh jq; do
         if ! command -v "$tool" &> /dev/null; then
@@ -227,6 +243,8 @@ cp ${PROJECT_ROOT}/${INSTALLER}/{all.yml,kube-node.yml} \
     ${PROJECT_ROOT}/container-experience-kits/group_vars/
 cp ${PROJECT_ROOT}/${INSTALLER}/patched_cmk_build.yml \
     ${PROJECT_ROOT}/container-experience-kits/roles/cmk_install/tasks/main.yml
+cp ${PROJECT_ROOT}/${INSTALLER}/patched_vfio.yml \
+    ${PROJECT_ROOT}/container-experience-kits/roles/sriov_nic_init/tasks/bind_vf_driver.yml
 sudo docker run --rm \
 -e ANSIBLE_CONFIG=/bmra/ansible.cfg \
 -e PROFILE=${BMRA_PROFILE} \
@@ -253,11 +271,19 @@ EOF
     fi
 }
 
+# Creates a python virtual environment
+creates_virtualenv() {
+    if [  ! -d "$CURRENTPATH/.venv" ]; then
+        virtualenv .venv
+    fi
+    # shellcheck disable=SC1090
+    source "$CURRENTPATH/.venv/bin/activate"
+    pip install -r "$CURRENTPATH/requirements.txt"
+}
+
 # Executes a specific Ansible playbook
 run_playbook() {
-    ansible_cmd="$(command -v ansible-playbook)"
-    ansible_cmd+=" -i $CURRENTPATH/inventory/localhost.ini"
-    ansible_cmd+=" -e ansible_python_interpreter=$(command -v python)"
+    ansible_cmd="$(command -v ansible-playbook) -i $CURRENTPATH/inventory/localhost.ini -e ansible_python_interpreter=$(command -v python)"
     if [ "${DEBUG:-false}" == "true" ]; then
         ansible_cmd+=" -vvv"
     fi