Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
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
a627c311
authored
Jan 28, 2013
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
one: add stop/resume and poweroff/restart views
parent
08b1192a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
0 deletions
+43
-0
cloud/urls.py
+4
-0
one/views.py
+39
-0
No files found.
cloud/urls.py
View file @
a627c311
...
...
@@ -16,6 +16,10 @@ urlpatterns = patterns('',
url
(
r'^vm/new/(?P<template>\d+)/$'
,
'one.views.vm_new'
,
name
=
'vm_new'
),
url
(
r'^vm/show/(?P<iid>\d+)/$'
,
'one.views.vm_show'
,
name
=
'vm_show'
),
url
(
r'^vm/delete/(?P<iid>\d+)/$'
,
'one.views.vm_delete'
,
name
=
'vm_delete'
),
url
(
r'^vm/stop/(?P<iid>\d+)/$'
,
'one.views.vm_stop'
,
name
=
'vm_stop'
),
url
(
r'^vm/resume/(?P<iid>\d+)/$'
,
'one.views.vm_resume'
,
name
=
'vm_resume'
),
url
(
r'^vm/power_off/(?P<iid>\d+)/$'
,
'one.views.vm_power_off'
,
name
=
'vm_power_off'
),
url
(
r'^vm/restart/(?P<iid>\d+)/$'
,
'one.views.vm_restart'
,
name
=
'vm_restart'
),
url
(
r'^vm/port_add/(?P<iid>\d+)/$'
,
'one.views.vm_port_add'
,
name
=
'vm_port_add'
),
url
(
r'^vm/port_del/(?P<iid>\d+)/(?P<proto>tcp|udp)/(?P<public>\d+)/$'
,
'one.views.vm_port_del'
,
name
=
'vm_port_del'
),
url
(
r'^reload/$'
,
'firewall.views.reload_firewall'
,
name
=
'reload_firewall'
),
...
...
one/views.py
View file @
a627c311
...
...
@@ -162,6 +162,45 @@ class VmDeleteView(View):
vm_delete
=
login_required
(
VmDeleteView
.
as_view
())
@login_required
@require_POST
def
vm_stop
(
request
,
iid
,
*
args
,
**
kwargs
):
try
:
get_object_or_404
(
Instance
,
id
=
iid
,
owner
=
request
.
user
)
.
stop
()
messages
.
success
(
request
,
_
(
'Virtual machine is successfully stopped.'
))
except
:
messages
.
error
(
request
,
_
(
'Failed to stop virtual machine.'
))
return
redirect
(
'/'
)
@login_required
@require_POST
def
vm_resume
(
request
,
iid
,
*
args
,
**
kwargs
):
try
:
get_object_or_404
(
Instance
,
id
=
iid
,
owner
=
request
.
user
)
.
resume
()
messages
.
success
(
request
,
_
(
'Virtual machine is successfully resumed.'
))
except
:
messages
.
error
(
request
,
_
(
'Failed to resume virtual machine.'
))
return
redirect
(
'/'
)
@login_required
@require_POST
def
vm_power_off
(
request
,
iid
,
*
args
,
**
kwargs
):
try
:
get_object_or_404
(
Instance
,
id
=
iid
,
owner
=
request
.
user
)
.
poweroff
()
messages
.
success
(
request
,
_
(
'Virtual machine is successfully powered off.'
))
except
:
messages
.
error
(
request
,
_
(
'Failed to power off virtual machine.'
))
return
redirect
(
'/'
)
@login_required
@require_POST
def
vm_restart
(
request
,
iid
,
*
args
,
**
kwargs
):
try
:
get_object_or_404
(
Instance
,
id
=
iid
,
owner
=
request
.
user
)
.
restart
()
messages
.
success
(
request
,
_
(
'Virtual machine is successfully restarted.'
))
except
:
messages
.
error
(
request
,
_
(
'Failed to restart virtual machine.'
))
return
redirect
(
'/'
)
def
vm_active
(
request
,
token
):
id
=
signing
.
loads
(
token
,
salt
=
'activate'
,
max_age
=
300
)
...
...
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