Commit 6a4aed6e authored by Antoine Catton's avatar Antoine Catton

Restore Person_requestSoftwareInstance script from master.

parent a828e2de
...@@ -75,59 +75,60 @@ if is_slave == True:\n ...@@ -75,59 +75,60 @@ if is_slave == True:\n
else:\n else:\n
software_instance_portal_type = "Software Instance"\n software_instance_portal_type = "Software Instance"\n
\n \n
tag = "%s_%s_inProgress" % (person.getUid(),\n 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
cleanup_resource = portal.portal_preferences.getPreferredInstanceCleanupResource()\n cleanup_resource = portal.portal_preferences.getPreferredInstanceCleanupResource()\n
request_software_instance = None\n request_software_instance = None\n
request_hosting_subscription = None\n for si in portal.portal_catalog(\n
for hs in portal.portal_catalog(\n portal_type=software_instance_portal_type,\n
portal_type=hosting_subscription_portal_type,\n
title=software_title,\n title=software_title,\n
):\n ):\n
si_list = hs.portal_catalog(portal_type=software_instance_portal_type,\n
title=software_title, root_uid=hs.getUid())\n
if len(si_list) == 0:\n
request_hosting_subscription = hs\n
for si in si_list:\n
try:\n try:\n
cleanup_delivery_line = si.Item_getInstancePackingListLine(cleanup_resource)\n cleanup_delivery_line = si.Item_getInstancePackingListLine(cleanup_resource)\n
except ValueError:\n except ValueError:\n
request_hosting_subscription = hs\n request_software_instance = si\n
break\n break\n
else:\n else:\n
if cleanup_delivery_line.getSimulationState() != \'delivered\':\n if cleanup_delivery_line.getSimulationState() != \'delivered\':\n
request_hosting_subscription = hs\n request_software_instance = si\n
break\n break\n
\n \n
if (portal.portal_activities.countMessageWithTag(tag) > 0):\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
if (portal.portal_activities.countMessageWithTag(tag) > 0):\n
# The software instance is already under creation but can not be fetched from catalog\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 # As it is not possible to fetch informations, it is better to raise an error\n
raise NotImplementedError(tag)\n raise NotImplementedError(tag)\n
else:\n
\n \n
if request_hosting_subscription is None:\n
hosting_subscription_reference = "HOSTSUBS-%s" % context.getPortalObject().portal_ids\\\n
.generateNewId(id_group=\'slap_hosting_subscription_reference\', id_generator=\'uid\')\n
setup_service_relative_url = portal.portal_preferences.getPreferredInstanceSetupResource()\n setup_service_relative_url = portal.portal_preferences.getPreferredInstanceSetupResource()\n
\n software_instance = portal.getDefaultModule(portal_type=software_instance_portal_type).newContent(\n
portal_type=software_instance_portal_type,\n
source_reference=software_type,\n
title=software_title,\n
text_content=instance_xml,\n
sla_xml=sla_xml,\n
activate_kw={\'tag\': tag},\n
**portal.Base_getNewSoftwareInstanceCoordinate()\n
)\n
software_instance.portal_workflow.doActionFor(software_instance, \'validate_action\')\n
subscription = portal.getDefaultModule(portal_type=hosting_subscription_portal_type).newContent(\n subscription = portal.getDefaultModule(portal_type=hosting_subscription_portal_type).newContent(\n
portal_type=hosting_subscription_portal_type,\n portal_type=hosting_subscription_portal_type,\n
reference=hosting_subscription_reference,\n reference=hosting_subscription_reference,\n
title=software_title,\n title=software_title,\n
activate_kw={\'tag\': tag},\n
source_reference=software_type,\n
text_content=instance_xml,\n
sla_xml=sla_xml,\n
periodicity_hour_list=[0],\n periodicity_hour_list=[0],\n
periodicity_minute_list=[0],\n periodicity_minute_list=[0],\n
periodicity_month_day=[1],\n periodicity_month_day=[1],\n
root_state=state,\n activate_kw={\'tag\': tag},\n
root_software_release_url=software_release_url_string,\n
root_slave=is_slave,\n
)\n )\n
subscription.portal_workflow.doActionFor(subscription, \'validate_action\')\n subscription.portal_workflow.doActionFor(subscription, \'validate_action\')\n
software_instance = subscription.HostingSubscription_requestRootSoftwareInstance(tag, person_request=True)\n if state == \'started\':\n
software_instance.startRequested()\n
elif state == \'stopped\':\n
software_instance.stopRequested()\n
\n \n
software_release_document = context.portal_catalog.getResultValue(\n software_release_document = context.portal_catalog.getResultValue(\n
portal_type=\'Software Release\',\n portal_type=\'Software Release\',\n
...@@ -170,7 +171,6 @@ if request_hosting_subscription is None:\n ...@@ -170,7 +171,6 @@ if request_hosting_subscription is None:\n
ob=person, name=\'open_order_url\',\n ob=person, name=\'open_order_url\',\n
wf_id=\'person_slap_interface_workflow\')\n wf_id=\'person_slap_interface_workflow\')\n
open_order = portal.restrictedTraverse(open_order_url)\n open_order = portal.restrictedTraverse(open_order_url)\n
pass\n
else:\n else:\n
raise ValueError(\'Person has no open order created\')\n raise ValueError(\'Person has no open order created\')\n
\n \n
...@@ -204,17 +204,18 @@ if request_hosting_subscription is None:\n ...@@ -204,17 +204,18 @@ if request_hosting_subscription is None:\n
# XXX Link subscript to open order\n # XXX Link subscript to open order\n
else:\n else:\n
# Update existing software instance\n # Update existing software instance\n
request_hosting_subscription.edit(\n request_software_instance.edit(\n
text_content=instance_xml,\n text_content=instance_xml,\n
source_reference=software_type,\n source_reference=software_type,\n
sla_xml=sla_xml,\n sla_xml=sla_xml,\n
root_state=state,\n
software_release_url=software_release_url_string,\n
root_slave=is_slave,\n
activate_kw={\'tag\': tag},\n activate_kw={\'tag\': tag},\n
)\n )\n
requested_software_instance = request_hosting_subscription\\\n if state == \'started\':\n
.HostingSubscription_requestRootSoftwareInstance(tag)\n request_software_instance.startRequested()\n
request_software_instance.activate(after_tag=tag).requestStartComputerPartition()\n
elif state == \'stopped\':\n
request_software_instance.stopRequested()\n
request_software_instance.activate(after_tag=tag).requestStopComputerPartition()\n
]]></string> </value> ]]></string> </value>
......
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