Use Neutron (if available) to create floating IPs for validation

The 2.36 microversion in the compute API deprecates the os-floating-ips
API since it's a proxy when using Neutron, and nova-network is deprecated.

When ssh validation is enabled in a Tempest run, we should create the
floating IP using Neutron if available and only fallback to the compute
API if using nova-network.

Change-Id: Ib345abdeec17fef85f99beb0ff4f3639e95acf6f
This commit is contained in:
Matt Riedemann 2017-06-05 15:50:14 -04:00
parent 827493abe3
commit dfbefae99d
1 changed files with 17 additions and 4 deletions

View File

@ -80,10 +80,23 @@ def create_validation_resources(os, validation_resources=None):
validation_data['security_group'] = \
create_ssh_security_group(os, add_rule)
if validation_resources['floating_ip']:
floating_client = os.compute_floating_ips_client
validation_data.update(
floating_client.create_floating_ip(
pool=CONF.network.floating_network_name))
if CONF.service_available.neutron:
floatingip = os.floating_ips_client.create_floatingip(
floating_network_id=CONF.network.public_network_id)
# validation_resources['floating_ip'] has historically looked
# like a compute API POST /os-floating-ips response, so we need
# to mangle it a bit for a Neutron response with different
# fields.
validation_data['floating_ip'] = floatingip['floatingip']
validation_data['floating_ip']['ip'] = (
floatingip['floatingip']['floating_ip_address'])
else:
# NOTE(mriedem): The os-floating-ips compute API was deprecated
# in the 2.36 microversion. Any tests for CRUD operations on
# floating IPs using the compute API should be capped at 2.35.
validation_data.update(
os.compute_floating_ips_client.create_floating_ip(
pool=CONF.network.floating_network_name))
return validation_data