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:
committed by
Alvaro Lopez Garcia
parent
bd01399525
commit
45dd8b5005
@@ -799,13 +799,14 @@ class OpenStackHelper(BaseHelper):
|
|||||||
link_list.append(link)
|
link_list.append(link)
|
||||||
if not link_list:
|
if not link_list:
|
||||||
for ip in floating_ips:
|
for ip in floating_ips:
|
||||||
link = self._build_link(os_helpers.PUBLIC_NETWORK,
|
if ip["instance_id"]:
|
||||||
ip['instance_id'],
|
link = self._build_link(os_helpers.PUBLIC_NETWORK,
|
||||||
ip['ip'],
|
ip['instance_id'],
|
||||||
ip_id=ip["id"],
|
ip['ip'],
|
||||||
pool=ip["pool"]
|
ip_id=ip["id"],
|
||||||
)
|
pool=ip["pool"]
|
||||||
link_list.append(link)
|
)
|
||||||
|
link_list.append(link)
|
||||||
return link_list
|
return link_list
|
||||||
|
|
||||||
def create_port(self, req, network_id, device_id):
|
def create_port(self, req, network_id, device_id):
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
from ooi.api import base
|
from ooi.api import base
|
||||||
from ooi.api import helpers
|
from ooi.api import helpers
|
||||||
from ooi.api import network as network_api
|
|
||||||
from ooi import exception
|
from ooi import exception
|
||||||
from ooi.occi.core import collection
|
from ooi.occi.core import collection
|
||||||
from ooi.occi.infrastructure import compute
|
from ooi.occi.infrastructure import compute
|
||||||
@@ -35,7 +34,7 @@ def _get_network_link_resources(link_list):
|
|||||||
occi_network_resources = []
|
occi_network_resources = []
|
||||||
if link_list:
|
if link_list:
|
||||||
for l in link_list:
|
for l in link_list:
|
||||||
compute_id = l.get('compute_id')
|
compute_id = l['compute_id']
|
||||||
mac = l.get('mac', None)
|
mac = l.get('mac', None)
|
||||||
net_pool = l.get('pool', None)
|
net_pool = l.get('pool', None)
|
||||||
ip = l.get('ip', None)
|
ip = l.get('ip', None)
|
||||||
@@ -68,10 +67,7 @@ class Controller(base.Controller):
|
|||||||
|
|
||||||
:param req: request object
|
:param req: request object
|
||||||
"""
|
"""
|
||||||
attributes = network_api.process_parameters(req)
|
link_list = self.os_helper.list_compute_net_links(req)
|
||||||
link_list = self.os_helper.list_compute_net_links(
|
|
||||||
req,
|
|
||||||
attributes)
|
|
||||||
occi_link_resources = _get_network_link_resources(link_list)
|
occi_link_resources = _get_network_link_resources(link_list)
|
||||||
return collection.Collection(resources=occi_link_resources)
|
return collection.Collection(resources=occi_link_resources)
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class TestNetworkLinkController(base.TestController):
|
|||||||
os_network.OSNetworkInterface)
|
os_network.OSNetworkInterface)
|
||||||
else:
|
else:
|
||||||
self.assertEqual([], ret.resources)
|
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")
|
@mock.patch.object(helpers.OpenStackHelper, "list_compute_net_links")
|
||||||
def test_index_Empty(self, mock_list):
|
def test_index_Empty(self, mock_list):
|
||||||
|
|||||||
Reference in New Issue
Block a user