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):
security.declareProtected(Permissions.AccessContentsInformation,
'requestComputerPartition')
def requestComputerPartition(self, computer_id, computer_partition_id,
software_release, software_type, partition_reference,
shared_xml, partition_parameter_xml, filter_xml):
def requestComputerPartition(self, computer_id=None,
computer_partition_id=None, software_release=None, software_type=None,
partition_reference=None, shared_xml=None, partition_parameter_xml=None,
filter_xml=None):
"""
Asynchronously requests creation of computer partition for assigned
parameters
......@@ -601,28 +602,46 @@ class SlapTool(BaseTool):
instance_xml = etree.tostring(instance, pretty_print=True,
xml_declaration=True, encoding='utf-8')
software_instance_document = self._getSoftwareInstanceForComputerPartition(
computer_id,
if computer_id and computer_partition_id:
# requested by Software Instance, there is already top part of tree
software_instance_document = self.\
_getSoftwareInstanceForComputerPartition(computer_id,
computer_partition_id)
software_instance_document.requestSoftwareInstance(
software_release=software_release,
software_type=software_type,
partition_reference=partition_reference,
shared=shared,
instance_xml=instance_xml,
filter_kw=filter_kw)
# Get requested software instance
requested_software_instance = software_instance_document.portal_catalog.\
getResultValue(
portal_type="Software Instance",
source_reference=software_type,
# predecessor_related_uid is inconsistent with
# SoftwareInstancae.requestSoftwareInstance but in this case it
# is assumed, that data are correct
predecessor_related_uid=software_instance_document.getUid(),
title=partition_reference,
)
software_instance_document.requestSoftwareInstance(
software_release=software_release,
software_type=software_type,
partition_reference=partition_reference,
shared=shared,
instance_xml=instance_xml,
filter_kw=filter_kw)
# Get requested software instance
requested_software_instance = software_instance_document.portal_catalog.\
getResultValue(
portal_type="Software Instance",
source_reference=software_type,
# predecessor_related_uid is inconsistent with
# SoftwareInstancae.requestSoftwareInstance but in this case it
# is assumed, that data are correct
predecessor_related_uid=software_instance_document.getUid(),
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:
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