Commit 7a0b9b2b by Szabolcs Gelencser

Add public network icon, ipv4 address to interfaces

parent 0cfffed4
......@@ -15,9 +15,9 @@
{% for i in networks %}
<div>
<h3 class="list-group-item-heading dashboard-vm-details-network-h3">
<i class="fa fa-{% if i.host %}globe{% else %}link{% endif %}"></i>
<i class="fa fa-{% if i.internet_access %}globe{% else %}link{% endif %}"></i>
{{ i.name }}
{% if not i.subnets.0.enable_dhcp %}({% trans "unmanaged" %}){% endif %}
{% if not i.subnet.enable_dhcp %}({% trans "unmanaged" %}){% endif %}
{% if user.is_superuser and i.host %}
<a href="{{ i.host.get_absolute_url }}"
class="btn btn-default btn-xs">{% trans "edit" %}</a>
......@@ -32,23 +32,23 @@
</span>
{% endif %}{% endwith %}
</h3>
{% if i.host %}
<div class="row">
<div class="col-md-5">
<dl>
<dt>{% trans "IPv4 address" %}:</dt> <dd>{{ i.host.ipv4 }}</dd>
<dt>{% trans "IPv6 address" %}:</dt> <dd>{{ i.host.ipv6 }}</dd>
<dt>{% trans "DNS name" %}:</dt> <dd>{{ i.host.get_fqdn }}</dd>
<dt>{% trans "Groups" %}:</dt>
<dd>
{% for g in i.host.groups.all %}
{{ g }}{% if not forloop.last %},{% endif %}
{% empty %}
-
{% endfor %}
</dd>
<dt>{% trans "IPv4 address" %}:</dt> <dd>{{ i.ipv4 }}</dd>
{# <dt>{% trans "IPv6 address" %}:</dt> <dd>{{ i.ipv6 }}</dd>#}
{# <dt>{% trans "DNS name" %}:</dt> <dd>{{ i.host.get_fqdn }}</dd>#}
{# <dt>{% trans "Groups" %}:</dt>#}
{# <dd>#}
{# {% for g in i.host.groups.all %}#}
{# {{ g }}{% if not forloop.last %},{% endif %}#}
{# {% empty %}#}
{# -#}
{# {% endfor %}#}
{# </dd>#}
</dl>
</div>
{% if i.host %}
<div class="col-md-7">
<ul class="nav nav-pills pull-right">
<li class="active"><a href="#ipv4_{{ i.host.vlan.pk }}" data-toggle="pill" class="text-center">{% trans "IPv4" %}</a></li>
......@@ -136,7 +136,7 @@
{% include "dashboard/vm-detail/_network-port-add.html" %}
</div>
</div>
</div>
{% endif %}
</div>
</div>
{% endfor %}
......@@ -148,21 +148,30 @@ class VmDetailView(LoginRequiredMixin, GraphMixin, DetailView):
activities = openstack_api.nova.instance_action_list(self.request, instance.id)
ports = openstack_api.neutron.port_list(self.request)
instance_ports = [p for p in ports if p.device_id == self.object.id]
instance_net_ids = [p.network_id for p in ports if p.device_id == self.object.id]
instance_net_ids = [p.network_id for p in instance_ports]
all_networks = openstack_api.neutron.network_list(self.request)
instance_networks = [n for n in all_networks if n.id in instance_net_ids and len(n.subnets) > 0]
instance_networks = {n.id: n for n in all_networks if n.id in instance_net_ids and len(n.subnets) > 0}
router_ports = [p for p in ports if p.device_owner == 'network:router_interface']
routers = openstack_api.neutron.router_list(self.request)
router_by_id = {r.id: r for r in routers}
for n in instance_networks:
n.subnet = n.subnets[0]
#TODO: mark network public if it is based on router ports and router
# mark networks with internet access
for rtr_port in router_ports:
if router_by_id[rtr_port.device_id].external_gateway_info is not None \
and rtr_port.network_id in instance_networks.keys():
instance_networks[rtr_port.network_id].internet_access = True
for port in instance_ports:
instance_networks[port.network_id].ipv4 = port.fixed_ips[0]['ip_address']
# set default subnets for networks
for id in instance_networks:
instance_networks[id].subnet = instance_networks[id].subnets[0]
context['networks'] = instance_networks
context['networks'] = instance_networks.values()
# context['vlans'] = Vlan.get_objects_with_level(
# 'user', self.request.user
......
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