run_functional_tests.sh 2.14 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
#!/bin/bash

echo "Check vars ..."

if [ -z "$OCCI_ENDPOINT" ]; then echo "E: OCCI_ENDPOINT not set"; exit 1; fi;
echo "OCCI_ENDPOINT = ${OCCI_ENDPOINT}"

if [ -z "$USER_PROXY" ]; then echo "E: USER_PROXY not set"; exit 1; fi;
echo "USER_PROXY = ${USER_PROXY}"

if [ -z "$OS_TPL" ]; then echo "E: OS_TPL not set"; exit 1; fi;
echo "OS_TPL = ${OS_TPL}"

if [ -z "$RESOURCE_TPL" ]; then echo "E: RESOURCE_TPL not set"; exit 1; fi;
echo "RESOURCE_TPL = ${RESOURCE_TPL}";

echo "Vars OK, run tests"
echo


BASE_CMD="occi --endpoint ${OCCI_ENDPOINT} -n x509 -X --user-cred ${USER_PROXY}"


echo "List OS templates"
echo "Meaning: kamaki image list"
CMD="${BASE_CMD} --action list --resource os_tpl"
echo "$CMD"
eval $CMD
echo

echo "List resource templates"
echo "Meaning: kamaki flavor list"
CMD="${BASE_CMD} --action list --resource resource_tpl"
echo "$CMD"
eval $CMD
echo

echo "Details on OS template"
echo "Meaning: kamaki image info <ID of ${OS_TPL} image>"
CMD="${BASE_CMD} --action describe --resource os_tpl#${OS_TPL}"
echo "$CMD"
eval $CMD
echo

echo "Details on resource template"
echo "Meaning: kamaki flavor info <FLAVOR ID of ${RESOURCE_TPL}>"
CMD="${BASE_CMD} --action describe --resource resource_tpl#${RESOURCE_TPL}"
echo "$CMD"
eval $CMD
echo

echo "Create a server instance"
echo "Meaning: kamaki server create --name \"My Test VM\" \\"
echo "    --flavor-id <ID of c2r2048d40drb> --image-id <ID of ${OS_TPL}>"
CMD="${BASE_CMD} --action create --resource compute "
CMD="${CMD} --attribute occi.core.title=\"My Test VM\""
CMD="${CMD} --mixin os_tpl#${OS_TPL} --mixin resource_tpl#${RESOURCE_TPL}"
echo "$CMD"
VM_URL=$(eval $CMD)
echo "VM URL: ${VM_URL}"
echo

echo "List server instances"
echo "Meaning: kamaki server list"
CMD="${BASE_CMD} --action list --resource compute"
echo "$CMD"
eval $CMD
echo

if [ -z "$VM_URL" ]; then
    echo "Frankly, I don't know what servers to delete";
else
    SUFFIX=(`echo ${VM_URL}|awk '{n=split($0,a,"/"); print "/"a[n-1]"/"a[n]}'`)
    echo "Destroy server instance ${SUFFIX}";
    echo "Meaning: kamaki server delete ${SERVER_URL}";
    CMD="${BASE_CMD} --action delete --resource ${SUFFIX}";
    echo "$CMD";
    eval $CMD;
fi;
echo