Commit b5491afd authored by Romain Courteaud's avatar Romain Courteaud

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 bcda1fdf
...@@ -825,8 +825,15 @@ class SlapTool(BaseTool): ...@@ -825,8 +825,15 @@ class SlapTool(BaseTool):
requested_software_instance, **query_kw) requested_software_instance, **query_kw)
if movement is None: if movement is None:
raise SoftwareInstanceNotReady raise SoftwareInstanceNotReady
software_instance = SoftwareInstance( parameter_dict = self._getSalePackingListLineAsSoftwareInstance(movement)
**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) return xml_marshaller.xml_marshaller.dumps(software_instance)
#################################################### ####################################################
......
...@@ -172,9 +172,14 @@ class OpenOrder(SlapDocument): ...@@ -172,9 +172,14 @@ class OpenOrder(SlapDocument):
else: else:
xml = self._connection_helper.response.read() xml = self._connection_helper.response.read()
software_instance = xml_marshaller.loads(xml) software_instance = xml_marshaller.loads(xml)
return ComputerPartition( computer_partition = ComputerPartition(
software_instance.slap_computer_id.encode('UTF-8'), software_instance.slap_computer_id.encode('UTF-8'),
software_instance.slap_computer_partition_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): def _syncComputerInformation(func):
""" """
...@@ -237,6 +242,8 @@ def _syncComputerPartitionInformation(func): ...@@ -237,6 +242,8 @@ def _syncComputerPartitionInformation(func):
Synchronize computer partition object with server information Synchronize computer partition object with server information
""" """
def decorated(self, *args, **kw): def decorated(self, *args, **kw):
if getattr(self, '_synced', 0):
return func(self, *args, **kw)
computer = self._connection_helper.getComputerInformation(self._computer_id) computer = self._connection_helper.getComputerInformation(self._computer_id)
found_computer_partition = None found_computer_partition = None
for computer_partition in computer._computer_partition_list: for computer_partition in computer._computer_partition_list:
...@@ -334,9 +341,14 @@ class ComputerPartition(SlapDocument): ...@@ -334,9 +341,14 @@ class ComputerPartition(SlapDocument):
else: else:
xml = self._connection_helper.response.read() xml = self._connection_helper.response.read()
software_instance = xml_marshaller.loads(xml) software_instance = xml_marshaller.loads(xml)
return ComputerPartition( computer_partition = ComputerPartition(
software_instance.slap_computer_id.encode('UTF-8'), software_instance.slap_computer_id.encode('UTF-8'),
software_instance.slap_computer_partition_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): def building(self):
self._connection_helper.POST('/buildingComputerPartition', { 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