Commit 66990a19 authored by Antoine Catton's avatar Antoine Catton

Modifying request in order to support renaming of root.

parent 3bffc8d2
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from DateTime import DateTime\n
\n
portal = context.getPortalObject()\n
cleanup_resource = portal.portal_preferences.getPreferredInstanceCleanupResource()\n
\n
sale_order_portal_type = "Sale Order"\n
sale_order_line_portal_type = "Sale Order Line"\n
hosting_subscription_portal_type = "Hosting Subscription"\n
if context.isRootSlave():\n
software_instance_portal_type = "Slave Instance"\n
else:\n
software_instance_portal_type = "Software Instance"\n
\n
# Mostly copy and paste from\n
# portal_workflow/person_slap_interface_workflow/scripts/Person_requestSoftwareInstance\n
request_software_instance = None\n
for si in context.portal_catalog(portal_type=software_instance_portal_type,\n
title=context.getTitle(), root_uid=context.getUid()):\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() != \'delivered\':\n
request_software_instance = si\n
break\n
\n
if request_software_instance is None:\n
setup_service_relative_url = portal.portal_preferences.getPreferredInstanceSetupResource()\n
\n
request_software_instance = portal.getDefaultModule(portal_type=software_instance_portal_type).newContent(\n
portal_type=software_instance_portal_type,\n
source_reference=context.getSourceReference(),\n
title=context.getTitle(),\n
text_content=context.getTextContent(),\n
sla_xml=context.getSlaXml(),\n
activate_kw={\'tag\': tag},\n
**portal.Base_getNewSoftwareInstanceCoordinate()\n
)\n
request_software_instance.portal_workflow.doActionFor(request_software_instance, \'validate_action\')\n
context.setPredecessorValueList(\n
context.getPredecessorValueList() + [request_software_instance]\n
)\n
\n
if context.getRootState() == \'started\':\n
request_software_instance.startRequested()\n
elif context.getRootState() == \'stopped\':\n
request_software_instance.stopRequested()\n
else:\n
request_software_instance.edit(\n
text_content=context.getTextContent(),\n
source_reference=context.getSourceReference(),\n
sla_xml=context.getSlaXml(),\n
activate_kw={\'tag\': tag},\n
)\n
if context.getRootState() == \'started\':\n
request_software_instance.startRequested()\n
request_software_instance.activate(after_tag=tag).requestStartComputerPartition()\n
elif context.getRootState() == \'stopped\':\n
request_software_instance.stopRequested()\n
request_software_instance.activate(after_tag=tag).requestStopComputerPartition()\n
\n
return request_software_instance\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>HostingSubscription_requestRootSoftwareInstance</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -93,133 +93,102 @@ for hs in portal.portal_catalog(\n ...@@ -93,133 +93,102 @@ for hs in portal.portal_catalog(\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_software_instance = si\n request_hosting_subscription = hs\n
break\n break\n
else:\n else:\n
if cleanup_delivery_line.getSimulationState() != \'delivered\':\n if cleanup_delivery_line.getSimulationState() != \'delivered\':\n
request_software_instance = si\n request_hosting_subscription = hs\n
break\n break\n
\n \n
if request_software_instance is None and request_hosting_subscription 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
\n
if request_hosting_subscription 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
if (portal.portal_activities.countMessageWithTag(tag) > 0):\n setup_service_relative_url = portal.portal_preferences.getPreferredInstanceSetupResource()\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
\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
portal_type=hosting_subscription_portal_type,\n
reference=hosting_subscription_reference,\n
title=software_title,\n
activate_kw={\'tag\': tag},\n
)\n
subscription.setPredecessorValue(software_instance)\n
\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 subscription = portal.getDefaultModule(portal_type=hosting_subscription_portal_type).newContent(\n
portal_type=\'Software Release\',\n portal_type=hosting_subscription_portal_type,\n
url_string=software_release_url_string)\n reference=hosting_subscription_reference,\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
root_state=state,\n
software_release_url=software_release_url_string,\n
root_slave=is_slave,\n
)\n
software_instance = subscription.HostingSubscription_requestRootSoftwareInstance(tag)\n
\n \n
sale_order = portal.getDefaultModule(portal_type=sale_order_portal_type).newContent(\n software_release_document = context.portal_catalog.getResultValue(\n
portal_type=sale_order_portal_type,\n portal_type=\'Software Release\',\n
destination_value=person,\n url_string=software_release_url_string)\n
destination_section_value=person,\n
destination_decision_value=person,\n
start_date=DateTime(),\n
received_date=DateTime(),\n
# XXX Hardcoded values\n
source="organisation_module/vifib_internet",\n
source_section="organisation_module/vifib_internet",\n
price_currency="currency_module/EUR",\n
activate_kw={\'tag\': tag},\n
)\n
sale_order_line = sale_order.newContent(\n
portal_type=sale_order_line_portal_type,\n
resource=setup_service_relative_url,\n
quantity=1,\n
aggregate_value_list=[software_instance, subscription, software_release_document],\n
activate_kw={\'tag\': tag},\n
)\n
portal.portal_workflow.doActionFor(sale_order, "order_action")\n
\n \n
# Update Open Order\n sale_order = portal.getDefaultModule(portal_type=sale_order_portal_type).newContent(\n
# does this order have a client-specific Open Order\n portal_type=sale_order_portal_type,\n
open_order = portal.portal_catalog.getResultValue(\n destination_value=person,\n
default_destination_section_uid=person.getUid(),\n destination_section_value=person,\n
portal_type="Open Sale Order",\n destination_decision_value=person,\n
validation_state="validated")\n start_date=DateTime(),\n
if open_order is None:\n received_date=DateTime(),\n
person_slap_interface_state = person.getSlapState()\n # XXX Hardcoded values\n
if person_slap_interface_state == \'open_order_created\':\n source="organisation_module/vifib_internet",\n
open_order_url = context.portal_workflow.getInfoFor(\n source_section="organisation_module/vifib_internet",\n
ob=person, name=\'open_order_url\',\n price_currency="currency_module/EUR",\n
wf_id=\'person_slap_interface_workflow\')\n activate_kw={\'tag\': tag},\n
open_order = portal.restrictedTraverse(open_order_url)\n )\n
pass\n sale_order_line = sale_order.newContent(\n
else:\n portal_type=sale_order_line_portal_type,\n
raise ValueError(\'Person has no open order created\')\n resource=setup_service_relative_url,\n
quantity=1,\n
aggregate_value_list=[software_instance, subscription, software_release_document],\n
activate_kw={\'tag\': tag},\n
)\n
portal.portal_workflow.doActionFor(sale_order, "order_action")\n
\n \n
open_order.newContent(\n # Update Open Order\n
portal_type="Open Sale Order Line",\n # does this order have a client-specific Open Order\n
title=software_title,\n open_order = portal.portal_catalog.getResultValue(\n
aggregate_value=subscription,\n default_destination_section_uid=person.getUid(),\n
activate_kw={\'tag\': tag},\n portal_type="Open Sale Order",\n
)\n validation_state="validated")\n
if open_order is None:\n
person_slap_interface_state = person.getSlapState()\n
if person_slap_interface_state == \'open_order_created\':\n
open_order_url = context.portal_workflow.getInfoFor(\n
ob=person, name=\'open_order_url\',\n
wf_id=\'person_slap_interface_workflow\')\n
open_order = portal.restrictedTraverse(open_order_url)\n
pass\n
else:\n
raise ValueError(\'Person has no open order created\')\n
\n \n
# Find Computer partition\n open_order.newContent(\n
# XXX Link subscript to open order\n portal_type="Open Sale Order Line",\n
elif request_software_instance is None:\n title=software_title,\n
if (portal.portal_activities.countMessageWithTag(tag) > 0):\n aggregate_value=subscription,\n
# The software instance is already under creation but can not be fetched from catalog\n activate_kw={\'tag\': tag},\n
# As it is not possible to fetch informations, it is better to raise an error\n )\n
raise NotImplementedError(tag)\n
else:\n
setup_service_relative_url = portal.portal_preferences.getPreferredInstanceSetupResource()\n
\n \n
software_instance = portal.getDefaultModule(portal_type=software_instance_portal_type).newContent(\n # Find Computer partition\n
portal_type=software_instance_portal_type,\n # XXX Link subscript to open order\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
request_hosting_subscription.setPredecessorValueList(\n
request_hosting_subscription.getPredecessorList() + [software_instance])\n
else:\n else:\n
# Update existing software instance\n # Update existing software instance\n
request_software_instance.edit(\n request_hosting_subscription.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
if state == \'started\':\n requested_software_instance = request_hosting_subscription\\\n
request_software_instance.startRequested()\n .HostingSubscription_requestRootSoftwareInstance(tag)\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>
......
450 451
\ 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