Commit 9d0e91b1 authored by Łukasz Nowak's avatar Łukasz Nowak

Support repeated software instance title.

parent 0ed82865
......@@ -78,10 +78,22 @@ tag = "%s_%s_inProgress" % (person.getUid(), \n
software_title)\n
\n
# Check if it already exists\n
request_software_instance = portal.portal_catalog.getResultValue(\n
cleanup_resource = portal.portal_preferences.getPreferredInstanceCleanupResource()\n
request_software_instance = None\n
for si in portal.portal_catalog(\n
portal_type=software_instance_portal_type,\n
title=software_title,\n
)\n
):\n
try:\n
cleanup_delivery_line = si.Item_getInstancePackingListLine(cleanup_resource)\n
except ValueError:\n
request_software_instance = si\n
break\n
else:\n
if cleanup_delivery_line.getSimulationState() != \'destroyed\':\n
request_software_instance = si\n
break\n
\n
if (request_software_instance is None):\n
hosting_subscription_reference = "HOSTSUBS-%s" % context.getPortalObject().portal_ids\\\n
.generateNewId(id_group=\'slap_hosting_subscription_reference\', id_generator=\'uid\')\n
......
441
\ No newline at end of file
442
\ No newline at end of file
......@@ -745,6 +745,8 @@ class SlapTool(BaseTool):
else:
instance_portal_type = "Software Instance"
cleanup_resource = self.getPortalObject().portal_preferences\
.getPreferredInstanceCleanupResource()
if computer_id and computer_partition_id:
# requested by Software Instance, there is already top part of tree
software_instance_document = self.\
......@@ -781,15 +783,25 @@ class SlapTool(BaseTool):
instance_xml=instance_xml,
sla_xml=sla_xml,
state=state)
requested_software_instance = person.portal_catalog.\
getResultValue(
requested_software_instance = None
for software_instance in person.portal_catalog(
portal_type=instance_portal_type,
# In order be in sync with defaults of person.
# requestSoftwareInstance it is required to default here
# too
source_reference=software_type or 'RootSoftwareInstance',
title=partition_reference,
)
):
try:
cleanup_delivery_line = software_instance\
.Item_getInstancePackingListLine(cleanup_resource)
except ValueError:
requested_software_instance = software_instance
break
else:
if cleanup_delivery_line.getSimulationState() != 'delivered':
requested_software_instance = software_instance
break
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