#!/bin/bash

set -x
set -e

source {{ overcloudrc }}

# This script validates the resources create by the resources/create role.
# It pings to the floating ip of the server and ssh into the server.

server_ip=`cat {{ ovn_migration_temp_dir }}/server_public_ip`

# WORKAROUND: There is a problem in core OVN where in DVR case of missing MAC_Bindings
#             packets are sent from controller to compute via tunnel. Let the
#             MAC_Bindings be created first before testing accessibility of a FIP.
#             https://bugzilla.redhat.com/show_bug.cgi?id=1788193

set +e
ping -c 30 $server_ip
set -e

echo "Running ping test with -c 3 to the server ip - $server_ip"
ping -c 3 $server_ip

ssh -i {{ ovn_migration_temp_dir }}/ovn_migration_ssh_key -o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null  cirros@$server_ip date

echo "Done with the validation"
