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
1
Merge Requests
1
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
Romain Courteaud
slapos.core
Commits
ec040fbf
Commit
ec040fbf
authored
Nov 16, 2023
by
Romain Courteaud
🐙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_cloud: propagate remote node destruction
parent
4387416d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
127 additions
and
4 deletions
+127
-4
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/Alarm_propagateRemoteNodeInstance.py
...l_skins/slapos_cloud/Alarm_propagateRemoteNodeInstance.py
+1
-0
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/ComputePartition_propagateRemoteNode.py
...kins/slapos_cloud/ComputePartition_propagateRemoteNode.py
+39
-3
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/ComputePartition_propagateRemoteNode.xml
...ins/slapos_cloud/ComputePartition_propagateRemoteNode.xml
+1
-1
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
...eItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
+86
-0
No files found.
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/Alarm_propagateRemoteNodeInstance.py
View file @
ec040fbf
...
...
@@ -5,6 +5,7 @@ portal.portal_catalog.searchAndActivate(
free_for_request
=
0
,
parent_portal_type
=
'Remote Node'
,
method_id
=
'ComputePartition_propagateRemoteNode'
,
method_kw
=
{
"activate_kw"
:
{
'tag'
:
tag
}},
activate_kw
=
{
'tag'
:
tag
}
)
...
...
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/ComputePartition_propagateRemoteNode.py
View file @
ec040fbf
...
...
@@ -15,16 +15,43 @@ if compute_partition.getId() == 'SHARED_REMOTE':
# Hardcoded ID behaviour
local_instance_list
=
portal
.
portal_catalog
(
portal_type
=
'Slave Instance'
,
aggregate__uid
=
compute_partition
.
getUid
()
aggregate__uid
=
compute_partition
.
getUid
(),
validation_state
=
'validated'
)
else
:
local_instance_list
=
[
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
'Software Instance'
,
aggregate__uid
=
compute_partition
.
getUid
()
aggregate__uid
=
compute_partition
.
getUid
(),
validation_state
=
'validated'
)]
for
local_instance
in
local_instance_list
:
# If local instance destruction has been propagated, do nothing
if
local_instance
.
getValidationState
()
!=
'validated'
:
continue
# if local instance is destroyed, propagate blindly
if
local_instance
.
getSlapState
()
==
'destroy_requested'
:
remote_person
.
requestSoftwareInstance
(
project_reference
=
remote_project
.
getReference
(),
software_release
=
local_instance
.
getUrlString
(),
software_title
=
'_remote_%s_%s'
%
(
remote_node
.
getFollowUpReference
(),
local_instance
.
getReference
()),
software_type
=
local_instance
.
getSourceReference
(),
instance_xml
=
local_instance
.
getTextContent
(),
sla_xml
=
None
,
shared
=
(
local_instance
.
getPortalType
()
==
'Slave Instance'
),
state
=
'destroyed'
)
local_instance
.
invalidate
(
comment
=
'Remote destruction has been propagated'
)
# Try to no trigger the script again on this object
local_instance
.
reindexObject
(
activate_kw
=
activate_kw
)
requested_instance_tree
=
context
.
REQUEST
.
get
(
'request_instance_tree'
)
if
requested_instance_tree
is
not
None
:
requested_instance_tree
.
reindexObject
(
activate_kw
=
activate_kw
)
return
# do not increase the workflow history
# Use the 'cached' API instead
# manually search the instance and compare all parameters
...
...
@@ -72,7 +99,16 @@ for local_instance in local_instance_list:
state
=
{
'start_requested'
:
'started'
,
'stop_requested'
:
'stopped'
}[
local_instance
.
getSlapState
()]
)
requested_software_instance
=
context
.
REQUEST
.
get
(
'request_instance'
)
requested_instance_tree
=
context
.
REQUEST
.
get
(
'request_instance_tree'
)
# Try to no trigger the script again on this object
requested_instance_tree
.
reindexObject
(
activate_kw
=
activate_kw
)
if
requested_software_instance
is
not
None
:
requested_software_instance
.
reindexObject
(
activate_kw
=
activate_kw
)
if
(
requested_software_instance
is
not
None
)
and
\
(
requested_software_instance
.
getConnectionXml
()
!=
local_instance
.
getConnectionXml
()):
local_instance
.
edit
(
connection_xml
=
requested_software_instance
.
getConnectionXml
())
# Try to no trigger the script again on this object
local_instance
.
edit
(
connection_xml
=
requested_software_instance
.
getConnectionXml
(),
activate_kw
=
activate_kw
)
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/ComputePartition_propagateRemoteNode.xml
View file @
ec040fbf
...
...
@@ -50,7 +50,7 @@
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
REQUEST=None
</string>
</value>
<value>
<string>
activate_kw=None,
REQUEST=None
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
...
...
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
View file @
ec040fbf
...
...
@@ -1655,3 +1655,89 @@ class TestSlapOSPropagateRemoteNodeInstance(SlapOSTestCaseMixin):
self
.
assertEqual
(
software_instance
.
getConnectionXml
(),
remote_instance
.
getConnectionXml
())
def
test_propagateRemoteNode_script_propagateDestructionIfValidated
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
remote_node
,
partition
=
self
.
addComputeNodeAndPartition
(
project
=
instance_tree
.
getFollowUpValue
(),
portal_type
=
'Remote Node'
)
software_instance
.
setAggregateValue
(
partition
)
partition
.
markBusy
()
with
TemporaryAlarmScript
(
self
.
portal
,
'ComputePartition_propagateRemoteNode'
,
""
):
self
.
tic
()
partition
.
ComputePartition_propagateRemoteNode
()
self
.
tic
()
remote_user
=
remote_node
.
getDestinationSectionValue
()
remote_project
=
remote_node
.
getDestinationProjectValue
()
remote_instance_tree
=
self
.
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
'Instance Tree'
,
destination_section__uid
=
remote_user
.
getUid
(),
follow_up__uid
=
remote_project
.
getUid
(),
title
=
'_remote_%s_%s'
%
(
software_instance
.
getFollowUpReference
(),
software_instance
.
getReference
())
)
remote_modification_date
=
remote_instance_tree
.
getModificationDate
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'destroy_requested'
)
self
.
tic
()
self
.
assertEqual
(
software_instance
.
getValidationState
(),
'validated'
)
partition
.
ComputePartition_propagateRemoteNode
()
self
.
assertNotEqual
(
remote_instance_tree
.
getModificationDate
(),
remote_modification_date
)
self
.
assertEqual
(
remote_instance_tree
.
getValidationState
(),
"archived"
)
self
.
assertEqual
(
remote_instance_tree
.
getSlapState
(),
"destroy_requested"
)
self
.
assertEqual
(
remote_instance_tree
.
getUrlString
(),
software_instance
.
getUrlString
())
self
.
assertEqual
(
remote_instance_tree
.
getSourceReference
(),
software_instance
.
getSourceReference
())
self
.
assertEqual
(
remote_instance_tree
.
getTextContent
(),
software_instance
.
getTextContent
())
self
.
assertEqual
(
remote_instance_tree
.
getSlaXml
(),
None
)
self
.
assertEqual
(
remote_instance_tree
.
isRootSlave
(
False
),
software_instance
.
getPortalType
()
==
'Slave Instance'
)
self
.
assertEqual
(
software_instance
.
getConnectionXml
(),
None
)
self
.
assertEqual
(
software_instance
.
getValidationState
(),
'invalidated'
)
def
test_propagateRemoteNode_script_doNotPropagateDestructionIfInvalidated
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
remote_node
,
partition
=
self
.
addComputeNodeAndPartition
(
project
=
instance_tree
.
getFollowUpValue
(),
portal_type
=
'Remote Node'
)
software_instance
.
setAggregateValue
(
partition
)
partition
.
markBusy
()
with
TemporaryAlarmScript
(
self
.
portal
,
'ComputePartition_propagateRemoteNode'
,
""
):
self
.
tic
()
partition
.
ComputePartition_propagateRemoteNode
()
self
.
tic
()
remote_user
=
remote_node
.
getDestinationSectionValue
()
remote_project
=
remote_node
.
getDestinationProjectValue
()
remote_instance_tree
=
self
.
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
'Instance Tree'
,
destination_section__uid
=
remote_user
.
getUid
(),
follow_up__uid
=
remote_project
.
getUid
(),
title
=
'_remote_%s_%s'
%
(
software_instance
.
getFollowUpReference
(),
software_instance
.
getReference
())
)
remote_modification_date
=
remote_instance_tree
.
getModificationDate
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'destroy_requested'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'invalidated'
)
self
.
tic
()
partition
.
ComputePartition_propagateRemoteNode
()
self
.
assertEqual
(
remote_instance_tree
.
getModificationDate
(),
remote_modification_date
)
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