Make sure only one port_id is given.

It could happen by mistake that both port_id and port parameters are
passed to create_floating_ip method. In such case verify they are
the same port to avoid undetected problems.

Change-Id: I4ebdbca21a2f8285cf22f57f55e52892c9feb34d
This commit is contained in:
Federico Ressi 2018-09-24 16:19:14 +02:00 committed by Brian Haley
parent 0d24f2a02a
commit 47f6ae434e
1 changed files with 5 additions and 1 deletions

View File

@ -613,7 +613,11 @@ class BaseNetworkTest(test.BaseTestCase):
cls.external_network_id)
if port:
kwargs['port_id'] = port['id']
port_id = kwargs.setdefault('port_id', port['id'])
if port_id != port['id']:
message = "Port ID specified twice: {!s} != {!s}".format(
port_id, port['id'])
raise ValueError(message)
fip = client.create_floatingip(external_network_id,
**kwargs)['floatingip']