Commit 3d598aa0 authored by Łukasz Nowak's avatar Łukasz Nowak

Support requestComputerPartition in more cases.

SlapTool itself shall not force to pass all possible parameters, as slap
library calls it in different ways.

Add support for lack of existence of computer_id and computer_partition_id,
in this case assume that human (person) is logged in by slap library.
parent 535cd83f
...@@ -256,9 +256,10 @@ class SlapTool(BaseTool): ...@@ -256,9 +256,10 @@ class SlapTool(BaseTool):
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'requestComputerPartition') 'requestComputerPartition')
def requestComputerPartition(self, computer_id, computer_partition_id, def requestComputerPartition(self, computer_id=None,
software_release, software_type, partition_reference, computer_partition_id=None, software_release=None, software_type=None,
shared_xml, partition_parameter_xml, filter_xml): partition_reference=None, shared_xml=None, partition_parameter_xml=None,
filter_xml=None):
""" """
Asynchronously requests creation of computer partition for assigned Asynchronously requests creation of computer partition for assigned
parameters parameters
...@@ -601,8 +602,10 @@ class SlapTool(BaseTool): ...@@ -601,8 +602,10 @@ class SlapTool(BaseTool):
instance_xml = etree.tostring(instance, pretty_print=True, instance_xml = etree.tostring(instance, pretty_print=True,
xml_declaration=True, encoding='utf-8') xml_declaration=True, encoding='utf-8')
software_instance_document = self._getSoftwareInstanceForComputerPartition( if computer_id and computer_partition_id:
computer_id, # requested by Software Instance, there is already top part of tree
software_instance_document = self.\
_getSoftwareInstanceForComputerPartition(computer_id,
computer_partition_id) computer_partition_id)
software_instance_document.requestSoftwareInstance( software_instance_document.requestSoftwareInstance(
software_release=software_release, software_release=software_release,
...@@ -623,6 +626,22 @@ class SlapTool(BaseTool): ...@@ -623,6 +626,22 @@ class SlapTool(BaseTool):
predecessor_related_uid=software_instance_document.getUid(), predecessor_related_uid=software_instance_document.getUid(),
title=partition_reference, title=partition_reference,
) )
else:
# requested as root, so done by human
person = self.getPortalObject()\
.ERP5Site_getAuthenticatedMemberPersonValue()
person.requestSoftwareInstance(software_release=software_release,
software_type=software_type,
software_title=partition_reference,
shared=shared,
instance_xml=instance_xml,
filter_kw=filter_kw)
requested_software_instance = person.portal_catalog.\
getResultValue(
portal_type="Software Instance",
source_reference=software_type,
title=partition_reference,
)
if requested_software_instance is None: if requested_software_instance is None:
raise SoftwareInstanceNotReady raise SoftwareInstanceNotReady
......
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