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
Łukasz Nowak
slapos.core
Commits
1c53c728
Commit
1c53c728
authored
Sep 23, 2014
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[slaptool] Add getComputerPartitionList and getComputerPartitionInformation methods.
parent
40bc7f38
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
87 additions
and
11 deletions
+87
-11
master/product/Vifib/Tool/SlapTool.py
master/product/Vifib/Tool/SlapTool.py
+87
-11
No files found.
master/product/Vifib/Tool/SlapTool.py
View file @
1c53c728
...
...
@@ -425,6 +425,82 @@ class SlapTool(BaseTool):
for
software_release
in
software_release_list
if
software_release
.
getValidationState
()
==
'published'
])
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getComputerPartitionList'
)
def
getComputerPartitionList
(
self
):
"""
Return the list of requested instances.
Actually returns the list of Hosting Subscription owned by user.
"""
# XXX cache
# XXX software_instance.getComputerPartitionList support
from
Products.ZSQLCatalog.SQLCatalog
import
NegatedQuery
,
Query
portal
=
context
.
getPortalObject
()
person_uid
=
portal
.
ERP5Site_getPropertyFromAuthenticatedMemberPersonValue
(
'uid'
)
hosting_subscription_list
=
portal
.
portal_catalog
(
portal_type
=
"Hosting Subscription"
,
default_destination_section_uid
=
person_uid
,
validation_state
=
'validated'
)
# XXX Shouldn't we just return list of slapos.slap.Partition ?
hosting_subscription_list
=
[{
'partition_reference'
:
hosting_subscription
.
getTitle
(),
'software_release'
:
hosting_subscription
.
getUrl
(),
}]
return
xml_marshaller
.
xml_marshaller
.
dumps
(
hosting_subscription_list
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getComputerPartitionInformation'
)
def
getComputerPartitionInformation
(
self
,
partition_reference
):
"""
Returns XML representation of corresponding partition with HTTP code 200 OK.
"""
# requested as root, so done by human
person
=
portal
.
ERP5Site_getAuthenticatedMemberPersonValue
()
key
=
'_'
.
join
([
person
.
getRelativeUrl
(),
partition_reference
])
value
=
dict
(
hash
=
str
(
kw
)
)
last_data
=
self
.
_getLastData
(
key
)
if
last_data
is
not
None
and
type
(
last_data
)
==
type
({}):
requested_software_instance
=
portal
.
restrictedTraverse
(
last_data
.
get
(
'request_instance'
),
None
)
if
last_data
is
None
or
type
(
last_data
)
!=
type
(
value
)
or
\
last_data
.
get
(
'hash'
)
!=
value
[
'hash'
]
or
\
requested_software_instance
is
None
:
person
.
requestSoftwareInstance
(
**
kw
)
requested_software_instance
=
self
.
REQUEST
.
get
(
'request_instance'
)
if
requested_software_instance
is
not
None
:
value
[
'request_instance'
]
=
requested_software_instance
\
.
getRelativeUrl
()
self
.
_storeLastData
(
key
,
value
)
if
requested_software_instance
is
None
:
raise
SoftwareInstanceNotReady
else
:
if
not
requested_software_instance
.
getAggregate
(
portal_type
=
"Computer Partition"
):
raise
SoftwareInstanceNotReady
else
:
parameter_dict
=
self
.
_getSoftwareInstanceAsParameterDict
(
requested_software_instance
)
# software instance has to define an xml parameter
xml
=
self
.
_instanceXmlToDict
(
parameter_dict
.
pop
(
'xml'
))
connection_xml
=
self
.
_instanceXmlToDict
(
parameter_dict
.
pop
(
'connection_xml'
))
filter_xml
=
self
.
_instanceXmlToDict
(
parameter_dict
.
pop
(
'filter_xml'
))
instance_guid
=
parameter_dict
.
pop
(
'instance_guid'
)
software_instance
=
SoftwareInstance
(
**
parameter_dict
)
software_instance
.
_parameter_dict
=
xml
software_instance
.
_connection_dict
=
connection_xml
software_instance
.
_filter_dict
=
filter_xml
software_instance
.
_requested_state
=
state
software_instance
.
_instance_guid
=
instance_guid
return
xml_marshaller
.
xml_marshaller
.
dumps
(
software_instance
)
####################################################
# Public POST methods
...
...
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