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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
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
Show 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
...
@@ -40,10 +40,12 @@ from zLOG import LOG, INFO
try
:
try
:
from
slapos.slap.slap
import
\
from
slapos.slap.slap
import
\
SoftwareInstance
as
SlapSoftwareInstance
SoftwareInstance
as
SlapSoftwareInstance
from
slapos.util
import
xml2dict
from
slapos.util
import
xml2dict
,
loads
except
ImportError
:
except
ImportError
:
def
xml2dict
(
dictionary
):
def
xml2dict
(
dictionary
):
raise
ImportError
raise
ImportError
def
loads
(
*
args
):
raise
ImportError
class
SlapSoftwareInstance
:
class
SlapSoftwareInstance
:
def
__init__
(
self
):
def
__init__
(
self
):
raise
ImportError
raise
ImportError
...
@@ -289,3 +291,31 @@ class SoftwareInstance(Item):
...
@@ -289,3 +291,31 @@ class SoftwareInstance(Item):
)
)
return
ip_address_list
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):
...
@@ -941,26 +941,7 @@ class SlapTool(BaseTool):
_getSoftwareInstanceForComputePartition
(
compute_node_id
,
_getSoftwareInstanceForComputePartition
(
compute_node_id
,
compute_partition_id
)
compute_partition_id
)
cache_reference
=
'%s-PREDLIST'
%
software_instance_document
.
getReference
()
software_instance_document
.
_updateSucessorList
(
instance_reference_xml
)
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
)
####################################################
####################################################
# Internals methods
# 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