Commit d804f3fb authored by Romain Courteaud's avatar Romain Courteaud Committed by Antoine Catton

Allow to get connection parameter for slave instance.

WARNING: this is an quick ugly hack to not block developper.
The clean fix is to swith to the rest API defined in:
http://packages.python.org/slapos.core/
parent db44937d
No related merge requests found
......@@ -845,8 +845,15 @@ class SlapTool(BaseTool):
requested_software_instance, **query_kw)
if movement is None:
raise SoftwareInstanceNotReady
software_instance = SoftwareInstance(
**self._getSalePackingListLineAsSoftwareInstance(movement))
parameter_dict = self._getSalePackingListLineAsSoftwareInstance(movement)
software_instance = SoftwareInstance(**parameter_dict)
if shared:
slave_instance = parameter_dict.get("slave_instance_list")[0]
software_instance._parameter_dict = self._instanceXmlToDict(
slave_instance.pop('xml'))
software_instance._connection_dict = self._instanceXmlToDict(
slave_instance.pop('connection_xml'))
return xml_marshaller.xml_marshaller.dumps(software_instance)
####################################################
......
......@@ -172,9 +172,14 @@ class OpenOrder(SlapDocument):
else:
xml = self._connection_helper.response.read()
software_instance = xml_marshaller.loads(xml)
return ComputerPartition(
computer_partition = ComputerPartition(
software_instance.slap_computer_id.encode('UTF-8'),
software_instance.slap_computer_partition_id.encode('UTF-8'))
if shared:
computer_partition._synced = True
computer_partition._connection_dict = software_instance._connection_dict
computer_partition._parameter_dict = software_instance._parameter_dict
return computer_partition
def _syncComputerInformation(func):
"""
......@@ -237,6 +242,8 @@ def _syncComputerPartitionInformation(func):
Synchronize computer partition object with server information
"""
def decorated(self, *args, **kw):
if getattr(self, '_synced', 0):
return func(self, *args, **kw)
computer = self._connection_helper.getComputerInformation(self._computer_id)
found_computer_partition = None
for computer_partition in computer._computer_partition_list:
......@@ -334,9 +341,14 @@ class ComputerPartition(SlapDocument):
else:
xml = self._connection_helper.response.read()
software_instance = xml_marshaller.loads(xml)
return ComputerPartition(
computer_partition = ComputerPartition(
software_instance.slap_computer_id.encode('UTF-8'),
software_instance.slap_computer_partition_id.encode('UTF-8'))
if shared:
computer_partition._synced = True
computer_partition._connection_dict = software_instance._connection_dict
computer_partition._parameter_dict = software_instance._parameter_dict
return computer_partition
def building(self):
self._connection_helper.POST('/buildingComputerPartition', {
......
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