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
Lu Xu
slapos.core
Commits
69d8dbe7
Commit
69d8dbe7
authored
Sep 22, 2014
by
Cédric de Saint Martin
Committed by
Rafael Monnerat
Nov 10, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Master: add retention_delay support.
parent
5e065b8d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
214 additions
and
5 deletions
+214
-5
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSCloudWorkflow.py
.../slapos_cloud/TestTemplateItem/testSlapOSCloudWorkflow.py
+66
-4
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/instance_slap_interface_workflow/scripts/RequestedInstance_updateParameterInformation.xml
.../scripts/RequestedInstance_updateParameterInformation.xml
+6
-0
master/bt5/slapos_slap_tool/TestTemplateItem/testSlapOSSlapTool.py
...5/slapos_slap_tool/TestTemplateItem/testSlapOSSlapTool.py
+137
-0
master/bt5/slapos_slap_tool/bt/revision
master/bt5/slapos_slap_tool/bt/revision
+1
-1
master/product/Vifib/Tool/SlapTool.py
master/product/Vifib/Tool/SlapTool.py
+4
-0
No files found.
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSCloudWorkflow.py
View file @
69d8dbe7
...
...
@@ -1914,6 +1914,23 @@ class TestSlapOSCoreSoftwareInstanceRequest(testSlapOSMixin):
requested_instance2
.
getSlaXml
())
self
.
assertEqual
(
bang_amount
+
1
,
self
.
_countBang
(
requested_instance
))
def
test_request_retention_delay
(
self
):
retention_delay
=
42
sla_xml
=
'<?xml version="1.0" encoding="utf-8"?><instance><parameter '
\
'id="retention_delay">%s</parameter></instance>'
%
retention_delay
request_kw
=
self
.
request_kw
.
copy
()
request_kw
[
'software_title'
]
=
self
.
generateNewSoftwareTitle
()
request_kw
[
'sla_xml'
]
=
sla_xml
self
.
software_instance
.
requestInstance
(
**
request_kw
)
requested_instance
=
self
.
software_instance
.
REQUEST
.
get
(
'request_instance'
)
self
.
tic
()
self
.
assertEqual
(
retention_delay
,
requested_instance
.
getRetentionDelay
())
def
test_update_connection_bang_requester
(
self
):
request_kw
=
self
.
request_kw
.
copy
()
...
...
@@ -2493,6 +2510,38 @@ class TestSlapOSCorePersonRequest(testSlapOSMixin):
self
.
assertNotEquals
(
hosting_subscription
.
getRelativeUrl
(),
hosting_subscription2
.
getRelativeUrl
())
def
test_Person_requestSoftwareInstance_retention_delay
(
self
):
person
=
self
.
getPortalObject
().
ERP5Site_getAuthenticatedMemberPersonValue
()
retention_delay
=
42
software_release
=
self
.
generateNewSoftwareReleaseUrl
()
software_title
=
"test"
software_type
=
"test"
instance_xml
=
"""<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
shared
=
False
sla_xml
=
'<?xml version="1.0" encoding="utf-8"?><instance><parameter '
\
'id="retention_delay">%s</parameter></instance>'
%
retention_delay
person
.
requestSoftwareInstance
(
software_release
=
software_release
,
software_title
=
software_title
,
software_type
=
software_type
,
instance_xml
=
instance_xml
,
sla_xml
=
sla_xml
,
shared
=
shared
,
state
=
"started"
,
)
hosting_subscription
=
person
.
REQUEST
.
get
(
'request_hosting_subscription'
)
self
.
tic
()
self
.
assertEquals
(
retention_delay
,
hosting_subscription
.
getPredecessorValue
().
getRetentionDelay
())
class
TestSlapOSCorePersonRequestComputer
(
testSlapOSMixin
):
def
generateNewComputerTitle
(
self
):
...
...
@@ -2907,7 +2956,8 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(testSlapOSMixin):
def
test_SoftwareInstance_changeState_onDestroy
(
self
):
return
self
.
check_SoftwareInstance_changeState
(
"requestDestroy"
)
def
check_change_instance_parameter
(
self
,
portal_type
,
method_id
):
def
check_change_instance_parameter
(
self
,
portal_type
,
method_id
,
value
=
None
,
bang_expected
=
True
):
self
.
_makePerson
()
self
.
login
(
self
.
person_user
.
getReference
())
...
...
@@ -2925,10 +2975,17 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(testSlapOSMixin):
self
.
assertEqual
(
None
,
instance
.
workflow_history
[
'instance_slap_interface_workflow'
][
-
1
][
'action'
])
if
value
:
instance
.
edit
(
**
{
method_id
:
value
})
else
:
instance
.
edit
(
**
{
method_id
:
self
.
generateSafeXml
()})
self
.
tic
()
if
bang_expected
:
self
.
assertEqual
(
'bang'
,
instance
.
workflow_history
[
'instance_slap_interface_workflow'
][
-
1
][
'action'
])
else
:
self
.
assertNotEqual
(
'bang'
,
instance
.
workflow_history
[
'instance_slap_interface_workflow'
][
-
1
][
'action'
])
def
test_change_instance_parameter_onInstanceUrlString
(
self
):
return
self
.
check_change_instance_parameter
(
"Software Instance"
,
...
...
@@ -2946,6 +3003,11 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(testSlapOSMixin):
return
self
.
check_change_instance_parameter
(
"Software Instance"
,
'sla_xml'
)
def
test_change_instance_parameter_onInstanceRetentionDelay
(
self
):
return
self
.
check_change_instance_parameter
(
"Slave Instance"
,
'retention_delay'
,
value
=
42
,
bang_expected
=
False
)
def
test_change_instance_parameter_onSlaveUrlString
(
self
):
return
self
.
check_change_instance_parameter
(
"Slave Instance"
,
'url_string'
)
...
...
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/instance_slap_interface_workflow/scripts/RequestedInstance_updateParameterInformation.xml
View file @
69d8dbe7
...
...
@@ -92,6 +92,12 @@ else:\n
(instance.getPortalType(), instance.getRelativeUrl())\n
\n
instance.edit(**edit_kw)\n
\n
if instance_portal_type == "Software Instance":\n
sla_dict = instance.getSlaXmlAsDict()\n
retention_delay = sla_dict.get(\'retention_delay\', 0)\n
instance.setRetentionDelay(retention_delay)\n
\n
# Prevent storing broken XML in text content (which prevent to update parameters after)\n
context.Instance_checkConsistency(state_change)\n
</string>
</value>
...
...
master/bt5/slapos_slap_tool/TestTemplateItem/testSlapOSSlapTool.py
View file @
69d8dbe7
...
...
@@ -1001,6 +1001,143 @@ 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_getFullComputerInformation_retention_delay
(
self
):
"""
Test getFullComputerInformation() in case some Software Instances contain
a retention_delay.
"""
retention_delay
=
42
self
.
_makeComplexComputer
(
with_slave
=
True
)
self
.
start_requested_software_instance
.
setRetentionDelay
(
retention_delay
)
self
.
tic
()
self
.
login
(
self
.
start_requested_software_instance
.
getReference
())
response
=
self
.
portal_slap
.
getFullComputerInformation
(
self
.
computer_id
)
self
.
assertEqual
(
200
,
response
.
status
)
self
.
assertEqual
(
'public, max-age=1, stale-if-error=604800'
,
response
.
headers
.
get
(
'cache-control'
))
self
.
assertEqual
(
'REMOTE_USER'
,
response
.
headers
.
get
(
'vary'
))
self
.
assertTrue
(
'last-modified'
in
response
.
headers
)
self
.
assertEqual
(
'text/xml; charset=utf-8'
,
response
.
headers
.
get
(
'content-type'
))
# check returned XML
xml_fp
=
StringIO
.
StringIO
()
xml
.
dom
.
ext
.
PrettyPrint
(
xml
.
dom
.
ext
.
reader
.
Sax
.
FromXml
(
response
.
body
),
stream
=
xml_fp
)
xml_fp
.
seek
(
0
)
got_xml
=
xml_fp
.
read
()
expected_xml
=
"""
\
<?xml version='1.0' encoding='UTF-8'?>
<marshal>
<object id='i2' module='slapos.slap.slap' class='Computer'>
<tuple>
<unicode>%(computer_id)s</unicode>
</tuple>
<dictionary id='i3'>
<string>_computer_id</string>
<unicode>%(computer_id)s</unicode>
<string>_computer_partition_list</string>
<list id='i4'>
<object id='i5' module='slapos.slap.slap' class='ComputerPartition'>
<tuple>
<unicode>%(computer_id)s</unicode>
<unicode>partition1</unicode>
</tuple>
<dictionary id='i6'>
<string>_computer_id</string>
<unicode>%(computer_id)s</unicode>
<string>_connection_dict</string>
<dictionary id='i7'/>
<string>_instance_guid</string>
<unicode>%(instance_guid)s</unicode>
<string>_need_modification</string>
<int>1</int>
<string>_parameter_dict</string>
<dictionary id='i8'>
<string>ip_list</string>
<list id='i9'>
<tuple>
<unicode/>
<unicode>ip_address_1</unicode>
</tuple>
</list>
<unicode>paramé</unicode>
<unicode>%(param)s</unicode>
<string>slap_computer_id</string>
<unicode>%(computer_id)s</unicode>
<string>slap_computer_partition_id</string>
<unicode>partition1</unicode>
<string>slap_software_release_url</string>
<unicode>%(software_release_url)s</unicode>
<string>slap_software_type</string>
<unicode>%(software_type)s</unicode>
<string>slave_instance_list</string>
<list id='i10'>
<dictionary id='i11'>
<unicode>paramé</unicode>
<unicode>%(slave_1_param)s</unicode>
<string>slap_software_type</string>
<unicode>%(slave_1_software_type)s</unicode>
<string>slave_reference</string>
<unicode>%(slave_1_instance_guid)s</unicode>
<string>slave_title</string>
<unicode>%(slave_1_title)s</unicode>
<string>timestamp</string>
<int>%(timestamp)s</int>
</dictionary>
</list>
<string>timestamp</string>
<string>%(timestamp)s</string>
</dictionary>
<string>_partition_id</string>
<unicode>partition1</unicode>
<string>_request_dict</string>
<none/>
<string>_requested_state</string>
<string>started</string>
<string>_retention_delay</string>
<int>42</int>
<string>_software_release_document</string>
<object id='i12' module='slapos.slap.slap' class='SoftwareRelease'>
<tuple>
<unicode>%(software_release_url)s</unicode>
<unicode>%(computer_id)s</unicode>
</tuple>
<dictionary id='i13'>
<string>_computer_guid</string>
<unicode>%(computer_id)s</unicode>
<string>_software_instance_list</string>
<list id='i14'/>
<string>_software_release</string>
<unicode>%(software_release_url)s</unicode>
</dictionary>
</object>
</dictionary>
</object>
</list>
<string>_software_release_list</string>
<list id='i15'/>
</dictionary>
</object>
</marshal>
"""
%
dict
(
computer_id
=
self
.
computer_id
,
instance_guid
=
self
.
start_requested_software_instance
.
getReference
(),
software_release_url
=
self
.
start_requested_software_instance
.
getUrlString
(),
software_type
=
self
.
start_requested_software_instance
.
getSourceReference
(),
param
=
self
.
start_requested_software_instance
.
getInstanceXmlAsDict
()[
'paramé'
],
timestamp
=
int
(
self
.
start_requested_software_instance
.
getModificationDate
()),
slave_1_param
=
self
.
start_requested_slave_instance
.
getInstanceXmlAsDict
()[
'paramé'
],
slave_1_software_type
=
self
.
start_requested_slave_instance
.
getSourceReference
(),
slave_1_instance_guid
=
self
.
start_requested_slave_instance
.
getReference
(),
slave_1_title
=
self
.
start_requested_slave_instance
.
getTitle
(),
)
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_getComputerPartitionStatus
(
self
):
self
.
_makeComplexComputer
()
partition_id
=
self
.
start_requested_software_instance
.
getAggregateValue
(
...
...
master/bt5/slapos_slap_tool/bt/revision
View file @
69d8dbe7
36
\ No newline at end of file
37
\ No newline at end of file
master/product/Vifib/Tool/SlapTool.py
View file @
69d8dbe7
...
...
@@ -893,6 +893,10 @@ class SlapTool(BaseTool):
slave_instance_dict
.
pop
(
"xml"
)))
slap_partition
.
_parameter_dict
.
update
(
parameter_dict
)
retention_delay
=
software_instance
.
getRetentionDelay
()
if
retention_delay
:
slap_partition
.
_retention_delay
=
retention_delay
return
slap_partition
@
convertToREST
...
...
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