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
# graph allows to "simulate" tree change after requested operation\n
graph = {}\n
# Get root software instance and create initial graph\n
predecessor_software_instance = software_instance\n
while (predecessor_software_instance is not None):\n
predecessor_software_instance_pred_uid_list = predecessor_software_instance.getPredecessorUidList()\n
graph[predecessor_software_instance.getUid()] = predecessor_software_instance_pred_uid_list\n
# as this walking is not fetching all instances fill predecessors into graph, in order to have\n
# "nearly" complete representation\n
for uid in predecessor_software_instance_pred_uid_list:\n
if uid not in graph:\n
graph[uid] = []\n
root_software_instance = predecessor_software_instance\n
predecessor_software_instance = predecessor_software_instance.getPredecessorRelatedValue(\n
portal_type="Software Instance")\n
root_hosting_subscription = software_instance.portal_catalog.getResultValue(\n
uid=software_instance.SoftwareInstance_getRootHostingSubscriptionUid(),\n
)\n
\n
predecessor_list = root_hosting_subscription.getPredecessorValueList()\n
while True:\n
try:\n
software_instance = predecessor_list.pop(0)\n
except IndexError:\n
break\n
software_instance_predecessor_list = software_instance.getPredecessorValueList() or []\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
tag = "%s_%s_inProgress" % (root_software_instance.getUid(),\n
tag = "%s_%s_inProgress" % (root_hosting_subscription.getUid(),\n
requested_partition_reference)\n
\n
# Check if it already exists\n
......@@ -94,20 +96,22 @@ request_software_instance = software_instance.portal_catalog.getResultValue(\n
# XXX: User based property is used in non manual operation\n
# XXX-2: Do we really need to use root_uid?\n
title=requested_partition_reference,\n
root_uid=root_software_instance.getUid(),\n
root_uid=root_hosting_subscription.getUid(),\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
# to find, just check if such request does not come and raise\n
if root_software_instance.getTitle() == requested_partition_reference:\n
raise ValueError(\'It is disallowed to request root software instance\')\n
\n
if (request_software_instance is None):\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
else:\n
# First time that the software instance is requested\n
# Create a new one\n
module = software_instance.getDefaultModule(portal_type="Software Instance")\n
......
331
\ No newline at end of file
332
\ 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