Commit 304c91b3 authored by Gabriel Monnerat's avatar Gabriel Monnerat

fix variable name according to your context

parent feae0415
......@@ -50,10 +50,10 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>software_instance = state_change[\'object\']\n
<value> <string>slave_instance = state_change[\'object\']\n
hosting_subscription_uid = state_change.kwargs[\'hosting_subscription_uid\']\n
hosting_subscription = software_instance.portal_catalog.getResultValue(uid=hosting_subscription_uid)\n
portal = software_instance.getPortalObject()\n
hosting_subscription = slave_instance.portal_catalog.getResultValue(uid=hosting_subscription_uid)\n
portal = slave_instance.getPortalObject()\n
\n
# Get services\n
portal_preferences = portal.portal_preferences\n
......
......@@ -50,8 +50,8 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>software_instance = state_change[\'object\']\n
software_instance.Base_checkConsistency()\n
<value> <string>slave_instance = state_change[\'object\']\n
slave_instance.Base_checkConsistency()\n
</string> </value>
</item>
<item>
......
......@@ -50,11 +50,11 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>software_instance = state_change[\'object\']\n
<value> <string>slave_instance = state_change[\'object\']\n
instance_setup_sale_packing_list_line = \\\n
context.SlaveInstance_getInstancePackingListLine(\n
state_change, \n
service_relative_url=software_instance.portal_preferences.\\\n
service_relative_url=slave_instance.portal_preferences.\\\n
getPreferredInstanceSetupResource())\n
instance_setup_sale_packing_list = instance_setup_sale_packing_list_line.getParentValue()\n
portal = context.getPortalObject()\n
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>software_instance = state_change[\'object\']\n
<value> <string>slave_instance = state_change[\'object\']\n
service_relative_url = software_instance.portal_preferences.\\\n
getPreferredInstanceHostingResource()\n
return context.SlaveInstance_getInstancePackingListLine(\n
......
......@@ -50,9 +50,9 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>software_instance = state_change[\'object\']\n
<value> <string>slave_instance = state_change[\'object\']\n
\n
portal = software_instance.getPortalObject()\n
portal = slave_instance.getPortalObject()\n
\n
# Get services\n
portal_preferences = portal.portal_preferences\n
......@@ -79,15 +79,14 @@ state_list.extend(portal.getPortalCurrentInventoryStateList())\n
packing_list_line = portal.portal_catalog.getResultValue(\n
portal_type=\'Sale Packing List Line\',\n
simulation_state=state_list,\n
aggregate_uid=software_instance.getUid(),\n
aggregate_uid=slave_instance.getUid(),\n
default_resource_uid=service_uid_list,\n
sort_on=((\'movement.start_date\', \'DESC\'),),\n
limit=1,\n
)\n
\n
if packing_list_line is None:\n
raise ValueError("No sale packing list line found for %s" % \\\n
software_instance.getRelativeUrl())\n
raise ValueError("No sale packing list line found for %s - %s" % (slave_instance.getRelativeUrl(),slave_instance.getPortalType()))\n
else:\n
return packing_list_line\n
</string> </value>
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>software_instance = state_change[\'object\']\n
<value> <string>slave_instance = state_change[\'object\']\n
service_relative_url = software_instance.portal_preferences.\\\n
getPreferredInstanceSetupResource()\n
return context.SlaveInstance_getInstancePackingListLine(\n
......
......@@ -55,7 +55,7 @@
from DateTime import DateTime\n
import random\n
\n
software_instance = state_change[\'object\']\n
slave_instance = state_change[\'object\']\n
software_release_url_string = state_change.kwargs[\'software_release\']\n
hosting_subscription_uid = state_change.kwargs[\'hosting_subscription_uid\']\n
shared = state_change.kwargs[\'shared\']\n
......@@ -64,9 +64,9 @@ tag = state_change.kwargs[\'tag\']\n
filter_kw = state_change.kwargs["filter_kw"]\n
\n
# Assertion: No packing list line should be related to this software instance\n
packing_list_line = software_instance.getAggregateRelatedValue(portal_type=\'Sale Packing List Line\')\n
packing_list_line = slave_instance.getAggregateRelatedValue(portal_type=\'Sale Packing List Line\')\n
if packing_list_line is not None:\n
raise ValueError("Software Instance %s is already associated to a packing list line" % software_instance.getRelativeurl())\n
raise ValueError("Software Instance %s is already associated to a packing list line" % slave_instance.getRelativeurl())\n
\n
# Find a free computer partition. This means:\n
# Computer Partition which doesn\'t have non delivered sale packing list related\n
......@@ -83,16 +83,16 @@ if "computer_guid" in filter_kw:\n
query_kw["parent_reference"] = filter_kw["computer_guid"]\n
\n
# fetch at mot 50 random Computer Partitions, and check if they are ok\n
isTransitionPossible = software_instance.getPortalObject().portal_workflow.isTransitionPossible\n
isTransitionPossible = slave_instance.getPortalObject().portal_workflow.isTransitionPossible\n
query_kw.update(free_for_request=1) # is free\n
result_count = software_instance.portal_catalog.countResults(**query_kw)[0][0]\n
result_count = slave_instance.portal_catalog.countResults(**query_kw)[0][0]\n
offset = max(0, result_count-1)\n
if offset >= SQL_WINDOW_SIZE:\n
limit = (random.randint(0, offset), SQL_WINDOW_SIZE)\n
else:\n
limit = (0, SQL_WINDOW_SIZE)\n
\n
for computer_partition_candidate in software_instance.portal_catalog(\n
for computer_partition_candidate in slave_instance.portal_catalog(\n
limit=limit, **query_kw):\n
computer_partition_candidate = computer_partition_candidate.getObject()\n
# Check if the computer partition can be marked as busy (done by an interaction workflow on sale packing list level)\n
......@@ -112,7 +112,7 @@ software_release_document = context.portal_catalog.getResultValue(\n
# protect computer partition from being selected again\n
portal = context.getPortalObject()\n
\n
hosting_subscription = software_instance.portal_catalog.getResultValue(uid=hosting_subscription_uid)\n
hosting_subscription = slave_instance.portal_catalog.getResultValue(uid=hosting_subscription_uid)\n
sale_packing_list_line = context.HostingSubscription_getInstancePackingListLine(state_change)\n
base_sale_packing_list = sale_packing_list_line.getParentValue()\n
# XXX: SlaveInstance_createSalePackingList shall be used to create new Sale Packing List\n
......@@ -135,7 +135,7 @@ sale_packing_list = sale_packing_list_module.newContent(\n
sale_packing_list_line = sale_packing_list.newContent(\n
portal_type=\'Sale Packing List Line\',\n
resource=context.portal_preferences.getPreferredInstanceSetupResource(),\n
aggregate_value_list=[software_instance, software_release_document, computer_partition, hosting_subscription]\n
aggregate_value_list=[slave_instance, software_release_document, computer_partition, hosting_subscription]\n
)\n
\n
# confirm Sale Packing List\n
......
......@@ -52,8 +52,8 @@
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
software_instance = state_change[\'object\']\n
service_relative_url = software_instance.portal_preferences.\\\n
slave_instance = state_change[\'object\']\n
service_relative_url = slave_instance.portal_preferences.\\\n
getPreferredInstanceHostingResource()\n
need_to_create_packing_list = False\n
try:\n
......@@ -75,11 +75,11 @@ else:\n
\n
portal = context.getPortalObject()\n
if need_to_create_packing_list:\n
tag = "%s_startInProgress" % software_instance.getUid()\n
tag = "%s_startInProgress" % slave_instance.getUid()\n
if (portal.portal_activities.countMessageWithTag(tag) > 0):\n
raise ValueError("Slave Instance is currently being started.")\n
# lock software instance in transaction\n
software_instance.serialize()\n
slave_instance.serialize()\n
sale_packing_list = context.SlaveInstance_createSalePackingList(state_change, service_relative_url, tag)\n
sale_packing_list.confirm(activate_kw={\'tag\':tag})\n
......
249
\ No newline at end of file
250
\ 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