Commit 8d3527d0 authored by Antoine Catton's avatar Antoine Catton

Adapt SoftwareInstance_requestSoftwareInstance to root hosting subscription design.

parent 51d1ad69
...@@ -72,20 +72,22 @@ else:\n ...@@ -72,20 +72,22 @@ else:\n
# graph allows to "simulate" tree change after requested operation\n # graph allows to "simulate" tree change after requested operation\n
graph = {}\n graph = {}\n
# Get root software instance and create initial graph\n # Get root software instance and create initial graph\n
predecessor_software_instance = software_instance\n root_hosting_subscription = software_instance.portal_catalog.getResultValue(\n
while (predecessor_software_instance is not None):\n uid=software_instance.SoftwareInstance_getRootHostingSubscriptionUid(),\n
predecessor_software_instance_pred_uid_list = predecessor_software_instance.getPredecessorUidList()\n )\n
graph[predecessor_software_instance.getUid()] = predecessor_software_instance_pred_uid_list\n \n
# as this walking is not fetching all instances fill predecessors into graph, in order to have\n predecessor_list = root_hosting_subscription.getPredecessorValueList()\n
# "nearly" complete representation\n while True:\n
for uid in predecessor_software_instance_pred_uid_list:\n try:\n
if uid not in graph:\n software_instance = predecessor_list.pop(0)\n
graph[uid] = []\n except IndexError:\n
root_software_instance = predecessor_software_instance\n break\n
predecessor_software_instance = predecessor_software_instance.getPredecessorRelatedValue(\n software_instance_predecessor_list = software_instance.getPredecessorValueList() or []\n
portal_type="Software Instance")\n graph[software_instance.getUid()] = [predecessor.getUid()\n
for predecessor in software_instance_predecessor_list]\n
predecessor_list.extend(software_instance_predecessor_list)\n
\n \n
tag = "%s_%s_inProgress" % (root_software_instance.getUid(),\n tag = "%s_%s_inProgress" % (root_hosting_subscription.getUid(),\n
requested_partition_reference)\n requested_partition_reference)\n
\n \n
# Check if it already exists\n # Check if it already exists\n
...@@ -94,40 +96,42 @@ request_software_instance = software_instance.portal_catalog.getResultValue(\n ...@@ -94,40 +96,42 @@ request_software_instance = software_instance.portal_catalog.getResultValue(\n
# XXX: User based property is used in non manual operation\n # XXX: User based property is used in non manual operation\n
# XXX-2: Do we really need to use root_uid?\n # XXX-2: Do we really need to use root_uid?\n
title=requested_partition_reference,\n title=requested_partition_reference,\n
root_uid=root_software_instance.getUid(),\n root_uid=root_hosting_subscription.getUid(),\n
)\n )\n
\n \n
if (portal.portal_activities.countMessageWithTag(tag) > 0):\n
# The software instance is already under creation but can not be fetched from catalog\n
# As it is not possible to fetch informations, it is better to raise an error\n
raise NotImplementedError(tag)\n
\n
root_software_instance = root_hosting_subscription.HostingSubscription_requestRootSoftwareInstance(tag)\n
\n
# above query does not find root software instance, but as this case is easy\n # above query does not find root software instance, but as this case is easy\n
# to find, just check if such request does not come and raise\n # to find, just check if such request does not come and raise\n
if root_software_instance.getTitle() == requested_partition_reference:\n if root_software_instance.getTitle() == requested_partition_reference:\n
raise ValueError(\'It is disallowed to request root software instance\')\n raise ValueError(\'It is disallowed to request root software instance\')\n
\n \n
if (request_software_instance is None):\n if (request_software_instance is None):\n
if (portal.portal_activities.countMessageWithTag(tag) > 0):\n # First time that the software instance is requested\n
# The software instance is already under creation but can not be fetched from catalog\n # Create a new one\n
# As it is not possible to fetch informations, it is better to raise an error\n module = software_instance.getDefaultModule(portal_type="Software Instance")\n
raise NotImplementedError(tag)\n request_software_instance = module.newContent(\n
else:\n portal_type=software_instance_portal_type,\n
# First time that the software instance is requested\n title=requested_partition_reference,\n
# Create a new one\n source_reference=software_type,\n
module = software_instance.getDefaultModule(portal_type="Software Instance")\n text_content=instance_xml,\n
request_software_instance = module.newContent(\n sla_xml=sla_xml,\n
portal_type=software_instance_portal_type,\n activate_kw={\'tag\': tag},\n
title=requested_partition_reference,\n **portal.Base_getNewSoftwareInstanceCoordinate()\n
source_reference=software_type,\n )\n
text_content=instance_xml,\n request_software_instance.portal_workflow.doActionFor(request_software_instance, \'validate_action\')\n
sla_xml=sla_xml,\n sale_packing_list_line = context.SoftwareInstance_getInstanceSetupPackingListLine(state_change)\n
activate_kw={\'tag\': tag},\n hosting_subscription_uid = sale_packing_list_line.getAggregateValue(portal_type=\'Hosting Subscription\').getUid()\n
**portal.Base_getNewSoftwareInstanceCoordinate()\n request_software_instance.requestComputerPartition(\n
)\n software_release=software_release_url_string,\n
request_software_instance.portal_workflow.doActionFor(request_software_instance, \'validate_action\')\n hosting_subscription_uid=hosting_subscription_uid,\n
sale_packing_list_line = context.SoftwareInstance_getInstanceSetupPackingListLine(state_change)\n software_type=software_type,\n
hosting_subscription_uid = sale_packing_list_line.getAggregateValue(portal_type=\'Hosting Subscription\').getUid()\n tag=tag)\n
request_software_instance.requestComputerPartition(\n
software_release=software_release_url_string,\n
hosting_subscription_uid=hosting_subscription_uid,\n
software_type=software_type,\n
tag=tag)\n
else:\n else:\n
# Update existing software instance\n # Update existing software instance\n
# Sale Packing List interaction has to be requested automatically with an interaction workflow\n # Sale Packing List interaction has to be requested automatically with an interaction workflow\n
......
331 332
\ No newline at end of file \ No newline at end of file
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