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
Labels
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Rafael Monnerat
slapos.core
Commits
af06f46d
Commit
af06f46d
authored
Aug 30, 2024
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_cloud: move instance tree update logic into a python script
parent
4406c739
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
117 additions
and
38 deletions
+117
-38
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/InstanceTree_updateParameterAndRequest.py
...ns/slapos_cloud/InstanceTree_updateParameterAndRequest.py
+50
-0
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/InstanceTree_updateParameterAndRequest.xml
...s/slapos_cloud/InstanceTree_updateParameterAndRequest.xml
+62
-0
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/person_slap_interface_workflow/script_Person_requestSoftwareInstance.py
...terface_workflow/script_Person_requestSoftwareInstance.py
+4
-38
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSCodingStyle.py
...Item/portal_components/test.erp5.testSlapOSCodingStyle.py
+1
-0
No files found.
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/InstanceTree_updateParameterAndRequest.py
0 → 100644
View file @
af06f46d
from
zExceptions
import
Unauthorized
if
REQUEST
is
not
None
:
raise
Unauthorized
request_instance_tree
=
context
software_release_url_string
=
software_release
root_state
=
state
is_slave
=
shared
if
is_slave
not
in
[
True
,
False
]:
raise
ValueError
(
"shared should be a boolean"
)
promise_kw
=
{
'instance_xml'
:
instance_xml
,
'software_type'
:
software_type
,
'sla_xml'
:
sla_xml
,
'software_release'
:
software_release_url_string
,
'shared'
:
is_slave
,
}
# Change desired state
if
(
root_state
==
"started"
):
request_instance_tree
.
requestStart
(
**
promise_kw
)
elif
(
root_state
==
"stopped"
):
request_instance_tree
.
requestStop
(
**
promise_kw
)
elif
(
root_state
==
"destroyed"
):
request_instance_tree
.
requestDestroy
(
**
promise_kw
)
context
.
REQUEST
.
set
(
'request_instance_tree'
,
None
)
else
:
raise
ValueError
(
"state should be started, stopped or destroyed"
)
request_instance_tree
.
requestInstance
(
software_release
=
software_release_url_string
,
software_title
=
software_title
,
software_type
=
software_type
,
instance_xml
=
instance_xml
,
sla_xml
=
sla_xml
,
shared
=
is_slave
,
state
=
root_state
,
)
# Change the state at the end to allow to execute updateLocalRoles only once in the transaction
validation_state
=
request_instance_tree
.
getValidationState
()
slap_state
=
request_instance_tree
.
getSlapState
()
if
validation_state
==
'draft'
:
request_instance_tree
.
portal_workflow
.
doActionFor
(
request_instance_tree
,
'validate_action'
)
if
(
validation_state
!=
'archived'
)
and
\
(
slap_state
==
'destroy_requested'
):
# XXX TODO do not use validation workflow to filter destroyed subscription
request_instance_tree
.
archive
()
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/InstanceTree_updateParameterAndRequest.xml
0 → 100644
View file @
af06f46d
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"_reconstructor"
module=
"copy_reg"
/>
</klass>
<tuple>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
<global
name=
"object"
module=
"__builtin__"
/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
state, software_release, software_title, software_type, instance_xml, sla_xml, shared, REQUEST=None
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
InstanceTree_updateParameterAndRequest
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/person_slap_interface_workflow/script_Person_requestSoftwareInstance.py
View file @
af06f46d
...
...
@@ -79,43 +79,9 @@ else:
activate_kw
=
{
'tag'
:
tag
},
)
promise_kw
=
{
'instance_xml'
:
instance_xml
,
'software_type'
:
software_type
,
'sla_xml'
:
sla_xml
,
'software_release'
:
software_release_url_string
,
'shared'
:
is_slave
,
}
request_instance_tree
.
InstanceTree_updateParameterAndRequest
(
root_state
,
software_release_url_string
,
software_title
,
software_type
,
instance_xml
,
sla_xml
,
is_slave
)
context
.
REQUEST
.
set
(
'request_instance_tree'
,
request_instance_tree
)
# Change desired state
if
(
root_state
==
"started"
):
request_instance_tree
.
requestStart
(
**
promise_kw
)
elif
(
root_state
==
"stopped"
):
request_instance_tree
.
requestStop
(
**
promise_kw
)
elif
(
root_state
==
"destroyed"
):
request_instance_tree
.
requestDestroy
(
**
promise_kw
)
if
(
root_state
==
"destroyed"
):
context
.
REQUEST
.
set
(
'request_instance_tree'
,
None
)
else
:
raise
ValueError
(
"state should be started, stopped or destroyed"
)
request_instance_tree
.
requestInstance
(
software_release
=
software_release_url_string
,
software_title
=
software_title
,
software_type
=
software_type
,
instance_xml
=
instance_xml
,
sla_xml
=
sla_xml
,
shared
=
is_slave
,
state
=
root_state
,
)
# Change the state at the end to allow to execute updateLocalRoles only once in the transaction
validation_state
=
request_instance_tree
.
getValidationState
()
slap_state
=
request_instance_tree
.
getSlapState
()
if
validation_state
==
'draft'
:
request_instance_tree
.
portal_workflow
.
doActionFor
(
request_instance_tree
,
'validate_action'
)
if
(
validation_state
!=
'archived'
)
and
\
(
slap_state
==
'destroy_requested'
):
# XXX TODO do not use validation workflow to filter destroyed subscription
request_instance_tree
.
archive
()
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSCodingStyle.py
View file @
af06f46d
...
...
@@ -83,6 +83,7 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template):
'slapos_cloud/ComputeNode_getUsageReportUrl'
,
'slapos_cloud/ComputeNode_init'
,
'slapos_cloud/InstanceNode_init'
,
'slapos_cloud/InstanceTree_updateParameterAndRequest'
,
'slapos_cloud/RemoteNode_init'
,
'slapos_cloud/ComputePartition_getAvailableSoftwareReleaseUrlStringList'
,
'slapos_cloud/ComputePartition_getLastestContactedDate'
,
...
...
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