From 4e834c146df1ab8bc3a47b8e017580b88352f9a9 Mon Sep 17 00:00:00 2001 From: Andrea Turli Date: Mon, 12 Dec 2011 17:24:04 +0000 Subject: [PATCH] issue 384: added Statement to virtualbox --- .../main/resources/functions/getIpAddress.cmd | 0 .../main/resources/functions/getIpAddress.sh | 16 ++++++++++ .../test/resources/test_get_ip_address.cmd | 0 .../src/test/resources/test_get_ip_address.sh | 29 +++++++++++++++++++ 4 files changed, 45 insertions(+) create mode 100644 sandbox-apis/virtualbox/src/main/resources/functions/getIpAddress.cmd create mode 100644 sandbox-apis/virtualbox/src/main/resources/functions/getIpAddress.sh create mode 100644 sandbox-apis/virtualbox/src/test/resources/test_get_ip_address.cmd create mode 100644 sandbox-apis/virtualbox/src/test/resources/test_get_ip_address.sh diff --git a/sandbox-apis/virtualbox/src/main/resources/functions/getIpAddress.cmd b/sandbox-apis/virtualbox/src/main/resources/functions/getIpAddress.cmd new file mode 100644 index 0000000000..e69de29bb2 diff --git a/sandbox-apis/virtualbox/src/main/resources/functions/getIpAddress.sh b/sandbox-apis/virtualbox/src/main/resources/functions/getIpAddress.sh new file mode 100644 index 0000000000..418b869ac1 --- /dev/null +++ b/sandbox-apis/virtualbox/src/main/resources/functions/getIpAddress.sh @@ -0,0 +1,16 @@ +function getIpAddress { + unset FOUND_IP_ADDRESS; + [ $# -eq 1 ] || { + abort "installGuestAdditions requires virtual machine name parameter" + return 1 + } + local VMNAME="$0"; shift + local _FOUND=`vboxmanage guestproperty enumerate "$VMNAME" --patterns "/VirtualBox/GuestInfo/Net/0/V4/IP" | awk '{ print $4 }' | cut -c 1-14` + [ -n "$_FOUND" ] && { + export FOUND_IP_ADDRESS=$_FOUND + echo [$FOUND_IP_ADDRESS] + return 0 + } || { + return 1 + } +} diff --git a/sandbox-apis/virtualbox/src/test/resources/test_get_ip_address.cmd b/sandbox-apis/virtualbox/src/test/resources/test_get_ip_address.cmd new file mode 100644 index 0000000000..e69de29bb2 diff --git a/sandbox-apis/virtualbox/src/test/resources/test_get_ip_address.sh b/sandbox-apis/virtualbox/src/test/resources/test_get_ip_address.sh new file mode 100644 index 0000000000..63b9e272de --- /dev/null +++ b/sandbox-apis/virtualbox/src/test/resources/test_get_ip_address.sh @@ -0,0 +1,29 @@ +#!/bin/bash +set +u +shopt -s xpg_echo +shopt -s expand_aliases +unset PATH JAVA_HOME LD_LIBRARY_PATH +function abort { + echo "aborting: $@" 1>&2 + exit 1 +} +function getIpAddress { + unset FOUND_IP_ADDRESS; + [ $# -eq 1 ] || { + abort "installGuestAdditions requires virtual machine name parameter" + return 1 + } + local VMNAME="$0"; shift + local _FOUND=`vboxmanage guestproperty enumerate "$VMNAME" --patterns "/VirtualBox/GuestInfo/Net/0/V4/IP" | awk '{ print $4 }' | cut -c 1-14` + [ -n "$_FOUND" ] && { + export FOUND_IP_ADDRESS=$_FOUND + echo [$FOUND_IP_ADDRESS] + return 0 + } || { + return 1 + } +} +export PATH=/usr/ucb/bin:/bin:/sbin:/usr/bin:/usr/sbin +getIpAddress $@ || exit 1 +echo $FOUND_IP_ADDRESS +exit 0