From 02726df6261422b263959fc2f7c7c5e7e665513c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20Nowak?= <luke@nexedi.com>
Date: Thu, 15 Nov 2012 10:11:44 +0100
Subject: [PATCH] Rebrand building functionality.

Also drop 91761c1a56a84948e8b8199e97f575156bfdcde4, as in SlapOS deliveries
are not merged together.

Nevertheless 91761c1a56a introduced serious bug: as root_applied_rule.getPath
was not passed, searchMovementList from builder was returning a lot of
movements in case of system which has this alarm disabled, thus resulting in
enormous transaction per SimulationMovement_build*.

Even worse: passing path and explanation is mutually exclusive, as path is
internally recalculated by explanation.
---
 .../portal_alarms/slapos_trigger_build.xml}            |  6 +++---
 .../slapos_accounting/Alarm_buildSlapOSPath.xml}       |  4 ++--
 .../SimulationMovement_buildSlapOS.xml}                | 10 +++++-----
 master/bt5/slapos_accounting/bt/revision               |  2 +-
 master/bt5/slapos_accounting/bt/template_path_list     |  1 +
 master/bt5/vifib_slap/bt/revision                      |  2 +-
 master/bt5/vifib_slap/bt/template_path_list            |  1 -
 7 files changed, 13 insertions(+), 13 deletions(-)
 rename master/bt5/{vifib_slap/PathTemplateItem/portal_alarms/vifib_trigger_build.xml => slapos_accounting/PathTemplateItem/portal_alarms/slapos_trigger_build.xml} (92%)
 rename master/bt5/{vifib_slap/SkinTemplateItem/portal_skins/vifib_slap/Alarm_buildVifibPath.xml => slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Alarm_buildSlapOSPath.xml} (96%)
 rename master/bt5/{vifib_slap/SkinTemplateItem/portal_skins/vifib_slap/SimulationMovement_buildVifib.xml => slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/SimulationMovement_buildSlapOS.xml} (87%)

diff --git a/master/bt5/vifib_slap/PathTemplateItem/portal_alarms/vifib_trigger_build.xml b/master/bt5/slapos_accounting/PathTemplateItem/portal_alarms/slapos_trigger_build.xml
similarity index 92%
rename from master/bt5/vifib_slap/PathTemplateItem/portal_alarms/vifib_trigger_build.xml
rename to master/bt5/slapos_accounting/PathTemplateItem/portal_alarms/slapos_trigger_build.xml
index 5cc8d088e..8bc12da9f 100644
--- a/master/bt5/vifib_slap/PathTemplateItem/portal_alarms/vifib_trigger_build.xml
+++ b/master/bt5/slapos_accounting/PathTemplateItem/portal_alarms/slapos_trigger_build.xml
@@ -8,7 +8,7 @@
       <dictionary>
         <item>
             <key> <string>active_sense_method_id</string> </key>
-            <value> <string>Alarm_buildVifibPath</string> </value>
+            <value> <string>Alarm_buildSlapOSPath</string> </value>
         </item>
         <item>
             <key> <string>description</string> </key>
@@ -22,7 +22,7 @@
         </item>
         <item>
             <key> <string>id</string> </key>
-            <value> <string>vifib_trigger_build</string> </value>
+            <value> <string>slapos_trigger_build</string> </value>
         </item>
         <item>
             <key> <string>periodicity_hour</string> </key>
@@ -89,7 +89,7 @@
         </item>
         <item>
             <key> <string>title</string> </key>
-            <value> <string>Vifib Trigger Build</string> </value>
+            <value> <string>SlapOS Trigger Build</string> </value>
         </item>
       </dictionary>
     </pickle>
