Commit 05291f17 by Kálmán Viktor

Merge branch 'issue-239' into 'master'

Add running instance count to template-list
parents 3aaeff41 5274ed89
......@@ -184,9 +184,8 @@ class UserListTablex(Table):
class TemplateListTable(Table):
name = LinkColumn(
'dashboard.views.template-detail',
args=[A('pk')],
name = TemplateColumn(
template_name="dashboard/template-list/column-template-name.html",
attrs={'th': {'data-sort': "string"}}
)
num_cores = Column(
......@@ -194,23 +193,31 @@ class TemplateListTable(Table):
attrs={'th': {'data-sort': "int"}}
)
ram_size = TemplateColumn(
"{{ record.ram_size }} Mb",
attrs={'th': {'data-sort': "string"}}
"{{ record.ram_size }} MiB",
attrs={'th': {'data-sort': "int"}},
)
lease = TemplateColumn(
"{{ record.lease.name }}",
verbose_name=_("Lease"),
attrs={'th': {'data-sort': "string"}}
)
arch = Column(
attrs={'th': {'data-sort': "string"}}
)
system = Column(
attrs={'th': {'data-sort': "string"}}
)
access_method = Column(
attrs={'th': {'data-sort': "string"}}
)
owner = TemplateColumn(
template_name="dashboard/template-list/column-template-owner.html",
verbose_name=_("Owner"),
attrs={'th': {'data-sort': "string"}}
)
running = TemplateColumn(
template_name="dashboard/template-list/column-template-running.html",
verbose_name=_("Running"),
attrs={'th': {'data-sort': "int"}},
orderable=False,
)
actions = TemplateColumn(
verbose_name=_("Actions"),
template_name="dashboard/template-list/column-template-actions.html",
......@@ -222,8 +229,8 @@ class TemplateListTable(Table):
model = InstanceTemplate
attrs = {'class': ('table table-bordered table-striped table-hover'
' template-list-table')}
fields = ('name', 'num_cores', 'ram_size', 'arch',
'system', 'access_method', 'lease', 'actions', )
fields = ('name', 'num_cores', 'ram_size', 'system',
'access_method', 'lease', 'owner', 'running', 'actions', )
prefix = "template-"
......
<a href="{% url "dashboard.views.template-detail" pk=record.pk %}" title="{{ record.description }}">
{{ record.name }}
</a>
{% include "dashboard/_display-name.html" with user=record.owner show_org=True %}
<a href="{% url "dashboard.views.vm-list" %}?s=template:{{ record.pk }}%20status:running">
{{ record.get_running_instances.count }}
</a>
......@@ -1555,6 +1555,7 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView):
'tags[]': "tags__name__in",
'tags': "tags__name__in", # for search string
'owner': "owner__username",
'template': "template__pk",
}
def get(self, *args, **kwargs):
......
......@@ -203,6 +203,9 @@ class InstanceTemplate(AclBase, VirtualMachineDescModel, TimeStampedModel):
for disk in self.disks.all():
disk.destroy()
def get_running_instances(self):
return Instance.active.filter(template=self, status="RUNNING")
class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
TimeStampedModel):
......
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