[Floating IP] Remove port creation on fip creation

NeutronWrapper creates a private port when creating a floating IP.
This is bad because:
1. It doesn't make any sense to attach a fip to a standalone port.
2. The method associate_floating_ip() is always called and associates the fip
with a real server.
3. Rally consumes an extra port/ip from the tenant/network.

Change-Id: I932cdf707f6041df4eef8fcd6074ac069678de7b
Closes-Bug: #1465690
This commit is contained in:
Yair Fried 2015-06-17 13:18:10 +03:00
parent e1e6155b62
commit 16f8ff744d
4 changed files with 7 additions and 19 deletions

View File

@ -101,7 +101,7 @@ class VMScenario(base.Scenario):
fixed_ip = server.addresses[internal_network][0]["addr"]
fip = network_wrapper.wrap(self.clients).create_floating_ip(
ext_network=floating_network, int_network=internal_network,
ext_network=floating_network,
tenant_id=server.tenant_id, fixed_ip=fixed_ip)
self._associate_floating_ip(server, fip["ip"], fixed_address=fixed_ip)

View File

@ -320,12 +320,11 @@ class NeutronWrapper(NetworkWrapper):
kwargs["name"] = utils.generate_random_name("rally_port_")
return self.client.create_port({"port": kwargs})["port"]
def create_floating_ip(self, ext_network=None, int_network=None,
def create_floating_ip(self, ext_network=None,
tenant_id=None, port_id=None, **kwargs):
"""Create Neutron floating IP.
:param ext_network: floating network name or dict
:param int_network: fixed network name or dict
:param tenant_id str tenant id
:param port_id: str port id
:param **kwargs: for compatibility, not used here
@ -351,18 +350,10 @@ class NeutronWrapper(NetworkWrapper):
"no external networks found")
net_id = ext_networks[0]["id"]
if not port_id:
if type(int_network) is dict:
port_id = self.create_port(int_network["id"])["id"]
elif int_network:
int_net = self.get_network(name=int_network)
if int_net["external"]:
raise NetworkWrapperException("Network is external: %s"
% int_network)
port_id = self.create_port(int_net["id"])["id"]
kwargs = {"floatingip": {"floating_network_id": net_id},
"tenant_id": tenant_id,
"port_id": port_id}
"tenant_id": tenant_id}
if port_id:
kwargs["port_id"] = port_id
fip = self.client.create_floatingip(kwargs)["floatingip"]
return {"id": fip["id"], "ip": fip["floating_ip_address"]}

View File

@ -280,7 +280,7 @@ class VMScenarioTestCase(test.TestCase):
mock_wrap.assert_called_once_with(scenario.clients)
netwrap.create_floating_ip.assert_called_once_with(
ext_network="bar_network", int_network="foo_net",
ext_network="bar_network",
tenant_id="foo_tenant", fixed_ip="foo_ip")
scenario._associate_floating_ip.assert_called_once_with(

View File

@ -394,14 +394,11 @@ class NeutronWrapperTestCase(test.TestCase):
wrap.get_network = mock.Mock(
return_value={"id": "foo_net", "external": True})
self.assertRaises(network.NetworkWrapperException,
wrap.create_floating_ip, tenant_id="foo_tenant",
int_network="int_net")
wrap.create_floating_ip(tenant_id="foo_tenant", ext_network="ext_net")
wrap.get_network = mock.Mock(
return_value={"id": "foo_net", "external": False})
wrap.create_floating_ip(tenant_id="foo_tenant", int_network="int_net")
wrap.create_floating_ip(tenant_id="foo_tenant")
self.assertRaises(network.NetworkWrapperException,
wrap.create_floating_ip, tenant_id="foo_tenant",