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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
slapos.core
Commits
72e0b0e8
Commit
72e0b0e8
authored
Nov 13, 2013
by
Cédric de Saint Martin
Committed by
Gabriel Monnerat
Jan 13, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for getSoftwareReleaseListFromSoftwareProduct() SLAP method.
parent
0353b627
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
145 additions
and
1 deletion
+145
-1
CHANGES.txt
CHANGES.txt
+1
-0
master/bt5/slapos_slap_tool/TestTemplateItem/testSlapOSSlapTool.py
...5/slapos_slap_tool/TestTemplateItem/testSlapOSSlapTool.py
+83
-0
master/bt5/slapos_slap_tool/bt/revision
master/bt5/slapos_slap_tool/bt/revision
+1
-1
master/product/SlapOS/tests/testSlapOSMixin.py
master/product/SlapOS/tests/testSlapOSMixin.py
+22
-0
master/product/Vifib/Tool/SlapTool.py
master/product/Vifib/Tool/SlapTool.py
+28
-0
slapos/slap/interface/slap.py
slapos/slap/interface/slap.py
+5
-0
slapos/slap/slap.py
slapos/slap/slap.py
+5
-0
No files found.
CHANGES.txt
View file @
72e0b0e8
...
...
@@ -13,6 +13,7 @@ New features:
* Register: support for one-time authentication token. [Marco Mariani]
* New command: "slapos configure client" [Marco Mariani]
* add new "root_check" option in slapos configuration file (true by default) allowing to bypass "am I root" checks in slapos. [Cedric de Saint Martin]
* Add support for getSoftwareReleaseListFromSoftwareProduct() SLAP method. [Cedric de Saint Martin]
Major Improvements:
...
...
master/bt5/slapos_slap_tool/TestTemplateItem/testSlapOSSlapTool.py
View file @
72e0b0e8
...
...
@@ -1672,6 +1672,89 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
self
.
assertEqual
(
expected_xml
,
got_xml
,
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
def
test_getSoftwareReleaseListFromSoftwareProduct
(
self
):
new_id
=
self
.
generateNewId
()
software_product
=
self
.
_makeSoftwareProduct
(
new_id
)
# 2 published software releases
software_release1
=
self
.
_makeSoftwareRelease
(
new_id
)
software_release2
=
self
.
_makeSoftwareRelease
(
self
.
generateNewId
())
software_release1
.
publish
()
software_release2
.
publish
()
# 1 released software release, should not appear
software_release3
=
self
.
_makeSoftwareRelease
(
new_id
)
self
.
assertTrue
(
software_release3
.
getValidationState
()
==
'released'
)
software_release1
.
edit
(
aggregate_value
=
software_product
.
getRelativeUrl
(),
url_string
=
'http://example.org/1.cfg'
)
software_release2
.
edit
(
aggregate_value
=
software_product
.
getRelativeUrl
(),
url_string
=
'http://example.org/2.cfg'
)
software_release3
.
edit
(
aggregate_value
=
software_product
.
getRelativeUrl
(),
url_string
=
'http://example.org/3.cfg'
)
self
.
tic
()
response
=
self
.
portal_slap
.
getSoftwareReleaseListFromSoftwareProduct
(
software_product
.
getReference
())
# check returned XML
xml_fp
=
StringIO
.
StringIO
()
xml
.
dom
.
ext
.
PrettyPrint
(
xml
.
dom
.
ext
.
reader
.
Sax
.
FromXml
(
response
),
stream
=
xml_fp
)
xml_fp
.
seek
(
0
)
got_xml
=
xml_fp
.
read
()
expected_xml
=
"""
\
<?xml version='1.0' encoding='UTF-8'?>
<marshal>
<list id='i2'>
<string>%s</string>
<string>%s</string>
</list>
</marshal>
"""
%
(
software_release2
.
getUrlString
(),
software_release1
.
getUrlString
())
self
.
assertEqual
(
expected_xml
,
got_xml
,
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
def
test_getSoftwareReleaseListFromSoftwareProduct_emptySoftwareProduct
(
self
):
new_id
=
self
.
generateNewId
()
software_product
=
self
.
_makeSoftwareProduct
(
new_id
)
response
=
self
.
portal_slap
.
getSoftwareReleaseListFromSoftwareProduct
(
software_product
.
getReference
())
# check returned XML
xml_fp
=
StringIO
.
StringIO
()
xml
.
dom
.
ext
.
PrettyPrint
(
xml
.
dom
.
ext
.
reader
.
Sax
.
FromXml
(
response
),
stream
=
xml_fp
)
xml_fp
.
seek
(
0
)
got_xml
=
xml_fp
.
read
()
expected_xml
=
"""
\
<?xml version='1.0' encoding='UTF-8'?>
<marshal>
<list id='i2'/>
</marshal>
"""
self
.
assertEqual
(
expected_xml
,
got_xml
,
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
def
test_getSoftwareReleaseListFromSoftwareProduct_NoSoftwareProduct
(
self
):
response
=
self
.
portal_slap
.
getSoftwareReleaseListFromSoftwareProduct
(
'Can I has a nonexistent software product?'
)
# check returned XML
xml_fp
=
StringIO
.
StringIO
()
xml
.
dom
.
ext
.
PrettyPrint
(
xml
.
dom
.
ext
.
reader
.
Sax
.
FromXml
(
response
),
stream
=
xml_fp
)
xml_fp
.
seek
(
0
)
got_xml
=
xml_fp
.
read
()
expected_xml
=
"""
\
<?xml version='1.0' encoding='UTF-8'?>
<marshal>
<list id='i2'/>
</marshal>
"""
self
.
assertEqual
(
expected_xml
,
got_xml
,
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
class
TestSlapOSSlapToolPersonAccess
(
TestSlapOSSlapToolMixin
):
def
afterSetUp
(
self
):
...
...
master/bt5/slapos_slap_tool/bt/revision
View file @
72e0b0e8
3
2
3
3
master/product/SlapOS/tests/testSlapOSMixin.py
View file @
72e0b0e8
...
...
@@ -491,6 +491,28 @@ class testSlapOSMixin(ERP5TypeTestCase):
self
.
tic
()
self
.
_cleaupREQUEST
()
def
_makeSoftwareProduct
(
self
,
new_id
):
software_product
=
self
.
portal
.
software_product_module
\
.
template_software_product
.
Base_createCloneDocument
(
batch_mode
=
1
)
software_product
.
edit
(
reference
=
'TESTSOFTPROD-%s'
%
new_id
,
title
=
'Test software product %s'
%
new_id
)
software_product
.
publish
()
return
software_product
def
_makeSoftwareRelease
(
self
,
new_id
):
software_release
=
self
.
portal
.
software_release_module
\
.
template_software_release
.
Base_createCloneDocument
(
batch_mode
=
1
)
software_release
.
edit
(
url_string
=
self
.
generateNewSoftwareReleaseUrl
(),
reference
=
'TESTSOFTRELS-%s'
%
new_id
,
title
=
'Start requested for %s'
%
new_id
)
software_release
.
release
()
return
software_release
def
_cleaupREQUEST
(
self
):
self
.
portal
.
REQUEST
[
'request_instance'
]
=
None
self
.
portal
.
REQUEST
.
headers
=
{}
...
...
master/product/Vifib/Tool/SlapTool.py
View file @
72e0b0e8
...
...
@@ -353,6 +353,34 @@ class SlapTool(BaseTool):
computer
=
_assertACI
(
computer
)
return
self
.
_getAccessStatus
(
computer_id
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getSoftwareReleaseListFromSoftwareProduct'
)
def
getSoftwareReleaseListFromSoftwareProduct
(
self
,
software_product_reference
):
"""
Get the list of published software releases from a given software product,
sorted by descending age (latest first).
"""
software_product_list
=
self
.
getPortalObject
().
portal_catalog
.
unrestrictedSearchResults
(
portal_type
=
'Software Product'
,
reference
=
software_product_reference
,
validation_state
=
'published'
)
if
len
(
software_product_list
)
is
0
:
return
xml_marshaller
.
xml_marshaller
.
dumps
([])
if
len
(
software_product_list
)
>
1
:
raise
NotImplementedError
(
'Several Software Product with the same title.'
)
software_release_list
=
\
software_product_list
[
0
].
getObject
().
getAggregateRelatedValueList
()
software_release_list
=
sorted
(
software_release_list
,
key
=
lambda
software_release
:
software_release
.
getCreationDate
(),
reverse
=
True
,
)
return
xml_marshaller
.
xml_marshaller
.
dumps
(
[
software_release
.
getUrlString
()
for
software_release
in
software_release_list
if
software_release
.
getValidationState
()
==
'published'
])
####################################################
# Public POST methods
####################################################
...
...
slapos/slap/interface/slap.py
View file @
72e0b0e8
...
...
@@ -473,3 +473,8 @@ class slap(Interface):
"""
Instanciate a supply in the slap library.
"""
def
getSoftwareReleaseListFromProduct
(
software_product_reference
):
"""
Get the list of Software Releases from a product.
"""
slapos/slap/slap.py
View file @
72e0b0e8
...
...
@@ -735,3 +735,8 @@ class slap:
def
registerSupply
(
self
):
return
Supply
(
connection_helper
=
self
.
_connection_helper
)
def
getSoftwareReleaseListFromSoftwareProduct
(
self
,
software_product_reference
):
xml
=
self
.
_connection_helper
.
GET
(
'/getSoftwareReleaseListFromSoftwareProduct?'
\
'software_product_reference=%s'
%
software_product_reference
)
return
xml_marshaller
.
loads
(
xml
)
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