diff --git a/master/bt5/vifib_slap/SkinTemplateItem/portal_skins/vifib_slap/Alarm_buildVifibPath.xml b/master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Alarm_buildSlapOSPath.xml
similarity index 96%
rename from master/bt5/vifib_slap/SkinTemplateItem/portal_skins/vifib_slap/Alarm_buildVifibPath.xml
rename to master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Alarm_buildSlapOSPath.xml
index c56628376..ef4b1b202 100644
--- a/master/bt5/vifib_slap/SkinTemplateItem/portal_skins/vifib_slap/Alarm_buildVifibPath.xml
+++ b/master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Alarm_buildSlapOSPath.xml
@@ -60,7 +60,7 @@ kw.update(\n
 )\n
 \n
 context.getPortalObject().portal_catalog.searchAndActivate(\n
-  method_id=\'SimulationMovement_buildVifib\',\n
+  method_id=\'SimulationMovement_buildSlapOS\',\n
   packet_size=1, # Separate calls to many transactions\n
   method_kw={\'tag\': tag},\n
   activate_kw={\'tag\': tag},\n
@@ -78,7 +78,7 @@ context.activate(after_tag=tag).getId()\n
         </item>
         <item>
             <key> <string>id</string> </key>
-            <value> <string>Alarm_buildVifibPath</string> </value>
+            <value> <string>Alarm_buildSlapOSPath</string> </value>
         </item>
       </dictionary>
     </pickle>
diff --git a/master/bt5/vifib_slap/SkinTemplateItem/portal_skins/vifib_slap/SimulationMovement_buildVifib.xml b/master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/SimulationMovement_buildSlapOS.xml
similarity index 87%
rename from master/bt5/vifib_slap/SkinTemplateItem/portal_skins/vifib_slap/SimulationMovement_buildVifib.xml
rename to master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/SimulationMovement_buildSlapOS.xml
index dc1459e13..c45be6bcc 100644
--- a/master/bt5/vifib_slap/SkinTemplateItem/portal_skins/vifib_slap/SimulationMovement_buildVifib.xml
+++ b/master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/SimulationMovement_buildSlapOS.xml
@@ -60,13 +60,13 @@ if context.getDelivery() is not None:\n
   return\n
 \n
 root_applied_rule = context.getRootAppliedRule()\n
+root_applied_rule_path = root_applied_rule.getPath()\n
 \n
 business_link = context.getCausalityValue(portal_type=\'Business Link\')\n
-explanation = context.getImmediateExplanationValue()\n
-lock_tag = \'build_in_progress_%s_%s\' % (explanation.getUid(), business_link.getUid())\n
+lock_tag = \'build_in_progress_%s_%s\' % (business_link.getUid(), root_applied_rule.getUid())\n
 if context.getPortalObject().portal_activities.countMessageWithTag(lock_tag) == 0:\n
-  business_link.build(explanation=explanation, activate_kw={\'tag\': tag})\n
-  explanation.activate(activity=\'SQLQueue\', after_tag=tag, tag=lock_tag).getId()\n
+  business_link.build(path=\'%s/%%\' % root_applied_rule_path, activate_kw={\'tag\': tag})\n
+  root_applied_rule.activate(activity=\'SQLQueue\', after_tag=tag, tag=lock_tag).getId()\n
 </string> </value>
         </item>
         <item>
@@ -75,7 +75,7 @@ if context.getPortalObject().portal_activities.countMessageWithTag(lock_tag) ==
         </item>
         <item>
             <key> <string>id</string> </key>
-            <value> <string>SimulationMovement_buildVifib</string> </value>
+            <value> <string>SimulationMovement_buildSlapOS</string> </value>
         </item>
       </dictionary>
     </pickle>
diff --git a/master/bt5/slapos_accounting/bt/revision b/master/bt5/slapos_accounting/bt/revision
index 8580e7b68..b74e882ae 100644
--- a/master/bt5/slapos_accounting/bt/revision
+++ b/master/bt5/slapos_accounting/bt/revision
@@ -1 +1 @@
-30
\ No newline at end of file
+31
\ No newline at end of file
diff --git a/master/bt5/slapos_accounting/bt/template_path_list b/master/bt5/slapos_accounting/bt/template_path_list
index 982bcff46..8ee298baa 100644
--- a/master/bt5/slapos_accounting/bt/template_path_list
+++ b/master/bt5/slapos_accounting/bt/template_path_list
@@ -19,6 +19,7 @@ open_sale_order_module/template_open_sale_order
 organisation_module/slapos
 organisation_module/slapos/bank_account
 portal_alarms/slapos_request_update_hosting_subscription_open_sale_order
+portal_alarms/slapos_trigger_build
 portal_categories/trade_phase/slapos
 portal_categories/trade_phase/slapos/**
 portal_deliveries/slapos_sale_packing_list_builder
diff --git a/master/bt5/vifib_slap/bt/revision b/master/bt5/vifib_slap/bt/revision
index 1e140f3f4..aabe32b8b 100644
--- a/master/bt5/vifib_slap/bt/revision
+++ b/master/bt5/vifib_slap/bt/revision
@@ -1 +1 @@
-873
\ No newline at end of file
+874
\ No newline at end of file
diff --git a/master/bt5/vifib_slap/bt/template_path_list b/master/bt5/vifib_slap/bt/template_path_list
index b6621ed44..a007b41b3 100644
--- a/master/bt5/vifib_slap/bt/template_path_list
+++ b/master/bt5/vifib_slap/bt/template_path_list
@@ -11,6 +11,5 @@ portal_alarms/vifib_lock_person
 portal_alarms/vifib_lock_software_instance
 portal_alarms/vifib_request_destruction_selenium_tester_instance
 portal_alarms/vifib_set_priority_one_message_table
-portal_alarms/vifib_trigger_build
 portal_alarms/vifib_unlock_person
 portal_alarms/vifib_unlock_software_instance
\ No newline at end of file
-- 
2.30.9