From 1e2570f2082f930d63c0f4102872dc4dfa65bcb3 Mon Sep 17 00:00:00 2001 From: Georges Dubus Date: Mon, 15 Dec 2014 14:31:14 +0100 Subject: [PATCH] Display the vip name in the floating IP association dialog When LBaaS vips are defined, the floating IP association dialog used to display them with their IP and the name "None". Now, the name of the vip is used. Closes-bug: 1401954 Change-Id: I3e26dc84d0af9f226f1e1fc915c04c4089cf7c93 --- openstack_dashboard/api/neutron.py | 11 ++++++++++- openstack_dashboard/test/api_tests/network_tests.py | 3 +++ openstack_dashboard/test/test_data/neutron_data.py | 4 ++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/openstack_dashboard/api/neutron.py b/openstack_dashboard/api/neutron.py index 6926c91106..d591bec84a 100644 --- a/openstack_dashboard/api/neutron.py +++ b/openstack_dashboard/api/neutron.py @@ -423,6 +423,14 @@ class FloatingIpManager(network_base.FloatingIpManager): servers, has_more = nova.server_list(self.request) server_dict = SortedDict([(s.id, s.name) for s in servers]) reachable_subnets = self._get_reachable_subnets(ports) + if is_service_enabled(self.request, + config_name='enable_lb', + ext_name='lbaas'): + # Also get the loadbalancer VIPs + vip_dict = {v['port_id']: v['name'] + for v in self.client.list_vips().get('vips', [])} + else: + vip_dict = {} targets = [] for p in ports: @@ -430,7 +438,8 @@ class FloatingIpManager(network_base.FloatingIpManager): if p.device_owner.startswith('network:'): continue port_id = p.id - server_name = server_dict.get(p.device_id) + server_name = server_dict.get(p.device_id) or vip_dict.get(port_id) + for ip in p.fixed_ips: if ip['subnet_id'] not in reachable_subnets: continue diff --git a/openstack_dashboard/test/api_tests/network_tests.py b/openstack_dashboard/test/api_tests/network_tests.py index 36deb0b59e..d1bc3eeab9 100644 --- a/openstack_dashboard/test/api_tests/network_tests.py +++ b/openstack_dashboard/test/api_tests/network_tests.py @@ -688,6 +688,7 @@ class NetworkApiNeutronFloatingIpTests(NetworkApiNeutronTestBase): 'addr': port['fixed_ips'][0]['ip_address']} return 'server_%(svrid)s: %(addr)s' % param + @override_settings(OPENSTACK_NEUTRON_NETWORK={'enable_lb': True}) def test_floating_ip_target_list(self): ports = self.api_ports.list() # Port on the first subnet is connected to a router @@ -714,6 +715,8 @@ class NetworkApiNeutronFloatingIpTests(NetworkApiNeutronTestBase): self.qclient.list_routers().AndReturn({'routers': self.api_routers.list()}) + self.qclient.list_vips().AndReturn({'vips': self.vips.list()}) + self.mox.ReplayAll() rets = api.network.floating_ip_target_list(self.request) diff --git a/openstack_dashboard/test/test_data/neutron_data.py b/openstack_dashboard/test/test_data/neutron_data.py index 7b596b5eb8..c5f1ae64c5 100644 --- a/openstack_dashboard/test/test_data/neutron_data.py +++ b/openstack_dashboard/test/test_data/neutron_data.py @@ -658,11 +658,15 @@ def data(TEST): extension_5 = {"name": "HA Router extension", "alias": "l3-ha", "description": "Add HA capability to routers."} + extension_6 = {"name": "LoadBalancing service", + "alias": "lbaas", + "description": "Extension for LoadBalancing service"} TEST.api_extensions.add(extension_1) TEST.api_extensions.add(extension_2) TEST.api_extensions.add(extension_3) TEST.api_extensions.add(extension_4) TEST.api_extensions.add(extension_5) + TEST.api_extensions.add(extension_6) # 1st agent. agent_dict = {"binary": "neutron-openvswitch-agent",