summaryrefslogtreecommitdiffstats
path: root/tests/functions-common
diff options
context:
space:
mode:
authorRyota MIBU <r-mibu@cq.jp.nec.com>2017-02-02 15:03:01 +0000
committerRyota MIBU <r-mibu@cq.jp.nec.com>2017-02-02 16:22:03 +0000
commit1d5c5fae6b040a19404a1cfd9afd28237d93f6a7 (patch)
tree48375398109dc1d5b62cb954958048f4e31a6c67 /tests/functions-common
parent06406611160b83a2ec90400db3b9e6b08d60ff95 (diff)
refactor lib/installer
- make sure expected parameters and functions are set - remove all installer dependent codes from run.sh except non-used function which will be removed later on Change-Id: I4628173ef0891d893146976c7553ed6a95329957 Signed-off-by: Ryota MIBU <r-mibu@cq.jp.nec.com>
Diffstat (limited to 'tests/functions-common')
-rw-r--r--tests/functions-common28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/functions-common b/tests/functions-common
index 7928f20c..53a620b0 100644
--- a/tests/functions-common
+++ b/tests/functions-common
@@ -73,6 +73,20 @@ function die_if_not_set {
$xtrace
}
+# Check the function is defined
+# die_if_not_defined $LINENO function-name "message"
+function die_if_not_defined {
+ local xtrace
+ xtrace=$(set +o | grep xtrace)
+ set +o xtrace
+ local line=$1; shift
+ local func_name=$1; shift
+ if ! declare -f "$func_name" > /dev/null; then
+ die $line "$*"
+ fi
+ $xtrace
+}
+
# Wait until the condition is met.
# wait_until condition timeout interval
function wait_until {
@@ -90,3 +104,17 @@ function wait_until {
fi
done
}
+
+# Print IP address of the first vNIC owned by specified VM via virsh
+# get_first_vnic_ip vm_name
+function get_first_vnic_ip {
+ local vm_name=$1
+
+ _vnic_mac=$(sudo virsh domiflist $vm_name | \
+ sed -n -e 's/^.*\([0-9a-f]\{2\}\(:[0-9a-f]\{2\}\)\{5\}\).*$/\1/p' | \
+ head -1)
+ die_if_not_set $LINENO _vnic_mac
+ _vnic_ip=$(arp -e | grep $_vnic_mac | awk '{print $1}')
+ die_if_not_set $LINENO _vnic_ip
+ echo $_vnic_ip
+}