CI: Fix IP address detection in baremetal compute test

The 'openstack server show <server> -f value -c addresses' command
previously had output like this:

    <network name>=<IP>

Now it shows a Python output like this:

    {'<network name>': ['IP']}

This broke the parsing of the command output when determining which IP
address to use to access a bare metal instance via SSH.

This change fixes the issue by querying the server's port in Neutron,
and using the fixed IP address.

Change-Id: I55b5f185fb7136d3c6fa565aa46598f21c94eb43
This commit is contained in:
Mark Goddard 2021-03-22 19:50:01 +00:00
parent ad0800c2cb
commit 775620733b

View File

@ -505,7 +505,12 @@ function overcloud_test {
# Test SSH connectivity. For servers attached directly to the external
# network, use the fixed IP. Otherwise add a floating IP.
if [[ $network = provision-net ]]; then
ip=$(openstack server show "$name" -f value -c addresses | sed -e "s/${network}=//")
port_id=$(openstack port list --server $name --network $network -f value -c ID)
echo "port $port_id"
fixed_ips=$(openstack port show $port_id -f json -c fixed_ips)
echo "fixed_ips $fixed_ips"
ip=$(echo $fixed_ips | python3 -c "import json,sys; print(json.load(sys.stdin)['fixed_ips'][0]['ip_address'])")
echo "ip $ip"
else
echo "$name: Attaching floating IP"
if is_ironic_enabled; then