Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nicolas Wavrant
slapos.core
Commits
fa548541
Commit
fa548541
authored
May 21, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check transmitted json.
parent
f585c831
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
master/product/Vifib/Tool/VifibRestApiV1Tool.py
master/product/Vifib/Tool/VifibRestApiV1Tool.py
+30
-0
No files found.
master/product/Vifib/Tool/VifibRestApiV1Tool.py
View file @
fa548541
...
@@ -448,6 +448,36 @@ class ComputerPublisher(GenericPublisher):
...
@@ -448,6 +448,36 @@ class ComputerPublisher(GenericPublisher):
def
PUT
(
self
):
def
PUT
(
self
):
"""Computer PUT support"""
"""Computer PUT support"""
computer
=
self
.
restrictedTraverse
(
self
.
document_url
)
computer
=
self
.
restrictedTraverse
(
self
.
document_url
)
error_dict
=
{}
def
getErrorDict
(
list_
,
key_list
,
prefix
):
no
=
0
for
dict_
in
list_
:
error_list
=
[]
if
not
isinstance
(
dict_
,
dict
):
error_list
.
append
(
'Not a dict.'
)
else
:
for
k
in
key_list
:
if
k
not
in
dict_
:
error_list
.
append
(
'Missing key "%s".'
%
k
)
elif
not
isinstance
(
dict_
[
k
],
unicode
):
error_list
.
append
(
'Key "%s" is not unicode.'
%
k
)
if
len
(
error_list
)
>
0
:
error_dict
[
'%s_%s'
%
(
prefix
,
no
)]
=
error_list
no
+=
1
return
error_dict
error_dict
=
{}
if
'partition'
in
self
.
jbody
:
error_dict
.
update
(
getErrorDict
(
self
.
jbody
[
'partition'
],
(
'title'
,
'public_ip'
,
'private_ip'
,
'tap_interface'
),
'partition'
))
if
'software'
in
self
.
jbody
:
error_dict
.
update
(
getErrorDict
(
self
.
jbody
[
'software'
],
(
'software_release'
,
'status'
,
'log'
),
'software'
))
if
error_dict
:
self
.
REQUEST
.
response
.
setStatus
(
400
)
self
.
REQUEST
.
response
.
setBody
(
jsonify
(
error_dict
))
return
self
.
REQUEST
.
response
try
:
try
:
computer
.
Computer_updateFromJson
(
self
.
jbody
)
computer
.
Computer_updateFromJson
(
self
.
jbody
)
except
Exception
:
except
Exception
:
...
...
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