Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
c2c3913d
authored
May 20, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add screenshot
parent
31f77d82
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
73 additions
and
2 deletions
+73
-2
circle/dashboard/static/dashboard/dashboard.css
+9
-0
circle/dashboard/static/dashboard/vm-details.js
+13
-0
circle/dashboard/templates/dashboard/vm-detail/console.html
+10
-2
circle/dashboard/urls.py
+3
-0
circle/dashboard/views.py
+13
-0
circle/vm/models/instance.py
+6
-0
circle/vm/operations.py
+19
-0
No files found.
circle/dashboard/static/dashboard/dashboard.css
View file @
c2c3913d
...
...
@@ -654,3 +654,12 @@ textarea[name="list-new-namelist"] {
80
%
{
-webkit-transform
:
scale
(
1
);
}
100
%
{
-webkit-transform
:
scale
(
1
);
}
}
.btn-toolbar
{
margin-bottom
:
5px
;
}
#vm-console-screenshot
{
display
:
none
;
}
circle/dashboard/static/dashboard/vm-details.js
View file @
c2c3913d
...
...
@@ -264,6 +264,19 @@ $(function() {
return
false
;
});
// screenshot
$
(
"#getScreenshotButton"
).
click
(
function
()
{
var
vm
=
$
(
this
).
data
(
"vm-pk"
);
var
ct
=
$
(
"#vm-console-screenshot"
);
ct
.
slideDown
();
var
img
=
$
(
"img"
,
ct
).
prop
(
"src"
,
'/dashboard/vm/'
+
vm
+
'/screenshot/'
);
});
// screenshot close
$
(
"#vm-console-screenshot button"
).
click
(
function
()
{
$
(
this
).
parent
(
"div"
).
slideUp
();
});
});
...
...
circle/dashboard/templates/dashboard/vm-detail/console.html
View file @
c2c3913d
{% load i18n %}
<div
class=
"btn-toolbar"
>
<button
id=
"sendCtrlAltDelButton"
class=
"btn btn-danger small"
>
{% trans "Send Ctrl+Alt+Del" %}
</button>
<button
id=
"sendPasswordButton"
class=
"btn btn-default small"
>
{% trans "Type password" %}
</button>
<button
id=
"sendCtrlAltDelButton"
class=
"btn btn-danger btn-sm"
>
{% trans "Send Ctrl+Alt+Del" %}
</button>
<button
id=
"sendPasswordButton"
class=
"btn btn-default btn-sm"
>
{% trans "Type password" %}
</button>
<button
id=
"getScreenshotButton"
class=
"btn btn-info btn-sm pull-right"
data-vm-pk=
"{{ instance.pk }}"
><i
class=
"icon-picture"
></i>
{% trans "Screenshot" %}
</button>
</div>
<div
class=
"alert alert-info"
id=
"noVNC_status"
>
</div>
<div
id=
"vm-console-screenshot"
>
<button
class=
"btn btn-danger btn-sm pull-right"
>
Close
</button>
<h3>
{% trans "Screenshot" %}
</h3>
<img
/>
<hr
/>
</div>
<canvas
id=
"noVNC_canvas"
width=
"640px"
height=
"20px"
>
Canvas not supported.
</canvas>
...
...
circle/dashboard/urls.py
View file @
c2c3913d
...
...
@@ -33,6 +33,7 @@ from .views import (
GroupRemoveAclUserView
,
GroupRemoveAclGroupView
,
GroupRemoveUserView
,
GroupCreate
,
TemplateChoose
,
get_vm_screenshot
)
urlpatterns
=
patterns
(
...
...
@@ -83,6 +84,8 @@ urlpatterns = patterns(
name
=
'dashboard.views.vm-renew'
),
url
(
r'^vm/activity/(?P<pk>\d+)/$'
,
InstanceActivityDetail
.
as_view
(),
name
=
'dashboard.views.vm-activity'
),
url
(
r'^vm/(?P<pk>\d+)/screenshot/$'
,
get_vm_screenshot
,
name
=
'dashboard.views.vm-get-screenshot'
),
url
(
r'^node/list/$'
,
NodeList
.
as_view
(),
name
=
'dashboard.views.node-list'
),
url
(
r'^node/(?P<pk>\d+)/$'
,
NodeDetailView
.
as_view
(),
...
...
circle/dashboard/views.py
View file @
c2c3913d
...
...
@@ -2590,3 +2590,16 @@ class InterfaceDeleteView(DeleteView):
if
redirect
:
return
redirect
self
.
object
.
instance
.
get_absolute_url
()
@require_GET
def
get_vm_screenshot
(
request
,
pk
):
instance
=
get_object_or_404
(
Instance
,
pk
=
pk
)
try
:
image
=
instance
.
screenshot
(
instance
=
instance
,
user
=
request
.
user
)
.
getvalue
()
except
:
# TODO handle this better
raise
Http404
()
return
HttpResponse
(
image
,
mimetype
=
"image/png"
)
circle/vm/models/instance.py
View file @
c2c3913d
...
...
@@ -913,3 +913,9 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
i
.
is_abortable_for_user
=
partial
(
i
.
is_abortable_for
,
user
=
user
)
return
acts
def
get_screenshot
(
self
,
timeout
=
5
):
queue_name
=
self
.
get_remote_queue_name
(
'vm'
)
return
vm_tasks
.
screenshot
.
apply_async
(
args
=
[
self
.
vm_name
],
queue
=
queue_name
)
.
get
(
timeout
=
timeout
)
circle/vm/operations.py
View file @
c2c3913d
...
...
@@ -534,3 +534,22 @@ class FlushOperation(NodeOperation):
register_operation
(
FlushOperation
)
class
ScreenshotOperation
(
InstanceOperation
):
activity_code_suffix
=
'screenshot'
id
=
'screenshot'
name
=
_
(
"screenshot"
)
description
=
_
(
"Get screenshot"
)
acl_level
=
"owner"
def
check_precond
(
self
):
super
(
ScreenshotOperation
,
self
)
.
check_precond
()
if
self
.
instance
.
status
not
in
[
'RUNNING'
]:
raise
self
.
instance
.
WrongStateError
(
self
.
instance
)
def
_operation
(
self
,
instance
,
user
):
return
self
.
instance
.
get_screenshot
(
timeout
=
20
)
register_operation
(
ScreenshotOperation
)
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