Merge "[Floating IP] Remove port creation on fip creation"
This commit is contained in:
commit
46c2746ee3
@ -101,7 +101,7 @@ class VMScenario(base.Scenario):
|
|||||||
fixed_ip = server.addresses[internal_network][0]["addr"]
|
fixed_ip = server.addresses[internal_network][0]["addr"]
|
||||||
|
|
||||||
fip = network_wrapper.wrap(self.clients).create_floating_ip(
|
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)
|
tenant_id=server.tenant_id, fixed_ip=fixed_ip)
|
||||||
|
|
||||||
self._associate_floating_ip(server, fip["ip"], fixed_address=fixed_ip)
|
self._associate_floating_ip(server, fip["ip"], fixed_address=fixed_ip)
|
||||||
|
@ -320,12 +320,11 @@ class NeutronWrapper(NetworkWrapper):
|
|||||||
kwargs["name"] = utils.generate_random_name("rally_port_")
|
kwargs["name"] = utils.generate_random_name("rally_port_")
|
||||||
return self.client.create_port({"port": kwargs})["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):
|
tenant_id=None, port_id=None, **kwargs):
|
||||||
"""Create Neutron floating IP.
|
"""Create Neutron floating IP.
|
||||||
|
|
||||||
:param ext_network: floating network name or dict
|
:param ext_network: floating network name or dict
|
||||||
:param int_network: fixed network name or dict
|
|
||||||
:param tenant_id str tenant id
|
:param tenant_id str tenant id
|
||||||
:param port_id: str port id
|
:param port_id: str port id
|
||||||
:param **kwargs: for compatibility, not used here
|
:param **kwargs: for compatibility, not used here
|
||||||
@ -351,18 +350,10 @@ class NeutronWrapper(NetworkWrapper):
|
|||||||
"no external networks found")
|
"no external networks found")
|
||||||
net_id = ext_networks[0]["id"]
|
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},
|
kwargs = {"floatingip": {"floating_network_id": net_id},
|
||||||
"tenant_id": tenant_id,
|
"tenant_id": tenant_id}
|
||||||
"port_id": port_id}
|
if port_id:
|
||||||
|
kwargs["port_id"] = port_id
|
||||||
|
|
||||||
fip = self.client.create_floatingip(kwargs)["floatingip"]
|
fip = self.client.create_floatingip(kwargs)["floatingip"]
|
||||||
return {"id": fip["id"], "ip": fip["floating_ip_address"]}
|
return {"id": fip["id"], "ip": fip["floating_ip_address"]}
|
||||||
|
@ -271,7 +271,7 @@ class VMScenarioTestCase(test.TestCase):
|
|||||||
|
|
||||||
mock_wrap.assert_called_once_with(scenario.clients)
|
mock_wrap.assert_called_once_with(scenario.clients)
|
||||||
netwrap.create_floating_ip.assert_called_once_with(
|
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")
|
tenant_id="foo_tenant", fixed_ip="foo_ip")
|
||||||
|
|
||||||
scenario._associate_floating_ip.assert_called_once_with(
|
scenario._associate_floating_ip.assert_called_once_with(
|
||||||
|
@ -403,14 +403,11 @@ class NeutronWrapperTestCase(test.TestCase):
|
|||||||
|
|
||||||
wrap.get_network = mock.Mock(
|
wrap.get_network = mock.Mock(
|
||||||
return_value={"id": "foo_net", "external": True})
|
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.create_floating_ip(tenant_id="foo_tenant", ext_network="ext_net")
|
||||||
|
|
||||||
wrap.get_network = mock.Mock(
|
wrap.get_network = mock.Mock(
|
||||||
return_value={"id": "foo_net", "external": False})
|
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,
|
self.assertRaises(network.NetworkWrapperException,
|
||||||
wrap.create_floating_ip, tenant_id="foo_tenant",
|
wrap.create_floating_ip, tenant_id="foo_tenant",
|
||||||
|
Loading…
Reference in New Issue
Block a user