Merge "Drop unused floating_ip_target_get_by_instance"
This commit is contained in:
commit
0b79c35007
|
@ -693,33 +693,6 @@ class FloatingIpManager(object):
|
|||
search_opts = {'device_id': instance_id}
|
||||
return port_list(self.request, **search_opts)
|
||||
|
||||
@profiler.trace
|
||||
def get_target_by_instance(self, instance_id, target_list=None):
|
||||
"""Returns a FloatingIpTarget object of floating IP association.
|
||||
|
||||
:param instance_id: ID of target VM instance
|
||||
:param target_list: (optional) a list returned by list_targets().
|
||||
If specified, looking up is done against the specified list
|
||||
to save extra API calls to a back-end. Otherwise a target
|
||||
information is retrieved from a back-end inside the method.
|
||||
"""
|
||||
if target_list is not None:
|
||||
targets = [target for target in target_list
|
||||
if target['instance_id'] == instance_id]
|
||||
if not targets:
|
||||
return None
|
||||
return targets[0]
|
||||
else:
|
||||
# In Neutron one port can have multiple ip addresses, so this
|
||||
# method picks up the first one and generate target id.
|
||||
ports = self._target_ports_by_instance(instance_id)
|
||||
if not ports:
|
||||
return None
|
||||
# TODO(amotoki): Avoid using p.fixed_ips[0].
|
||||
# Extract all IPv4 addresses instead
|
||||
return FloatingIpTarget(
|
||||
ports[0], ports[0].fixed_ips[0]['ip_address'], '')
|
||||
|
||||
@profiler.trace
|
||||
def list_targets_by_instance(self, instance_id, target_list=None):
|
||||
"""Returns a list of FloatingIpTarget objects of FIP association.
|
||||
|
@ -1542,11 +1515,6 @@ def floating_ip_target_list(request):
|
|||
return FloatingIpManager(request).list_targets()
|
||||
|
||||
|
||||
def floating_ip_target_get_by_instance(request, instance_id, cache=None):
|
||||
return FloatingIpManager(request).get_target_by_instance(
|
||||
instance_id, cache)
|
||||
|
||||
|
||||
def floating_ip_target_list_by_instance(request, instance_id, cache=None):
|
||||
return FloatingIpManager(request).list_targets_by_instance(
|
||||
instance_id, cache)
|
||||
|
|
|
@ -1337,18 +1337,6 @@ class NeutronApiFloatingIpTests(NeutronApiTestBase):
|
|||
self.assertEqual(exp[0], ret.id)
|
||||
self.assertEqual(exp[1], ret.name)
|
||||
|
||||
def test_floating_ip_target_get_by_instance(self):
|
||||
ports = self.api_ports.list()
|
||||
candidates = [p for p in ports if p['device_id'] == '1']
|
||||
search_opts = {'device_id': '1'}
|
||||
self.qclient.list_ports(**search_opts).AndReturn({'ports': candidates})
|
||||
self.mox.ReplayAll()
|
||||
|
||||
ret = api.neutron.floating_ip_target_get_by_instance(self.request, '1')
|
||||
self.assertEqual(self._get_target_id(candidates[0]), ret.id)
|
||||
self.assertEqual(candidates[0]['id'], ret.port_id)
|
||||
self.assertEqual('1', ret.instance_id)
|
||||
|
||||
def test_target_floating_ip_port_by_instance(self):
|
||||
server = self.servers.first()
|
||||
ports = self.api_ports.list()
|
||||
|
@ -1409,14 +1397,6 @@ class NeutronApiFloatingIpTests(NeutronApiTestBase):
|
|||
'10.11.12.13', 'vm3'),
|
||||
]
|
||||
|
||||
def test_floating_ip_target_get_by_instance_with_preloaded_target(self):
|
||||
target_list = self._get_preloaded_targets()
|
||||
self.mox.ReplayAll()
|
||||
|
||||
ret = api.neutron.floating_ip_target_get_by_instance(
|
||||
self.request, 'id-vm2', target_list)
|
||||
self.assertEqual('id21', ret.port_id)
|
||||
|
||||
def test_target_floating_ip_port_by_instance_with_preloaded_target(self):
|
||||
target_list = self._get_preloaded_targets()
|
||||
self.mox.ReplayAll()
|
||||
|
|
Loading…
Reference in New Issue