Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
006ce344
authored
Oct 29, 2013
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: add context support (BootUrl)
parent
aea8a13b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
1 deletions
+33
-1
circle/circle/urls.py
+1
-0
circle/vm/models.py
+2
-0
circle/vm/urls.py
+9
-0
circle/vm/views.py
+21
-1
No files found.
circle/circle/urls.py
View file @
006ce344
...
@@ -17,4 +17,5 @@ urlpatterns = patterns(
...
@@ -17,4 +17,5 @@ urlpatterns = patterns(
url
(
r'^admin/'
,
include
(
admin
.
site
.
urls
)),
url
(
r'^admin/'
,
include
(
admin
.
site
.
urls
)),
url
(
r'^network/'
,
include
(
'network.urls'
)),
url
(
r'^network/'
,
include
(
'network.urls'
)),
url
(
r'^dashboard/'
,
include
(
'dashboard.urls'
)),
url
(
r'^dashboard/'
,
include
(
'dashboard.urls'
)),
url
(
r'^vm-api/'
,
include
(
'vm.urls'
)),
)
)
circle/vm/models.py
View file @
006ce344
...
@@ -17,6 +17,7 @@ from .tasks import local_tasks, vm_tasks, net_tasks
...
@@ -17,6 +17,7 @@ from .tasks import local_tasks, vm_tasks, net_tasks
from
common.models
import
ActivityModel
,
activitycontextimpl
from
common.models
import
ActivityModel
,
activitycontextimpl
from
firewall.models
import
Vlan
,
Host
from
firewall.models
import
Vlan
,
Host
from
storage.models
import
Disk
from
storage.models
import
Disk
from
django.core
import
signing
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -510,6 +511,7 @@ class Instance(VirtualMachineDescModel, TimeStampedModel):
...
@@ -510,6 +511,7 @@ class Instance(VirtualMachineDescModel, TimeStampedModel):
'passwd'
:
''
,
'passwd'
:
''
,
'port'
:
self
.
vnc_port
'port'
:
self
.
vnc_port
},
},
'boot_token'
:
signing
.
dumps
(
self
.
id
,
salt
=
'activate'
),
'raw_data'
:
""
if
not
self
.
raw_data
else
self
.
raw_data
'raw_data'
:
""
if
not
self
.
raw_data
else
self
.
raw_data
}
}
...
...
circle/vm/urls.py
0 → 100644
View file @
006ce344
from
django.conf.urls
import
patterns
,
url
from
.views
import
BootUrl
urlpatterns
=
patterns
(
''
,
url
(
r'^b/(?P<token>.*)/$'
,
BootUrl
.
as_view
()),
)
circle/vm/views.py
View file @
006ce344
# Create your views here.
from
django.views.generic.base
import
View
from
django.http
import
HttpResponse
from
django.core
import
signing
from
django.shortcuts
import
get_object_or_404
from
vm.models
import
Instance
from
datetime
import
datetime
class
BootUrl
(
View
):
def
get
(
self
,
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"
)
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