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