Files
training-labs/oslabs/osbash/tools/test-once.sh
Pranav Salunke 9aae759289 Refactors the architecture of osbash
Changes to the repository layout to incorporate the following:

  1. Migrate to dedicated repository
  2. Rebranding osbash to openstack-labs
  3. Adding Python specific bits
  4. Allowing a wrapper and switch to osbash meanwhile the
     python scripts (stacktrain) is underprogress

The current repository structure will allow us to carry out the above
mentioned changes while the stable code base is usable and will also
allow us to update the version of OpenStack being deployed on osbash.

This is the rough sketch of the repository ignoring the boilerplate:

    .
    |-- doc
    |-- openstack-labs
    |   |-- img
    |   |-- osbash
    |   |   |-- config
    |   |   |-- lib
    |   |   |-- tools
    |   |   |-- scripts
    |   |   |-- osbash.sh
    |   |   `-- wbatch
    |   |-- stacktrain
    |   |   `-- lib
    |   `-- stacktrain.py
    `-- oslabs.py

Note: Also adds/edits existing boilerplate (README's, Tools etc.)

Co-Authored-By: Roger Luethi <rl@patchworkscience.org>
Co-Authored-By: Sayali Lunkad <sayali.92720@gmail.com>
2015-09-29 11:23:32 +02:00

57 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
set -o errexit -o nounset
TOP_DIR=$(cd "$(dirname "$0")/.." && pwd)
source "$TOP_DIR/config/paths"
source "$CONFIG_DIR/deploy.osbash"
source "$OSBASH_LIB_DIR/functions-host.sh"
# Get remote ssh port of target node (VM_SSH_PORT)
source "$CONFIG_DIR/config.controller"
if [ $# -eq 0 ]; then
echo "Purpose: Copy one script to target node and execute it via ssh."
echo "Usage: $0 <script>"
exit 1
fi
SCRIPT_SRC=$1
if [ ! -f "$SCRIPT_SRC" ]; then
echo "File not found: $SCRIPT_SRC"
exit 1
fi
SCRIPT=$(basename "$SCRIPT_SRC")
wait_for_ssh "$VM_SSH_PORT"
function get_remote_top_dir {
if vm_ssh "$VM_SSH_PORT" "test -d /osbash"; then
# The installation uses a VirtualBox shared folder.
echo >&2 -n "Waiting for shared folder."
until vm_ssh "$VM_SSH_PORT" "test -f $REMOTE_TOP_DIR/lib"; do
sleep 1
echo >&2 -n .
done
echo >&2
echo /osbash
else
# Copy and execute the script with scp/ssh.
echo /home/osbash
fi
}
REMOTE_TOP_DIR=$(get_remote_top_dir)
EXE_DIR_NAME=test_tmp
mkdir -p "$TOP_DIR/$EXE_DIR_NAME"
cp -f "$SCRIPT_SRC" "$TOP_DIR/$EXE_DIR_NAME"
if [[ "$REMOTE_TOP_DIR" = "/home/osbash" ]]; then
# Not using a shared folder, we need to scp the script to the target node
vm_scp_to_vm "$VM_SSH_PORT" "$TOP_DIR/$EXE_DIR_NAME/$SCRIPT"
fi
vm_ssh "$VM_SSH_PORT" "bash -c $REMOTE_TOP_DIR/$EXE_DIR_NAME/$SCRIPT" || \
rc=$?
echo "$SCRIPT returned status: ${rc:-0}"