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
Boxiang Sun
slapos.core
Commits
64a6cf01
Commit
64a6cf01
authored
Sep 13, 2012
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New method to check if an instance can be allocated
parent
c26c10d8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
2 deletions
+65
-2
master/bt5/vifib_slapos_rest_api_v1/DocumentTemplateItem/portal_components/VifibRestAPIV1.py
.../DocumentTemplateItem/portal_components/VifibRestAPIV1.py
+64
-1
master/bt5/vifib_slapos_rest_api_v1/bt/revision
master/bt5/vifib_slapos_rest_api_v1/bt/revision
+1
-1
No files found.
master/bt5/vifib_slapos_rest_api_v1/DocumentTemplateItem/portal_components/VifibRestAPIV1.py
View file @
64a6cf01
...
@@ -343,6 +343,66 @@ class InstancePublisher(GenericPublisher):
...
@@ -343,6 +343,66 @@ class InstancePublisher(GenericPublisher):
self
.
REQUEST
.
response
.
setBody
(
jsonify
({
'status'
:
'processing'
}))
self
.
REQUEST
.
response
.
setBody
(
jsonify
({
'status'
:
'processing'
}))
return
self
.
REQUEST
.
response
return
self
.
REQUEST
.
response
@
requireHeader
({
'Content-Type'
:
'^application/json.*'
})
@
requireJson
(
dict
(
slave
=
bool
,
software_release
=
(
unicode
,
encode_utf8
),
title
=
(
unicode
,
encode_utf8
),
software_type
=
(
unicode
,
encode_utf8
),
parameter
=
(
dict
,
etreeXml
),
sla
=
(
dict
,
etreeXml
),
status
=
(
unicode
,
encode_utf8
),
))
def
__allocable
(
self
):
request_dict
=
{}
if
self
.
jbody
[
'status'
]
not
in
[
'started'
,
'stopped'
,
'destroyed'
]:
self
.
REQUEST
.
response
.
setStatus
(
400
)
self
.
REQUEST
.
response
.
setBody
(
jsonify
(
{
'status'
:
'Status shall be one of: started, stopped, destroyed.'
}))
return
self
.
REQUEST
.
response
try
:
user
=
self
.
restrictedTraverse
(
self
.
user_url
)
user_portal_type
=
user
.
getPortalType
()
if
user_portal_type
==
'Person'
:
pass
elif
user_portal_type
==
'Software Instance'
:
hosting_subscription
=
user
.
getSpecialiseValue
(
portal_type
=
"Hosting Subscription"
)
user
=
hosting_subscription
.
getDestinationSectionValue
(
portal_type
=
"Person"
)
else
:
raise
NotImplementedError
,
"Can not get Person document"
open_order
=
self
.
portal_catalog
.
getResultValue
(
portal_type
=
'Open Sale Order'
,
default_destination_decision_uid
=
user
.
getUid
(),
validation_state
=
'validated'
)
tmp_instance
=
self
.
software_instance_module
.
newContent
(
portal_type
=
"Software Instance"
,
sla_xml
=
self
.
jbody
[
'sla'
],
temp_object
=
1
,
)
result
=
open_order
.
OpenSaleOrder_findPartition
(
self
.
jbody
[
'software_release'
],
self
.
jbody
[
'software_type'
],
(
'Software Instance'
,
'Slave Instance'
)[
int
(
self
.
jbody
[
'slave'
])],
tmp_instance
.
getSlaXmlAsDict
(),
test_mode
=
True
)
except
Exception
:
transaction
.
abort
()
LOG
(
'VifibRestApiV1'
,
ERROR
,
'Problem with person.allocable:'
,
error
=
True
)
self
.
REQUEST
.
response
.
setStatus
(
500
)
self
.
REQUEST
.
response
.
setBody
(
jsonify
({
'error'
:
'There is system issue, please try again later.'
}))
return
self
.
REQUEST
.
response
self
.
REQUEST
.
response
.
setStatus
(
200
)
self
.
REQUEST
.
response
.
setHeader
(
'Cache-Control'
,
'max-age=300, private'
)
self
.
REQUEST
.
response
.
setBody
(
jsonify
({
'result'
:
result
}))
return
self
.
REQUEST
.
response
@
extractDocument
([
'Software Instance'
,
'Slave Instance'
])
@
extractDocument
([
'Software Instance'
,
'Slave Instance'
])
@
supportModifiedSince
(
'document_url'
)
@
supportModifiedSince
(
'document_url'
)
def
__instance_info
(
self
):
def
__instance_info
(
self
):
...
@@ -424,6 +484,9 @@ class InstancePublisher(GenericPublisher):
...
@@ -424,6 +484,9 @@ class InstancePublisher(GenericPublisher):
self
.
__request
()
self
.
__request
()
elif
self
.
REQUEST
[
'REQUEST_METHOD'
]
==
'GET'
:
elif
self
.
REQUEST
[
'REQUEST_METHOD'
]
==
'GET'
:
if
self
.
REQUEST
[
'traverse_subpath'
]:
if
self
.
REQUEST
[
'traverse_subpath'
]:
if
self
.
REQUEST
[
'traverse_subpath'
][
-
1
]
==
'request'
:
self
.
__allocable
()
else
:
self
.
__instance_info
()
self
.
__instance_info
()
else
:
else
:
self
.
__instance_list
()
self
.
__instance_list
()
...
...
master/bt5/vifib_slapos_rest_api_v1/bt/revision
View file @
64a6cf01
17
18
\ No newline at end of file
\ No newline at end of file
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