Solved list network links

It adds an extra parameter and shows free floating IPs. Now it
works fine, and shows only the floating IPs linked to a VM.

Change-Id: Ic9a078014d7d85829a36c93513c00b503982a059
Closes-bug: #1588858
This commit is contained in:
jorgesece
2016-06-03 16:28:04 +01:00
committed by Alvaro Lopez Garcia
parent bd01399525
commit 45dd8b5005
3 changed files with 11 additions and 14 deletions

View File

@@ -799,13 +799,14 @@ class OpenStackHelper(BaseHelper):
link_list.append(link)
if not link_list:
for ip in floating_ips:
link = self._build_link(os_helpers.PUBLIC_NETWORK,
ip['instance_id'],
ip['ip'],
ip_id=ip["id"],
pool=ip["pool"]
)
link_list.append(link)
if ip["instance_id"]:
link = self._build_link(os_helpers.PUBLIC_NETWORK,
ip['instance_id'],
ip['ip'],
ip_id=ip["id"],
pool=ip["pool"]
)
link_list.append(link)
return link_list
def create_port(self, req, network_id, device_id):

View File

@@ -16,7 +16,6 @@
from ooi.api import base
from ooi.api import helpers
from ooi.api import network as network_api
from ooi import exception
from ooi.occi.core import collection
from ooi.occi.infrastructure import compute
@@ -35,7 +34,7 @@ def _get_network_link_resources(link_list):
occi_network_resources = []
if link_list:
for l in link_list:
compute_id = l.get('compute_id')
compute_id = l['compute_id']
mac = l.get('mac', None)
net_pool = l.get('pool', None)
ip = l.get('ip', None)
@@ -68,10 +67,7 @@ class Controller(base.Controller):
:param req: request object
"""
attributes = network_api.process_parameters(req)
link_list = self.os_helper.list_compute_net_links(
req,
attributes)
link_list = self.os_helper.list_compute_net_links(req)
occi_link_resources = _get_network_link_resources(link_list)
return collection.Collection(resources=occi_link_resources)

View File

@@ -59,7 +59,7 @@ class TestNetworkLinkController(base.TestController):
os_network.OSNetworkInterface)
else:
self.assertEqual([], ret.resources)
mock_list.assert_called_with(req, None)
mock_list.assert_called_with(req)
@mock.patch.object(helpers.OpenStackHelper, "list_compute_net_links")
def test_index_Empty(self, mock_list):