Commit d162945d by Szabolcs Gelencsér

Add flat ip support to connection details

parent f8478254
......@@ -107,7 +107,13 @@ class VmDetailView(LoginRequiredMixin, GraphMixin, DetailView):
return instance_floating_ips[0].ip, 22
all_ports = openstack_api.neutron.port_list(self.request)
instance_ports = [p for p in all_ports if p.instance_id == self.object.id]
all_networks = openstack_api.neutron.network_list_for_tenant(self.request, self.request.user.tenant_id)
flat_network_ids = [n.id for n in all_networks if n.name in settings.FLAT_EXTERNAL_NETWORKS]
instance_flat_ports = [p for p in all_ports if p.device_id == self.object.id
and p.network_id in flat_network_ids]
if len(instance_flat_ports) > 0:
return instance_flat_ports[0].fixed_ips[0]["ip_address"], 22
return None, None
......@@ -167,7 +173,7 @@ class VmDetailView(LoginRequiredMixin, GraphMixin, DetailView):
'vnc_url': vnc_console.url if vnc_console else None,
'ops': ops,
'op': {i.op: i for i in ops},
'connect_commands': [connection_cmd,],
'connect_commands': [connection_cmd,] if connection_port else None,
'hide_tutorial': hide_tutorial,
'fav': Favourite.objects.filter(user=user.id, instance=instance.id).exists(),
'instance': self.object,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment