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
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
aff6d0b0
authored
Feb 08, 2013
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
one: reimplement boot token functionality
parent
d23686e0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
7 deletions
+14
-7
cloud/urls.py
+1
-0
one/views.py
+13
-7
No files found.
cloud/urls.py
View file @
aff6d0b0
...
...
@@ -42,4 +42,5 @@ urlpatterns = patterns('',
url
(
r'^ajax/vm/status/(?P<iid>\d+)$'
,
'one.views.vm_ajax_instance_status'
,
name
=
'vm_ajax_instance_status'
),
url
(
r'^language/(?P<lang>[-A-Za-z]+)/$'
,
'school.views.language'
,
name
=
'language'
),
url
(
r'^jsi18n/$'
,
'django.views.i18n.javascript_catalog'
,
js_info_dict
),
url
(
r'^b/(?P<token>.*)/$'
,
'one.views.boot_token'
,
name
=
'boot_token'
),
)
one/views.py
View file @
aff6d0b0
...
...
@@ -127,6 +127,19 @@ def vm_ajax_instance_status(request, iid):
inst
.
update_state
()
return
HttpResponse
(
json
.
dumps
({
'booting'
:
not
inst
.
active_since
,
'state'
:
inst
.
state
}))
def
boot_token
(
request
,
token
):
try
:
id
=
signing
.
loads
(
token
,
salt
=
'activate'
)
except
:
return
HttpResponse
(
"Invalid token."
)
inst
=
get_object_or_404
(
Instance
,
id
=
id
)
if
inst
.
active_since
:
return
HttpResponse
(
"Already booted?"
)
else
:
inst
.
active_since
=
datetime
.
now
()
inst
.
save
()
return
HttpResponse
(
"KTHXBYE"
)
class
VmPortAddView
(
View
):
def
post
(
self
,
request
,
iid
,
*
args
,
**
kwargs
):
try
:
...
...
@@ -217,11 +230,4 @@ def vm_restart(request, iid, *args, **kwargs):
messages
.
error
(
request
,
_
(
'Failed to restart virtual machine.'
))
return
redirect
(
'/'
)
def
vm_active
(
request
,
token
):
id
=
signing
.
loads
(
token
,
salt
=
'activate'
,
max_age
=
300
)
vm
=
get_object_or_404
(
Instance
,
id
=
id
)
vm
.
active_since
=
datetime
.
now
()
vm
.
save
()
return
HttpResponse
(
"Ok."
,
content_type
=
"text/plain"
)
# vim: et sw=4 ai fenc=utf8 smarttab :
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