Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
db39311c
authored
Mar 15, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: improve node list performance
parent
36538eb0
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
3 deletions
+8
-3
circle/dashboard/templates/dashboard/node-list/column-vm.html
+1
-1
circle/dashboard/views.py
+5
-1
circle/vm/models/node.py
+2
-1
No files found.
circle/dashboard/templates/dashboard/node-list/column-vm.html
View file @
db39311c
{% load i18n %}
{% load i18n %}
<div
id=
"node-list-column-vm"
>
<div
id=
"node-list-column-vm"
>
<a
class=
"real-link"
href=
"{% url "
dashboard
.
views
.
node-detail
"
pk=
record.pk
%}#
virtualmachines
"
>
{{
record.instance_set.count
}}
</a>
<a
class=
"real-link"
href=
"{% url "
dashboard
.
views
.
node-detail
"
pk=
record.pk
%}#
virtualmachines
"
>
{{
value
}}
</a>
</div>
</div>
circle/dashboard/views.py
View file @
db39311c
...
@@ -14,6 +14,7 @@ from django.core.exceptions import (
...
@@ -14,6 +14,7 @@ from django.core.exceptions import (
)
)
from
django.core
import
signing
from
django.core
import
signing
from
django.core.urlresolvers
import
reverse
,
reverse_lazy
from
django.core.urlresolvers
import
reverse
,
reverse_lazy
from
django.db.models
import
Count
from
django.http
import
HttpResponse
,
HttpResponseRedirect
,
Http404
from
django.http
import
HttpResponse
,
HttpResponseRedirect
,
Http404
from
django.shortcuts
import
redirect
,
render
,
get_object_or_404
from
django.shortcuts
import
redirect
,
render
,
get_object_or_404
from
django.views.decorators.http
import
require_GET
from
django.views.decorators.http
import
require_GET
...
@@ -921,10 +922,13 @@ class VmList(LoginRequiredMixin, SingleTableView):
...
@@ -921,10 +922,13 @@ class VmList(LoginRequiredMixin, SingleTableView):
class
NodeList
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SingleTableView
):
class
NodeList
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SingleTableView
):
template_name
=
"dashboard/node-list.html"
template_name
=
"dashboard/node-list.html"
model
=
Node
table_class
=
NodeListTable
table_class
=
NodeListTable
table_pagination
=
False
table_pagination
=
False
def
get_queryset
(
self
):
return
Node
.
objects
.
annotate
(
number_of_VMs
=
Count
(
'instance_set'
))
.
select_related
(
'host'
)
class
GroupList
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SingleTableView
):
class
GroupList
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SingleTableView
):
template_name
=
"dashboard/group-list.html"
template_name
=
"dashboard/group-list.html"
...
...
circle/vm/models/node.py
View file @
db39311c
...
@@ -305,7 +305,8 @@ class Node(TimeStampedModel):
...
@@ -305,7 +305,8 @@ class Node(TimeStampedModel):
@classmethod
@classmethod
def
get_state_count
(
cls
,
online
,
enabled
):
def
get_state_count
(
cls
,
online
,
enabled
):
return
len
([
1
for
i
in
cls
.
objects
.
filter
(
enabled
=
enabled
)
.
all
()
return
len
([
1
for
i
in
cls
.
objects
.
filter
(
enabled
=
enabled
)
.
select_related
(
'host'
)
if
i
.
online
==
online
])
if
i
.
online
==
online
])
@permalink
@permalink
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment