summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-04-17 08:47:55 +0000
committerGerrit Code Review <review@openstack.org>2015-04-17 08:47:55 +0000
commit202aa1e278855db35aeefb1d263da57496dffceb (patch)
tree7250be95c958d3bd5b68c16d6570611e5cd8a547
parent6eff20fa421f519ca225f99040642b76b0e69d2f (diff)
parent75c88f3da0568f833ce57e6fecf4d3765e6f7150 (diff)
downloadhorizon-202aa1e278855db35aeefb1d263da57496dffceb.tar.gz
Merge "Show ports from shared nets in floating IP assoc" into stable/juno
-rw-r--r--openstack_dashboard/api/neutron.py6
-rw-r--r--openstack_dashboard/test/api_tests/network_tests.py21
2 files changed, 21 insertions, 6 deletions
diff --git a/openstack_dashboard/api/neutron.py b/openstack_dashboard/api/neutron.py
index fff61add5..347ca56ff 100644
--- a/openstack_dashboard/api/neutron.py
+++ b/openstack_dashboard/api/neutron.py
@@ -414,7 +414,11 @@ class FloatingIpManager(network_base.FloatingIpManager):
if ((p.device_owner ==
'network:router_interface')
and (p.device_id in gw_routers))])
- return reachable_subnets
+ # we have to include any shared subnets as well because we may not
+ # have permission to see the router interface to infer connectivity
+ shared = set([s.id for n in network_list(self.request, shared=True)
+ for s in n.subnets])
+ return reachable_subnets | shared
def list_targets(self):
tenant_id = self.request.user.tenant_id
diff --git a/openstack_dashboard/test/api_tests/network_tests.py b/openstack_dashboard/test/api_tests/network_tests.py
index c46c8c054..9eb0dba33 100644
--- a/openstack_dashboard/test/api_tests/network_tests.py
+++ b/openstack_dashboard/test/api_tests/network_tests.py
@@ -691,16 +691,22 @@ class NetworkApiNeutronFloatingIpTests(NetworkApiNeutronTestBase):
'addr': port['fixed_ips'][0]['ip_address']}
return 'server_%(svrid)s: %(addr)s' % param
+ def _subs_from_port(self, port):
+ return [ip['subnet_id'] for ip in port['fixed_ips']]
+
def test_floating_ip_target_list(self):
ports = self.api_ports.list()
# Port on the first subnet is connected to a router
# attached to external network in neutron_data.
subnet_id = self.subnets.first().id
- target_ports = [(self._get_target_id(p),
- self._get_target_name(p)) for p in ports
- if (not p['device_owner'].startswith('network:') and
- subnet_id in [ip['subnet_id']
- for ip in p['fixed_ips']])]
+ shared_nets = [n for n in self.api_networks.list() if n['shared']]
+ shared_subnet_ids = [s for n in shared_nets for s in n['subnets']]
+ target_ports = [
+ (self._get_target_id(p), self._get_target_name(p)) for p in ports
+ if (not p['device_owner'].startswith('network:') and
+ (subnet_id in self._subs_from_port(p) or
+ (set(shared_subnet_ids) & set(self._subs_from_port(p)))))
+ ]
filters = {'tenant_id': self.request.user.tenant_id}
self.qclient.list_ports(**filters).AndReturn({'ports': ports})
servers = self.servers.list()
@@ -716,6 +722,11 @@ class NetworkApiNeutronFloatingIpTests(NetworkApiNeutronTestBase):
.AndReturn({'networks': ext_nets})
self.qclient.list_routers().AndReturn({'routers':
self.api_routers.list()})
+ self.qclient.list_networks(shared=True).AndReturn({'networks':
+ shared_nets})
+ shared_subs = [s for s in self.api_subnets.list()
+ if s['id'] in shared_subnet_ids]
+ self.qclient.list_subnets().AndReturn({'subnets': shared_subs})
self.mox.ReplayAll()