Commit 7a0b9b2b by Szabolcs Gelencser

Add public network icon, ipv4 address to interfaces

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