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
6a34166d
authored
Aug 27, 2015
by
Nyíri Tamás
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Graph for templates about number of running instances
closes #420
parent
61eae89b
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
4 deletions
+51
-4
circle/dashboard/templates/dashboard/template-edit.html
+14
-0
circle/dashboard/urls.py
+5
-1
circle/dashboard/views/graph.py
+23
-1
circle/dashboard/views/template.py
+5
-2
circle/vm/models/instance.py
+4
-0
No files found.
circle/dashboard/templates/dashboard/template-edit.html
View file @
6a34166d
...
...
@@ -166,6 +166,20 @@
</ul>
</div>
</div>
{% if show_graph %}
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<div
class=
"pull-right graph-buttons"
>
{% include "dashboard/_graph-time-buttons.html" %}
</div>
<h3
class=
"no-margin"
><i
class=
"fa fa-area-chart"
></i>
{% trans "Graphs" %}
</h3>
</div>
<div
class=
"text-center graph-images"
>
<img
src=
"{% url "
dashboard
.
views
.
template-graph
"
object
.
pk
"
instances
"
graph_time
%}"
/>
</div>
</div>
{% endif %}
</div>
<!-- .col-md-4 -->
</div>
<!-- .row -->
...
...
circle/dashboard/urls.py
View file @
6a34166d
...
...
@@ -47,7 +47,7 @@ from .views import (
LeaseAclUpdateView
,
toggle_template_tutorial
,
ClientCheck
,
TokenLogin
,
VmGraphView
,
NodeGraphView
,
NodeListGraphView
,
VmGraphView
,
NodeGraphView
,
NodeListGraphView
,
TemplateGraphView
,
TransferInstanceOwnershipView
,
TransferInstanceOwnershipConfirmView
,
TransferTemplateOwnershipView
,
TransferTemplateOwnershipConfirmView
,
OpenSearchDescriptionView
,
...
...
@@ -152,6 +152,10 @@ urlpatterns = patterns(
r'(?P<time>[0-9]{1,2}[hdwy])$'
),
NodeListGraphView
.
as_view
(),
name
=
'dashboard.views.node-list-graph'
),
url
((
r'^template/(?P<pk>\d+)/graph/(?P<metric>[a-z]+)/'
r'(?P<time>[0-9]{1,2}[hdwy])$'
),
TemplateGraphView
.
as_view
(),
name
=
'dashboard.views.template-graph'
),
url
(
r'^group/(?P<pk>\d+)/$'
,
GroupDetailView
.
as_view
(),
name
=
'dashboard.views.group-detail'
),
url
(
r'^group/(?P<pk>\d+)/update/$'
,
GroupProfileUpdate
.
as_view
(),
...
...
circle/dashboard/views/graph.py
View file @
6a34166d
...
...
@@ -28,7 +28,7 @@ from django.views.generic import View
from
braces.views
import
LoginRequiredMixin
from
vm.models
import
Instance
,
Node
from
vm.models
import
Instance
,
Node
,
InstanceTemplate
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -152,6 +152,28 @@ class NodeGraphView(GraphViewBase):
return
self
.
model
.
objects
.
get
(
id
=
pk
)
class
TemplateGraphView
(
GraphViewBase
):
model
=
InstanceTemplate
base
=
Metric
def
get_object
(
self
,
request
,
pk
):
instance
=
super
(
TemplateGraphView
,
self
)
.
get_object
(
request
,
pk
)
if
not
instance
.
has_level
(
request
.
user
,
'operator'
):
raise
PermissionDenied
()
return
instance
class
TemplateVms
(
object
):
metric_name
=
"instances.running"
title
=
_
(
"Instance count"
)
label
=
_
(
"instance count"
)
def
get_minmax
(
self
):
return
(
0
,
None
)
register_graph
(
TemplateVms
,
'instances'
,
TemplateGraphView
)
class
NodeListGraphView
(
GraphViewBase
):
model
=
Node
base
=
Metric
...
...
circle/dashboard/views/template.py
View file @
6a34166d
...
...
@@ -47,7 +47,8 @@ from ..tables import TemplateListTable, LeaseListTable
from
.util
import
(
AclUpdateView
,
FilterMixin
,
TransferOwnershipConfirmView
,
TransferOwnershipView
,
DeleteViewBase
DeleteViewBase
,
GraphMixin
)
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -258,7 +259,8 @@ class TemplateDelete(DeleteViewBase):
object
.
delete
()
class
TemplateDetail
(
LoginRequiredMixin
,
SuccessMessageMixin
,
UpdateView
):
class
TemplateDetail
(
LoginRequiredMixin
,
GraphMixin
,
SuccessMessageMixin
,
UpdateView
):
model
=
InstanceTemplate
template_name
=
"dashboard/template-edit.html"
form_class
=
TemplateForm
...
...
@@ -300,6 +302,7 @@ class TemplateDetail(LoginRequiredMixin, SuccessMessageMixin, UpdateView):
context
[
'is_owner'
]
=
obj
.
has_level
(
self
.
request
.
user
,
'owner'
)
context
[
'aclform'
]
=
AclUserOrGroupAddForm
()
context
[
'parent'
]
=
obj
.
parent
context
[
'show_graph'
]
=
obj
.
has_level
(
self
.
request
.
user
,
'operator'
)
return
context
def
get_success_url
(
self
):
...
...
circle/vm/models/instance.py
View file @
6a34166d
...
...
@@ -200,6 +200,10 @@ class InstanceTemplate(AclBase, VirtualMachineDescModel, TimeStampedModel):
def
get_running_instances
(
self
):
return
Instance
.
active
.
filter
(
template
=
self
,
status
=
"RUNNING"
)
@property
def
metric_prefix
(
self
):
return
'template.
%
d'
%
self
.
pk
class
Instance
(
AclBase
,
VirtualMachineDescModel
,
StatusModel
,
OperatedMixin
,
TimeStampedModel
):
...
...
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