Commit 045df7bb by Kálmán Viktor

dashboard: add ip and lease for vm list

parent 2fc29987
...@@ -68,10 +68,20 @@ ...@@ -68,10 +68,20 @@
{% trans "Owner" as t %} {% trans "Owner" as t %}
{% include "dashboard/vm-list/header-link.html" with name=t sort="owner" %} {% include "dashboard/vm-list/header-link.html" with name=t sort="owner" %}
</th> </th>
{% if user.is_superuser %}<th data-sort="string" class="orderable sortable"> <th data-sort="string" class="orderable sortable">
{% trans "Node" as t %} {% trans "Lease" as t %}
{% include "dashboard/vm-list/header-link.html" with name=t sort="node" %} {% include "dashboard/vm-list/header-link.html" with name=t sort="lease" %}
</th>{% endif %} </th>
{% if user.is_superuser %}
<th data-sort="string" class="orderable sortable">
{% trans "IP address" as t %}
{% include "dashboard/vm-list/header-link.html" with name=t sort="ip_addr" %}
</th>
<th data-sort="string" class="orderable sortable">
{% trans "Node" as t %}
{% include "dashboard/vm-list/header-link.html" with name=t sort="node" %}
</th>
{% endif %}
</tr></thead><tbody> </tr></thead><tbody>
{% for i in object_list %} {% for i in object_list %}
<tr class="{% cycle 'odd' 'even' %}" data-vm-pk="{{ i.pk }}"> <tr class="{% cycle 'odd' 'even' %}" data-vm-pk="{{ i.pk }}">
...@@ -93,7 +103,13 @@ ...@@ -93,7 +103,13 @@
{% endif %} {% endif %}
{# include "dashboard/_display-name.html" with user=i.owner show_org=True #} {# include "dashboard/_display-name.html" with user=i.owner show_org=True #}
</td> </td>
<td class="lease "data-sort-value="{{ i.lease.name }}">
{{ i.lease.name }}
</td>
{% if user.is_superuser %} {% if user.is_superuser %}
<td class="ip_addr "data-sort-value="{{ i.ipv4 }}">
{{ i.ipv4|default:"-" }}
</td>
<td class="node "data-sort-value="{{ i.node.normalized_name }}"> <td class="node "data-sort-value="{{ i.node.normalized_name }}">
{{ i.node.name|default:"-" }} {{ i.node.name|default:"-" }}
</td> </td>
...@@ -101,7 +117,7 @@ ...@@ -101,7 +117,7 @@
</tr> </tr>
{% empty %} {% empty %}
<tr> <tr>
<td colspan="5"> <td colspan="7">
{% if request.GET.s %} {% if request.GET.s %}
<strong>{% trans "No result." %}</strong> <strong>{% trans "No result." %}</strong>
{% else %} {% else %}
......
...@@ -1875,7 +1875,8 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView): ...@@ -1875,7 +1875,8 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView):
return queryset.filter( return queryset.filter(
**self.get_queryset_filters()).prefetch_related( **self.get_queryset_filters()).prefetch_related(
"owner", "node", "owner__profile").distinct() "owner", "node", "owner__profile", "interface_set", "lease",
"interface_set__host").distinct()
class NodeList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView): class NodeList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
......
...@@ -513,7 +513,12 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin, ...@@ -513,7 +513,12 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
def ipv4(self): def ipv4(self):
"""Primary IPv4 address of the instance. """Primary IPv4 address of the instance.
""" """
return self.primary_host.ipv4 if self.primary_host else None # return self.primary_host.ipv4 if self.primary_host else None
for i in self.interface_set.all():
if i.host:
return i.host.ipv4
return None
@property @property
def ipv6(self): def ipv6(self):
......
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