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
c89a51ba
Commit
c89a51ba
authored
Nov 14, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_cloud: try to create an upgrade decision for a remote instance
parent
ab54c13a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
115 additions
and
0 deletions
+115
-0
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/ComputePartition_propagateRemoteNode.py
...kins/slapos_cloud/ComputePartition_propagateRemoteNode.py
+16
-0
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
...eItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
+99
-0
No files found.
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/ComputePartition_propagateRemoteNode.py
View file @
c89a51ba
...
...
@@ -40,6 +40,22 @@ for local_instance in local_instance_list:
if
remote_instance_tree
is
not
None
:
requested_software_instance
=
remote_instance_tree
.
getSuccessorValue
(
title
=
remote_instance_tree
.
getTitle
())
if
(
remote_instance_tree
is
not
None
)
and
\
((
local_instance
.
getUrlString
()
!=
remote_instance_tree
.
getUrlString
())
or
\
(
local_instance
.
getSourceReference
()
!=
remote_instance_tree
.
getSourceReference
())):
# Try to create an Upgrade Decision for the new release
_
,
new_release_variation
,
new_type_variation
=
remote_instance_tree
.
asContext
(
url_string
=
local_instance
.
getUrlString
(),
source_reference
=
local_instance
.
getSourceReference
()
).
InstanceTree_getSoftwareProduct
()
if
new_release_variation
is
None
:
return
else
:
return
remote_instance_tree
.
InstanceTree_createUpgradeDecision
(
target_software_release
=
new_release_variation
,
target_software_type
=
new_type_variation
)
if
(
remote_instance_tree
is
None
)
or
\
(
local_instance
.
getTextContent
()
!=
remote_instance_tree
.
getTextContent
())
or
\
(
local_instance
.
getSlapState
()
!=
remote_instance_tree
.
getSlapState
()):
...
...
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
View file @
c89a51ba
...
...
@@ -1389,6 +1389,105 @@ class TestSlapOSPropagateRemoteNodeInstance(SlapOSTestCaseMixin):
self
.
assertEqual
(
software_instance
.
getConnectionXml
(),
None
)
def
test_propagateRemoteNode_script_propageReleaseChangesToUpgradeDecision
(
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
()
with
TemporaryAlarmScript
(
self
.
portal
,
'Item_getSubscriptionStatus'
,
"'subscribed'"
):
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_software_instance
=
remote_instance_tree
.
getSuccessorValue
()
# Create allocated partition to allow Upgrade Decision
remote_compute_node
,
remote_partition
=
self
.
addComputeNodeAndPartition
(
project
=
remote_instance_tree
.
getFollowUpValue
(),
)
remote_software_instance
.
setAggregateValue
(
remote_partition
)
remote_partition
.
markBusy
()
# Create remote Software Product, to allow generating the Upgrade Decision
new_id
=
self
.
generateNewId
()
software_product
=
self
.
portal
.
software_product_module
.
newContent
(
reference
=
'TESTSOFTPROD-%s'
%
new_id
,
title
=
'Test software product %s'
%
new_id
,
follow_up_value
=
remote_project
)
old_release_variation
=
software_product
.
newContent
(
portal_type
=
'Software Product Release Variation'
,
url_string
=
remote_instance_tree
.
getUrlString
()
)
type_variation
=
software_product
.
newContent
(
portal_type
=
'Software Product Type Variation'
,
reference
=
remote_instance_tree
.
getSourceReference
()
)
software_product
.
publish
()
new_release_variation
=
self
.
_makeSoftwareRelease
(
software_product
)
self
.
addAllocationSupply
(
"old release compute node"
,
remote_compute_node
,
software_product
,
old_release_variation
,
type_variation
,
disable_alarm
=
True
)
self
.
addAllocationSupply
(
"new release compute node"
,
remote_compute_node
,
software_product
,
new_release_variation
,
type_variation
,
disable_alarm
=
True
)
self
.
tic
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'stop_requested'
)
old_release_url
=
software_instance
.
getUrlString
()
old_text_content
=
software_instance
.
getTextContent
()
software_instance
.
edit
(
url_string
=
new_release_variation
.
getUrlString
(),
text_content
=
self
.
generateSafeXml
()
)
with
TemporaryAlarmScript
(
self
.
portal
,
'Item_getSubscriptionStatus'
,
"'subscribed'"
):
partition
.
ComputePartition_propagateRemoteNode
()
# Instance tree is not modified
self
.
assertEqual
(
remote_instance_tree
.
getValidationState
(),
"validated"
)
self
.
assertEqual
(
remote_instance_tree
.
getSlapState
(),
"start_requested"
)
self
.
assertEqual
(
remote_instance_tree
.
getUrlString
(),
old_release_url
)
self
.
assertEqual
(
remote_instance_tree
.
getSourceReference
(),
software_instance
.
getSourceReference
())
self
.
assertEqual
(
remote_instance_tree
.
getTextContent
(),
old_text_content
)
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
.
tic
()
# An upgrade decision is proposed
upgrade_decision
=
self
.
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
'Upgrade Decision'
,
destination_section__uid
=
remote_user
.
getUid
(),
destination_project__uid
=
remote_project
.
getUid
(),
aggregate__uid
=
remote_instance_tree
.
getUid
(),
resource__uid
=
software_product
.
getUid
(),
software_release__uid
=
new_release_variation
.
getUid
(),
software_type__uid
=
type_variation
.
getUid
(),
simulation_state
=
'confirmed'
)
self
.
assertNotEqual
(
upgrade_decision
,
None
)
def
test_propagateRemoteNode_script_doNotPropageConnectionXmlIfNotChanged
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
...
...
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