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
Léo-Paul Géneau
slapos.core
Commits
5804e551
Commit
5804e551
authored
Mar 30, 2022
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_cloud: Move API into SoftwareInstance to update the _updateSucessorList
parent
b5c767af
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
22 deletions
+33
-22
master/bt5/slapos_cloud/DocumentTemplateItem/portal_components/document.erp5.SoftwareInstance.py
...eItem/portal_components/document.erp5.SoftwareInstance.py
+32
-2
master/bt5/slapos_slap_tool/ToolComponentTemplateItem/portal_components/tool.erp5.SlapTool.py
...onentTemplateItem/portal_components/tool.erp5.SlapTool.py
+1
-20
No files found.
master/bt5/slapos_cloud/DocumentTemplateItem/portal_components/document.erp5.SoftwareInstance.py
View file @
5804e551
...
...
@@ -40,10 +40,12 @@ from zLOG import LOG, INFO
try
:
from
slapos.slap.slap
import
\
SoftwareInstance
as
SlapSoftwareInstance
from
slapos.util
import
xml2dict
from
slapos.util
import
xml2dict
,
loads
except
ImportError
:
def
xml2dict
(
dictionary
):
raise
ImportError
def
loads
(
*
args
):
raise
ImportError
class
SlapSoftwareInstance
:
def
__init__
(
self
):
raise
ImportError
...
...
@@ -288,4 +290,32 @@ class SoftwareInstance(Item):
internet_protocol_address
.
getIpAddress
().
decode
(
"UTF-8"
))
)
return
ip_address_list
\ No newline at end of file
return
ip_address_list
def
_updateSucessorList
(
self
,
instance_reference_xml
):
"""
Update Software Instance successor list to match the given list. If one
instance was not requested by this compute partition, it should be removed
in the successor_list of this instance.
Once the link is removed, this instance will be trashed by Garbage Collect!
instance_reference_xml contain list of title of sub-instances requested by
this instance.
"""
cache_reference
=
'%s-PREDLIST'
%
self
.
getReference
()
if
not
self
.
isLastData
(
cache_reference
,
instance_reference_xml
):
instance_reference_list
=
loads
(
instance_reference_xml
)
current_successor_list
=
self
.
getSuccessorValueList
(
portal_type
=
[
'Software Instance'
,
'Slave Instance'
])
current_successor_title_list
=
[
i
.
getTitle
()
for
i
in
current_successor_list
]
# If there are items to remove
if
list
(
set
(
current_successor_title_list
).
difference
(
instance_reference_list
))
!=
[]:
successor_list
=
[
instance
.
getRelativeUrl
()
for
instance
in
current_successor_list
if
instance
.
getTitle
()
in
instance_reference_list
]
LOG
(
'SoftwareInstance'
,
INFO
,
'%s : Updating successor list to %s'
%
(
self
.
getReference
(),
successor_list
),
error
=
False
)
self
.
edit
(
successor_list
=
successor_list
,
comment
=
'successor_list edited to unlink non commited instances'
)
self
.
setLastData
(
instance_reference_xml
,
key
=
cache_reference
)
\ No newline at end of file
master/bt5/slapos_slap_tool/ToolComponentTemplateItem/portal_components/tool.erp5.SlapTool.py
View file @
5804e551
...
...
@@ -941,26 +941,7 @@ class SlapTool(BaseTool):
_getSoftwareInstanceForComputePartition
(
compute_node_id
,
compute_partition_id
)
cache_reference
=
'%s-PREDLIST'
%
software_instance_document
.
getReference
()
if
not
software_instance_document
.
isLastData
(
cache_reference
,
instance_reference_xml
):
instance_reference_list
=
loads
(
instance_reference_xml
)
current_successor_list
=
software_instance_document
.
getSuccessorValueList
(
portal_type
=
[
'Software Instance'
,
'Slave Instance'
])
current_successor_title_list
=
[
i
.
getTitle
()
for
i
in
current_successor_list
]
# If there are items to remove
if
list
(
set
(
current_successor_title_list
).
difference
(
instance_reference_list
))
!=
[]:
successor_list
=
[
instance
.
getRelativeUrl
()
for
instance
in
current_successor_list
if
instance
.
getTitle
()
in
instance_reference_list
]
LOG
(
'SlapTool'
,
INFO
,
'%s, %s: Updating successor list to %s'
%
(
compute_node_id
,
compute_partition_id
,
successor_list
),
error
=
False
)
software_instance_document
.
edit
(
successor_list
=
successor_list
,
comment
=
'successor_list edited to unlink non commited instances'
)
software_instance_document
.
setLastData
(
instance_reference_xml
,
key
=
cache_reference
)
software_instance_document
.
_updateSucessorList
(
instance_reference_xml
)
####################################################
# Internals methods
...
...
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