Remove port_id from floating ip disassociate
Remove the redundant port_id from parameters of FloatingIpManager disassociate function and the related. Change-Id: I7425d654d9fee51b6b74e1cda888e12100a9cf3d Closes-Bug: #1396050
This commit is contained in:
parent
97bead4832
commit
ec93149311
@ -65,9 +65,8 @@ def floating_ip_associate(request, floating_ip_id, port_id):
|
||||
port_id)
|
||||
|
||||
|
||||
def floating_ip_disassociate(request, floating_ip_id, port_id):
|
||||
return NetworkClient(request).floating_ips.disassociate(floating_ip_id,
|
||||
port_id)
|
||||
def floating_ip_disassociate(request, floating_ip_id):
|
||||
return NetworkClient(request).floating_ips.disassociate(floating_ip_id)
|
||||
|
||||
|
||||
def floating_ip_target_list(request):
|
||||
|
@ -90,12 +90,8 @@ class FloatingIpManager(object):
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def disassociate(self, floating_ip_id, port_id):
|
||||
"""Disassociates the floating IP from the port.
|
||||
|
||||
port_id is a fixed IP of a instance (Nova) or
|
||||
a port_id attached to a VNIC of a instance.
|
||||
"""
|
||||
def disassociate(self, floating_ip_id):
|
||||
"""Disassociates the floating IP specified."""
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
|
@ -397,7 +397,7 @@ class FloatingIpManager(network_base.FloatingIpManager):
|
||||
self.client.update_floatingip(floating_ip_id,
|
||||
{'floatingip': update_dict})
|
||||
|
||||
def disassociate(self, floating_ip_id, port_id):
|
||||
def disassociate(self, floating_ip_id):
|
||||
update_dict = {'port_id': None}
|
||||
self.client.update_floatingip(floating_ip_id,
|
||||
{'floatingip': update_dict})
|
||||
|
@ -394,7 +394,7 @@ class FloatingIpManager(network_base.FloatingIpManager):
|
||||
fip = self.client.floating_ips.get(floating_ip_id)
|
||||
self.client.servers.add_floating_ip(server.id, fip.ip)
|
||||
|
||||
def disassociate(self, floating_ip_id, port_id):
|
||||
def disassociate(self, floating_ip_id):
|
||||
fip = self.client.floating_ips.get(floating_ip_id)
|
||||
server = self.client.servers.get(fip.instance_id)
|
||||
self.client.servers.remove_floating_ip(server.id, fip.ip)
|
||||
|
@ -142,8 +142,7 @@ class DisassociateIP(tables.Action):
|
||||
def single(self, table, request, obj_id):
|
||||
try:
|
||||
fip = table.get_object_by_id(filters.get_int_or_uuid(obj_id))
|
||||
api.network.floating_ip_disassociate(request, fip.id,
|
||||
fip.port_id)
|
||||
api.network.floating_ip_disassociate(request, fip.id)
|
||||
LOG.info('Disassociating Floating IP "%s".' % obj_id)
|
||||
messages.success(request,
|
||||
_('Successfully disassociated Floating IP: %s')
|
||||
|
@ -152,7 +152,6 @@ class FloatingIpViewTests(test.TestCase):
|
||||
'tenant_floating_ip_list',)})
|
||||
def test_disassociate_post(self):
|
||||
floating_ip = self.floating_ips.first()
|
||||
server = self.servers.first()
|
||||
|
||||
api.nova.server_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn([self.servers.list(), False])
|
||||
@ -161,8 +160,7 @@ class FloatingIpViewTests(test.TestCase):
|
||||
api.network.tenant_floating_ip_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.floating_ips.list())
|
||||
api.network.floating_ip_disassociate(IsA(http.HttpRequest),
|
||||
floating_ip.id,
|
||||
server.id)
|
||||
floating_ip.id)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
action = "floating_ips__disassociate__%s" % floating_ip.id
|
||||
@ -177,7 +175,6 @@ class FloatingIpViewTests(test.TestCase):
|
||||
'tenant_floating_ip_list',)})
|
||||
def test_disassociate_post_with_exception(self):
|
||||
floating_ip = self.floating_ips.first()
|
||||
server = self.servers.first()
|
||||
|
||||
api.nova.server_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn([self.servers.list(), False])
|
||||
@ -187,8 +184,7 @@ class FloatingIpViewTests(test.TestCase):
|
||||
.AndReturn(self.floating_ips.list())
|
||||
|
||||
api.network.floating_ip_disassociate(IsA(http.HttpRequest),
|
||||
floating_ip.id,
|
||||
server.id) \
|
||||
floating_ip.id) \
|
||||
.AndRaise(self.exceptions.nova)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
|
@ -601,8 +601,7 @@ class SimpleDisassociateIP(policy.PolicyTargetMixin, tables.Action):
|
||||
# off the first one.
|
||||
if fips:
|
||||
fip = fips.pop()
|
||||
api.network.floating_ip_disassociate(request,
|
||||
fip.id, fip.port_id)
|
||||
api.network.floating_ip_disassociate(request, fip.id)
|
||||
messages.success(request,
|
||||
_("Successfully disassociated "
|
||||
"floating IP: %s") % fip.ip)
|
||||
|
@ -3355,7 +3355,7 @@ class InstanceTests(helpers.TestCase):
|
||||
api.network.tenant_floating_ip_list(
|
||||
IsA(http.HttpRequest)).AndReturn([fip])
|
||||
api.network.floating_ip_disassociate(
|
||||
IsA(http.HttpRequest), fip.id, server.id)
|
||||
IsA(http.HttpRequest), fip.id)
|
||||
|
||||
self.mox.ReplayAll()
|
||||
|
||||
|
@ -196,8 +196,7 @@ class NetworkApiNovaFloatingIpTests(NetworkApiNovaTestBase):
|
||||
self.mox.ReplayAll()
|
||||
|
||||
api.network.floating_ip_disassociate(self.request,
|
||||
floating_ip.id,
|
||||
server.id)
|
||||
floating_ip.id)
|
||||
|
||||
def test_floating_ip_target_list(self):
|
||||
servers = self.servers.list()
|
||||
@ -671,15 +670,11 @@ class NetworkApiNeutronFloatingIpTests(NetworkApiNeutronTestBase):
|
||||
|
||||
def test_floating_ip_disassociate(self):
|
||||
fip = self.api_q_floating_ips.list()[1]
|
||||
assoc_port = self.api_ports.list()[1]
|
||||
ip_address = assoc_port['fixed_ips'][0]['ip_address']
|
||||
target_id = '%s_%s' % (assoc_port['id'], ip_address)
|
||||
self.qclient.update_floatingip(fip['id'],
|
||||
{'floatingip': {'port_id': None}})
|
||||
self.mox.ReplayAll()
|
||||
|
||||
api.network.floating_ip_disassociate(self.request, fip['id'],
|
||||
target_id)
|
||||
api.network.floating_ip_disassociate(self.request, fip['id'])
|
||||
|
||||
def _get_target_id(self, port):
|
||||
param = {'id': port['id'],
|
||||
|
Loading…
Reference in New Issue
Block a user