[Erp5-report] r45398 luke - in /slapos/trunk/bt5/vifib_base: WorkflowTemplateItem/portal_wo...

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Apr 14 09:47:55 CEST 2011


Author: luke
Date: Thu Apr 14 09:47:54 2011
New Revision: 45398

URL: http://svn.erp5.org?rev=45398&view=rev
Log:
 - support cases without small amount free partitions which are frequently
   requested

When the amount of partition is really low it can happen that all free
partitions are below generated window. In such case script is responding,
randomly (beacuse of random), that there is no free computer partition (even
if they are). Switch to using randomised windown when amount of detected free
partitions is high enough to have any impact on ZODB based walking on result.

Also change cryptic 50 to SQL_WINDOW_SIZE.

Modified:
    slapos/trunk/bt5/vifib_base/WorkflowTemplateItem/portal_workflow/software_instance_slap_interface_workflow/scripts/SoftwareInstance_requestComputerPartition.xml
    slapos/trunk/bt5/vifib_base/bt/revision

Modified: slapos/trunk/bt5/vifib_base/WorkflowTemplateItem/portal_workflow/software_instance_slap_interface_workflow/scripts/SoftwareInstance_requestComputerPartition.xml
URL: http://svn.erp5.org/slapos/trunk/bt5/vifib_base/WorkflowTemplateItem/portal_workflow/software_instance_slap_interface_workflow/scripts/SoftwareInstance_requestComputerPartition.xml?rev=45398&r1=45397&r2=45398&view=diff
==============================================================================
--- slapos/trunk/bt5/vifib_base/WorkflowTemplateItem/portal_workflow/software_instance_slap_interface_workflow/scripts/SoftwareInstance_requestComputerPartition.xml [utf8] (original)
+++ slapos/trunk/bt5/vifib_base/WorkflowTemplateItem/portal_workflow/software_instance_slap_interface_workflow/scripts/SoftwareInstance_requestComputerPartition.xml [utf8] Thu Apr 14 09:47:54 2011
@@ -50,7 +50,9 @@
         </item>
         <item>
             <key> <string>_body</string> </key>
-            <value> <string>from DateTime import DateTime\n
+            <value> <string encoding="cdata"><![CDATA[
+
+from DateTime import DateTime\n
 import random\n
 \n
 software_instance = state_change[\'object\']\n
@@ -68,6 +70,8 @@ if packing_list_line is not None:\n
 # Find a free computer partition. This means:\n
 # Computer Partition which doesn\'t have non delivered sale packing list related\n
 \n
+SQL_WINDOW_SIZE = 50\n
+\n
 computer_partition = None\n
 query_kw = {\n
   \'software_release_url\': software_release_url_string,\n
@@ -84,9 +88,12 @@ if shared:\n
   result_count = software_instance.portal_catalog.countResults(**query_kw)[0][0]\n
 \n
   offset = max(0, result_count-1)\n
-\n
+  if offset >= SQL_WINDOW_SIZE:\n
+    limit = (random.randint(0, offset), SQL_WINDOW_SIZE)\n
+  else:\n
+    limit = (0, SQL_WINDOW_SIZE)\n
   for computer_partition_candidate in software_instance.portal_catalog(\n
-                                           limit=(random.randint(0, offset), 50), **query_kw):\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
     if computer_partition_candidate.getSlapState() == \'busy\' and computer_partition_candidate.ComputerPartition_isSlaveAvailable():\n
@@ -113,9 +120,13 @@ else:\n
   result_count = software_instance.portal_catalog.countResults(**query_kw)[0][0]\n
 \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
-                                           limit=(random.randint(0, offset), 50), **query_kw):\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
     if isTransitionPossible(computer_partition_candidate, \'mark_busy\'):\n
@@ -148,7 +159,9 @@ sale_packing_list_line = sale_packing_li
 \n
 # confirm Sale Packing List\n
 sale_packing_list.confirm()\n
-</string> </value>
+
+
+]]></string> </value>
         </item>
         <item>
             <key> <string>_params</string> </key>

Modified: slapos/trunk/bt5/vifib_base/bt/revision
URL: http://svn.erp5.org/slapos/trunk/bt5/vifib_base/bt/revision?rev=45398&r1=45397&r2=45398&view=diff
==============================================================================
--- slapos/trunk/bt5/vifib_base/bt/revision [utf8] (original)
+++ slapos/trunk/bt5/vifib_base/bt/revision [utf8] Thu Apr 14 09:47:54 2011
@@ -1 +1 @@
-225
\ No newline at end of file
+226
\ No newline at end of file



More information about the Erp5-report mailing list