Merge "Fix NotImplementedError in floating-ip-list"
This commit is contained in:
@@ -71,7 +71,7 @@ def _translate_floating_ip_view(floating_ip):
|
||||
except (TypeError, KeyError, AttributeError):
|
||||
result['fixed_ip'] = None
|
||||
try:
|
||||
result['instance_id'] = floating_ip['instance']['uuid']
|
||||
result['instance_id'] = floating_ip['fixed_ip']['instance_uuid']
|
||||
except (TypeError, KeyError, AttributeError):
|
||||
result['instance_id'] = None
|
||||
return {'floating_ip': result}
|
||||
@@ -107,17 +107,6 @@ class FloatingIPController(object):
|
||||
self.network_api = network.API()
|
||||
super(FloatingIPController, self).__init__()
|
||||
|
||||
def _normalize_ip(self, floating_ip):
|
||||
# NOTE(vish): translate expects instance to be in the floating_ip
|
||||
# dict but it is returned in the fixed_ip dict by
|
||||
# nova-network
|
||||
fixed_ip = floating_ip.get('fixed_ip')
|
||||
if 'instance' not in floating_ip:
|
||||
if fixed_ip:
|
||||
floating_ip['instance'] = fixed_ip['instance']
|
||||
else:
|
||||
floating_ip['instance'] = None
|
||||
|
||||
@wsgi.serializers(xml=FloatingIPTemplate)
|
||||
def show(self, req, id):
|
||||
"""Return data about the given floating ip."""
|
||||
@@ -130,8 +119,6 @@ class FloatingIPController(object):
|
||||
msg = _("Floating ip not found for id %s") % id
|
||||
raise webob.exc.HTTPNotFound(explanation=msg)
|
||||
|
||||
self._normalize_ip(floating_ip)
|
||||
|
||||
return _translate_floating_ip_view(floating_ip)
|
||||
|
||||
@wsgi.serializers(xml=FloatingIPsTemplate)
|
||||
@@ -142,9 +129,6 @@ class FloatingIPController(object):
|
||||
|
||||
floating_ips = self.network_api.get_floating_ips_by_project(context)
|
||||
|
||||
for floating_ip in floating_ips:
|
||||
self._normalize_ip(floating_ip)
|
||||
|
||||
return _translate_floating_ips_view(floating_ips)
|
||||
|
||||
@wsgi.serializers(xml=FloatingIPTemplate)
|
||||
|
||||
@@ -52,6 +52,7 @@ def network_api_get_floating_ips_by_project(self, context):
|
||||
'address': '10.10.10.10',
|
||||
'pool': 'nova',
|
||||
'fixed_ip': {'address': '10.0.0.1',
|
||||
'instance_uuid': FAKE_UUID,
|
||||
'instance': {'uuid': FAKE_UUID}}},
|
||||
{'id': 2,
|
||||
'pool': 'nova', 'interface': 'eth0',
|
||||
@@ -171,7 +172,6 @@ class FloatingIpTest(test.TestCase):
|
||||
floating_ip_address)
|
||||
# NOTE(vish): network_get uses the id not the address
|
||||
floating_ip = db.floating_ip_get(self.context, floating_ip['id'])
|
||||
self.controller._normalize_ip(floating_ip)
|
||||
view = floating_ips._translate_floating_ip_view(floating_ip)
|
||||
self.assertIn('floating_ip', view)
|
||||
self.assertTrue(view['floating_ip']['id'])
|
||||
@@ -182,7 +182,6 @@ class FloatingIpTest(test.TestCase):
|
||||
def test_translate_floating_ip_view_dict(self):
|
||||
floating_ip = {'id': 0, 'address': '10.0.0.10', 'pool': 'nova',
|
||||
'fixed_ip': None}
|
||||
self.controller._normalize_ip(floating_ip)
|
||||
view = floating_ips._translate_floating_ip_view(floating_ip)
|
||||
self.assertIn('floating_ip', view)
|
||||
|
||||
@@ -266,6 +265,7 @@ class FloatingIpTest(test.TestCase):
|
||||
def get_floating_ip(self, context, id):
|
||||
return {'id': 1, 'address': '10.10.10.10', 'pool': 'nova',
|
||||
'fixed_ip': {'address': '10.0.0.1',
|
||||
'instance_uuid': FAKE_UUID,
|
||||
'instance': {'uuid': FAKE_UUID}}}
|
||||
|
||||
self.stubs.Set(network.api.API, "get_floating_ip", get_floating_ip)
|
||||
|
||||
Reference in New Issue
Block a user