34 lines
1.5 KiB
Django/Jinja
34 lines
1.5 KiB
Django/Jinja
#!/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
if [[ ! -s {{ working_dir }}/vm_ip.sh ]]; then
|
|
{% if workload_sriov | bool %}
|
|
echo export VM_IP=$(openstack server list -f json | jq -r -c '.[0]["Networks"]' | cut -d"=" -f2) > {{ working_dir }}/vm_ip.sh
|
|
{% else %}
|
|
#openstack server list --status ACTIVE -c Networks -f value produces different results in different OSP versions
|
|
#OSP10,13,16
|
|
#openstack server list --status ACTIVE -c Networks -f value
|
|
#internal_net_6f58c1ef02=192.168.0.13, 10.0.0.159
|
|
#internal_net_7c845f5f18=192.168.0.13, 10.0.0.173
|
|
#OSP17+
|
|
#{'internal_net_93bd647902': ['192.168.0.22', '10.0.0.159']}
|
|
#{'internal_net_7c845a1e74': ['192.168.0.13', '10.0.0.173']}
|
|
#IPv6 IPs are also possible
|
|
#
|
|
#Next line extracts last ip from all active networks and finds correspondant floating IP
|
|
echo export VM_IP=$(openstack floating ip list -c 'Floating IP Address' -f value | \
|
|
grep "$(openstack server list --status ACTIVE -c Networks -f value | \
|
|
grep -Eo '(([0-9a-fA-F]{1,4}:+){3,7}[0-9a-fA-F]{1,4})|(([0-9]{1,3}[\.]){3}[0-9]{1,3})' | tail -1)") > {{ working_dir }}/vm_ip.sh
|
|
{% endif %}
|
|
fi
|
|
|
|
source {{ working_dir }}/vm_ip.sh
|
|
|
|
while true; do
|
|
curl --location --silent --show-error --max-time 5 \
|
|
--write-out "HTTP Code: %{http_code}\nTotal Time: %{time_total} sec\nEffective URL: %{url_effective}\n\n" \
|
|
http://${VM_IP}/ 2>/dev/null >> {{ working_dir }}/http_response.log
|
|
sleep 1
|
|
done
|