From 24986ef94768bab93446fd31ab2779807d414461 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20Nowak?= <luke@nexedi.com>
Date: Thu, 11 Oct 2012 17:24:45 +0200
Subject: [PATCH] Alarm to assert that SI related to HS has same title.

---
 ...ssert_hosting_subscription_predecessor.xml | 91 +++++++++++++++++++
 ...ssertHostingSubscriptionHasPredecessor.xml | 83 +++++++++++++++++
 .../HostingSubscription_assertPredecessor.xml | 82 +++++++++++++++++
 master/bt5/vifib_slap/bt/revision             |  2 +-
 master/bt5/vifib_slap/bt/template_path_list   | 22 +----
 5 files changed, 258 insertions(+), 22 deletions(-)
 create mode 100644 master/bt5/vifib_slap/PathTemplateItem/portal_alarms/vifib_assert_hosting_subscription_predecessor.xml
 create mode 100644 master/bt5/vifib_slap/SkinTemplateItem/portal_skins/vifib_slap/Alarm_assertHostingSubscriptionHasPredecessor.xml
 create mode 100644 master/bt5/vifib_slap/SkinTemplateItem/portal_skins/vifib_slap/HostingSubscription_assertPredecessor.xml

diff --git a/master/bt5/vifib_slap/PathTemplateItem/portal_alarms/vifib_assert_hosting_subscription_predecessor.xml b/master/bt5/vifib_slap/PathTemplateItem/portal_alarms/vifib_assert_hosting_subscription_predecessor.xml
new file mode 100644
index 000000000..f7aab9a8a
--- /dev/null
+++ b/master/bt5/vifib_slap/PathTemplateItem/portal_alarms/vifib_assert_hosting_subscription_predecessor.xml
@@ -0,0 +1,91 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <global name="Alarm" module="erp5.portal_type"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>active_sense_method_id</string> </key>
+            <value> <string>Alarm_assertHostingSubscriptionHasPredecessor</string> </value>
+        </item>
+        <item>
+            <key> <string>description</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>enabled</string> </key>
+            <value> <int>1</int> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>vifib_assert_hosting_subscription_predecessor</string> </value>
+        </item>
+        <item>
+            <key> <string>periodicity_hour</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>periodicity_minute</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>periodicity_minute_frequency</string> </key>
+            <value> <int>1</int> </value>
+        </item>
+        <item>
+            <key> <string>periodicity_month</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>periodicity_month_day</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>periodicity_start_date</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="DateTime" module="DateTime.DateTime"/>
+                </klass>
+                <tuple>
+                  <none/>
+                </tuple>
+                <state>
+                  <tuple>
+                    <float>315532800.0</float>
+                    <string>GMT</string>
+                  </tuple>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>periodicity_week</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>portal_type</string> </key>
+            <value> <string>Alarm</string> </value>
+        </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <string>Asserts that Hosting Subscription has predecessor with same title</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/master/bt5/vifib_slap/SkinTemplateItem/portal_skins/vifib_slap/Alarm_assertHostingSubscriptionHasPredecessor.xml b/master/bt5/vifib_slap/SkinTemplateItem/portal_skins/vifib_slap/Alarm_assertHostingSubscriptionHasPredecessor.xml
new file mode 100644
index 000000000..148777276
--- /dev/null
+++ b/master/bt5/vifib_slap/SkinTemplateItem/portal_skins/vifib_slap/Alarm_assertHostingSubscriptionHasPredecessor.xml
@@ -0,0 +1,83 @@
+<?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 encoding="cdata"><![CDATA[
+
+portal = context.getPortalObject()\n
+from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, NegatedQuery\n
+\n
+portal.portal_catalog.searchAndActivate(\n
+  portal_type=\'Hosting Subscription\',\n
+  validation_state=\'validated\',\n
+  where_expression="related_predecessor_title_1_catalog.title <> catalog.title",\n
+  predecessor_title=NegatedQuery(SimpleQuery(predecessor_title=None, comparison_operator=\'is\')),\n
+  method_id=\'HostingSubscription_assertPredecessor\',\n
+  activate_kw={\'tag\': tag}\n
+)\n
+\n
+context.activate(after_tag=tag).getId()\n
+
+
+]]></string> </value>
+        </item>
+        <item>
+            <key> <string>_params</string> </key>
+            <value> <string>tag, fixit, params</string> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>Alarm_assertHostingSubscriptionHasPredecessor</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/master/bt5/vifib_slap/SkinTemplateItem/portal_skins/vifib_slap/HostingSubscription_assertPredecessor.xml b/master/bt5/vifib_slap/SkinTemplateItem/portal_skins/vifib_slap/HostingSubscription_assertPredecessor.xml
new file mode 100644
index 000000000..91ea88186
--- /dev/null
+++ b/master/bt5/vifib_slap/SkinTemplateItem/portal_skins/vifib_slap/HostingSubscription_assertPredecessor.xml
@@ -0,0 +1,82 @@
+<?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>if context.getPortalType() != \'Hosting Subscription\' \\\n
+  or context.getValidationState() != \'validated\' \\\n
+  or context.getSlapState() not in [\'start_requested\', \'stop_requested\'] \\\n
+  or context.getTitle() in context.getPredecessorTitleList():\n
+  # nothing to do\n
+  return\n
+\n
+context.requestInstance(\n
+  software_release=context.getRootSoftwareReleaseUrl(),\n
+  software_title=context.getTitle(),\n
+  software_type=context.getSourceReference(),\n
+  instance_xml=context.getTextContent(),\n
+  sla_xml=context.getSlaXml(),\n
+  shared=context.isRootSlave(),\n
+  state={\'start_requested\': \'started\', \'stop_requested\': \'stopped\'}[context.getSlapState()],\n
+)\n
+</string> </value>
+        </item>
+        <item>
+            <key> <string>_params</string> </key>
+            <value> <string></string> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>HostingSubscription_assertPredecessor</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/master/bt5/vifib_slap/bt/revision b/master/bt5/vifib_slap/bt/revision
index bbc7758aa..3e90fddab 100644
--- a/master/bt5/vifib_slap/bt/revision
+++ b/master/bt5/vifib_slap/bt/revision
@@ -1 +1 @@
-832
\ No newline at end of file
+833
\ 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 5023798e5..3e90fddab 100644
--- a/master/bt5/vifib_slap/bt/template_path_list
+++ b/master/bt5/vifib_slap/bt/template_path_list
@@ -1,21 +1 @@
-portal_alarms/cleanup_active_process
-portal_alarms/confirm_ordered_sale_order
-portal_alarms/confirm_planned_sale_invoice_transaction
-portal_alarms/deliver_subscription_sale_packing_list
-portal_alarms/free_computer_partition
-portal_alarms/garbage_collect_destroyed_root_tree
-portal_alarms/order_planned_sale_order
-portal_alarms/stop_confirmed_sale_invoice_transaction
-portal_alarms/vifib_bang_selenium_tester_instance
-portal_alarms/vifib_cancel_destroy_partition
-portal_alarms/vifib_cancel_update_partition
-portal_alarms/vifib_check_consistency
-portal_alarms/vifib_clone_destroy_partition
-portal_alarms/vifib_lock_person
-portal_alarms/vifib_lock_software_instance
-portal_alarms/vifib_person_update_open_order
-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
+833
\ No newline at end of file
-- 
2.30.9