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
d3987543
authored
Dec 01, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
occi: basic error handling
parent
37f608b2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
1 deletions
+10
-1
circle/occi/occi.py
+6
-0
circle/occi/views.py
+4
-1
No files found.
circle/occi/occi.py
View file @
d3987543
...
...
@@ -5,6 +5,7 @@ from django.contrib.auth.models import User
from
django.template.loader
import
render_to_string
from
django.utils
import
timezone
from
django.utils.formats
import
date_format
from
django.utils.translation
import
ugettext_noop
from
django_sshkey.models
import
UserKey
...
...
@@ -13,6 +14,7 @@ from storage.models import Disk
from
vm.models
import
Instance
,
InstanceTemplate
,
Lease
,
Interface
from
vm.models.common
import
ARCHITECTURES
from
vm.models.instance
import
ACCESS_METHODS
,
pwgen
from
common.models
import
humanize_exception
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -327,6 +329,10 @@ class Compute(Resource):
operation
=
"deploy"
else
:
action
=
compute_action_to_operation
.
get
(
action_term
)
if
not
method
:
raise
humanize_exception
(
ugettext_noop
(
"Missing 'method' attribute."
),
Exception
())
operation
=
action
.
get
(
method
)
getattr
(
self
.
instance
,
operation
)
.
async
(
user
=
user
)
...
...
circle/occi/views.py
View file @
d3987543
...
...
@@ -7,6 +7,7 @@ from django.utils.decorators import method_decorator
from
django.views.decorators.csrf
import
csrf_exempt
from
django.views.generic
import
View
,
DetailView
from
common.models
import
HumanReadableException
from
firewall.models
import
Vlan
from
vm.models
import
Instance
,
InstanceTemplate
,
Interface
from
storage.models
import
Disk
...
...
@@ -36,8 +37,10 @@ logger = logging.getLogger(__name__)
class
CSRFExemptMixin
(
object
):
@method_decorator
(
csrf_exempt
)
def
dispatch
(
self
,
*
args
,
**
kwargs
):
try
:
return
super
(
CSRFExemptMixin
,
self
)
.
dispatch
(
*
args
,
**
kwargs
)
except
HumanReadableException
as
e
:
return
HttpResponse
(
e
.
get_user_text
(),
status
=
400
)
class
OCCIPostDataAsListMixin
(
object
):
...
...
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