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
c3dd4099
authored
Nov 12, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
occi: delete VM
parent
78c30ada
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
1 deletions
+17
-1
circle/occi/occi.py
+5
-0
circle/occi/urls.py
+1
-1
circle/occi/views.py
+11
-0
No files found.
circle/occi/occi.py
View file @
c3dd4099
...
...
@@ -306,6 +306,11 @@ class Compute(Resource):
user
=
User
.
objects
.
get
(
username
=
"test"
)
getattr
(
self
.
instance
,
operation
)
.
async
(
user
=
user
)
def
delete
(
self
):
# TODO
user
=
User
.
objects
.
get
(
username
=
"test"
)
self
.
instance
.
destroy
(
user
=
user
)
class
OsTemplate
(
Mixin
):
def
__init__
(
self
,
template
):
...
...
circle/occi/urls.py
View file @
c3dd4099
...
...
@@ -28,7 +28,7 @@ urlpatterns = patterns(
url
(
r'^-/$'
,
QueryInterface
.
as_view
(),
name
=
"occi.query"
),
url
(
r'^compute/$'
,
ComputeInterface
.
as_view
(),
name
=
"occi.compute"
),
url
(
r'^os_tpl/$'
,
OsTplInterface
.
as_view
(),
name
=
"occi.os_tpl"
),
url
(
r'^vm/(?P<pk>\d+)/$'
,
VmInterface
.
as_view
(),
name
=
"occi.vm"
),
url
(
r'^vm/(?P<pk>\d+)/
?
$'
,
VmInterface
.
as_view
(),
name
=
"occi.vm"
),
url
(
r'^storage/$'
,
StorageInterface
.
as_view
(),
name
=
"occi.storage"
),
url
(
r'^disk/(?P<pk>\d+)/$'
,
DiskInterface
.
as_view
(),
name
=
"occi.disk"
),
...
...
circle/occi/views.py
View file @
c3dd4099
from
django.http
import
HttpResponse
,
Http404
from
django.shortcuts
import
get_object_or_404
from
django.utils.decorators
import
method_decorator
from
django.views.decorators.csrf
import
csrf_exempt
from
django.views.generic
import
View
,
DetailView
...
...
@@ -97,6 +98,10 @@ class ComputeInterface(View):
class
VmInterface
(
DetailView
):
model
=
Instance
def
get_object
(
self
):
return
get_object_or_404
(
Instance
.
objects
.
filter
(
destroyed_at
=
None
),
pk
=
self
.
kwargs
[
'pk'
])
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
vm
=
self
.
get_object
()
c
=
Compute
(
instance
=
vm
)
...
...
@@ -113,6 +118,12 @@ class VmInterface(DetailView):
Compute
(
instance
=
vm
)
.
trigger_action
(
data
)
return
HttpResponse
()
def
delete
(
self
,
request
,
*
args
,
**
kwargs
):
vm
=
self
.
get_object
()
Compute
(
instance
=
vm
)
.
delete
()
return
HttpResponse
()
@method_decorator
(
csrf_exempt
)
# decorator on post method doesn't work
def
dispatch
(
self
,
*
args
,
**
kwargs
):
return
super
(
VmInterface
,
self
)
.
dispatch
(
*
args
,
**
kwargs
)
...
...
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