Commit b66e981c authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

slapos_cloud: Software instance dedicated update sucessor list uses list and is accessible

parent b223b498
...@@ -39,12 +39,10 @@ from erp5.component.module.SlapOSCloud import _assertACI ...@@ -39,12 +39,10 @@ from erp5.component.module.SlapOSCloud import _assertACI
from zLOG import LOG, INFO from zLOG import LOG, INFO
try: try:
from slapos.util import xml2dict, loads from slapos.util import xml2dict
except ImportError: except ImportError:
def xml2dict(dictionary): def xml2dict(dictionary):
raise ImportError raise ImportError
def loads(*args):
raise ImportError
class DisconnectedSoftwareTree(Exception): class DisconnectedSoftwareTree(Exception):
pass pass
...@@ -281,19 +279,21 @@ class SoftwareInstance(Item, JSONType): ...@@ -281,19 +279,21 @@ class SoftwareInstance(Item, JSONType):
return ip_address_list return ip_address_list
def _updateSucessorList(self, instance_reference_xml): def updateRequestedInstanceList(self, instance_reference_list):
return self._updateSucessorList(instance_reference_list)
def _updateSucessorList(self, instance_reference_list):
""" """
Update Software Instance successor list to match the given list. If one Update Software Instance successor list to match the given list. If one
instance was not requested by this compute partition, it should be removed instance was not requested by this compute partition, it should be removed
in the successor_list of this instance. in the successor_list of this instance.
Once the link is removed, this instance will be trashed by Garbage Collect! 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 instance_reference_list contain list of title of sub-instances requested by
this instance. this instance.
""" """
cache_reference = '%s-PREDLIST' % self.getReference() cache_reference = '%s-PREDLIST' % self.getReference()
if not self.isLastData(cache_reference, instance_reference_xml): if not self.isLastData(cache_reference, str(instance_reference_list)):
instance_reference_list = loads(instance_reference_xml)
current_successor_list = self.getSuccessorValueList( current_successor_list = self.getSuccessorValueList(
portal_type=['Software Instance', 'Slave Instance']) portal_type=['Software Instance', 'Slave Instance'])
current_successor_title_list = [i.getTitle() for i in current_successor_list] current_successor_title_list = [i.getTitle() for i in current_successor_list]
...@@ -307,7 +307,7 @@ class SoftwareInstance(Item, JSONType): ...@@ -307,7 +307,7 @@ class SoftwareInstance(Item, JSONType):
self.getReference(), successor_list), error=False) self.getReference(), successor_list), error=False)
self.edit(successor_list=successor_list, self.edit(successor_list=successor_list,
comment='successor_list edited to unlink non commited instances') comment='successor_list edited to unlink non commited instances')
self.setLastData(instance_reference_xml, key=cache_reference) self.setLastData(str(instance_reference_list), key=cache_reference)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'asJSONText') 'asJSONText')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment