From eee63a744270c9e8ab41a38cbf1c473b07868337 Mon Sep 17 00:00:00 2001
From: Alain Takoudjou <talino@tiolive.com>
Date: Mon, 28 Jul 2014 16:55:52 +0200
Subject: [PATCH] Rename HostingSubscription_checkSofwareInstanceState, set
 alarm period to 30 minutes

---
 .../slapos_crm_check_partially_allocated_instance.xml  | 10 +++++-----
 ...Alarm_findAndNofitiyUnallocatedSoftwareInstance.xml |  9 +++++----
 ...bscription_checkSofwareInstanceAllocationState.xml} |  9 ++++-----
 master/bt5/slapos_crm/bt/revision                      |  2 +-
 4 files changed, 15 insertions(+), 15 deletions(-)
 rename master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/{HostingSubscription_checkSofwareInstanceState.xml => HostingSubscription_checkSofwareInstanceAllocationState.xml} (91%)

diff --git a/master/bt5/slapos_crm/PathTemplateItem/portal_alarms/slapos_crm_check_partially_allocated_instance.xml b/master/bt5/slapos_crm/PathTemplateItem/portal_alarms/slapos_crm_check_partially_allocated_instance.xml
index c2ac48552..9bd75aa5e 100644
--- a/master/bt5/slapos_crm/PathTemplateItem/portal_alarms/slapos_crm_check_partially_allocated_instance.xml
+++ b/master/bt5/slapos_crm/PathTemplateItem/portal_alarms/slapos_crm_check_partially_allocated_instance.xml
@@ -26,13 +26,15 @@
             <key> <string>periodicity_hour</string> </key>
             <value>
               <tuple>
-                <int>1</int>
+                <int>0</int>
               </tuple>
             </value>
         </item>
         <item>
             <key> <string>periodicity_hour_frequency</string> </key>
-            <value> <int>1</int> </value>
+            <value>
+              <none/>
+            </value>
         </item>
         <item>
             <key> <string>periodicity_minute</string> </key>
@@ -44,9 +46,7 @@
         </item>
         <item>
             <key> <string>periodicity_minute_frequency</string> </key>
-            <value>
-              <none/>
-            </value>
+            <value> <int>30</int> </value>
         </item>
         <item>
             <key> <string>periodicity_month</string> </key>
diff --git a/master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/Alarm_findAndNofitiyUnallocatedSoftwareInstance.xml b/master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/Alarm_findAndNofitiyUnallocatedSoftwareInstance.xml
index e842a2941..c5f56084c 100644
--- a/master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/Alarm_findAndNofitiyUnallocatedSoftwareInstance.xml
+++ b/master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/Alarm_findAndNofitiyUnallocatedSoftwareInstance.xml
@@ -63,20 +63,21 @@ software_instance_list = context.portal_catalog(\n
   # XXX slap_state=["start_requested", "stop_requested"],\n
   default_aggregate_uid=None,\n
   select_dict=select_dict,\n
-  left_join_list=select_dict.keys()\n
+  left_join_list=select_dict.keys(),\n
+  group_by="specialise_uid"\n
   )\n
 \n
 #Get the list of concerned Hosting Subscription reference\n
-hs_reference_list = set([si.getSpecialiseReference() for si in software_instance_list \n
+hs_reference_list = [si.getSpecialiseReference() for si in software_instance_list \n
                    if si.getSlapState() in [\'start_requested\', \'stop_requested\']\n
-                  ])\n
+                  ]\n
 \n
 if len(hs_reference_list) > 0:\n
   portal.portal_catalog.searchAndActivate(\n
     portal_type=\'Hosting Subscription\',\n
     validation_state=\'validated\',\n
     reference=hs_reference_list,\n
-    method_id=\'HostingSubscription_checkSofwareInstanceState\',\n
+    method_id=\'HostingSubscription_checkSofwareInstanceAllocationState\',\n
     activate_kw = {\'tag\':tag}\n
   )\n
 \n
diff --git a/master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/HostingSubscription_checkSofwareInstanceState.xml b/master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/HostingSubscription_checkSofwareInstanceAllocationState.xml
similarity index 91%
rename from master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/HostingSubscription_checkSofwareInstanceState.xml
rename to master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/HostingSubscription_checkSofwareInstanceAllocationState.xml
index f33a04284..772886ab2 100644
--- a/master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/HostingSubscription_checkSofwareInstanceState.xml
+++ b/master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/HostingSubscription_checkSofwareInstanceAllocationState.xml
@@ -88,11 +88,10 @@ for instance in software_instance_list:\n
 \n
 if has_unallocated_instance and has_newest_allocated_instance:\n
   return context.Base_generateSupportRequestForSlapOS(\n
-    "Hosting Subscription %s (%s) is partially allocated" % (hs_title,\n
-                                                          hosting_subscription.getReference()),\n
-    "%s has allocated instance(s) but, instance %s (%s) has been unallocated for more than 4 hours." % (\n
+    "Hosting Subscription %s is partially allocated" % hs_title,\n
+    "%s has allocated instance(s) but, the instance %s (%s) has been unallocated for more than 4 hours." % (\n
       hs_title, failing_instance.getTitle(), failing_instance.getAbsoluteUrl()),\n
-    source_instance.getRelativeUrl())\n
+    hosting_subscription.getRelativeUrl())\n
 else:\n
   return\n
 
@@ -105,7 +104,7 @@ else:\n
         </item>
         <item>
             <key> <string>id</string> </key>
-            <value> <string>HostingSubscription_checkSofwareInstanceState</string> </value>
+            <value> <string>HostingSubscription_checkSofwareInstanceAllocationState</string> </value>
         </item>
       </dictionary>
     </pickle>
diff --git a/master/bt5/slapos_crm/bt/revision b/master/bt5/slapos_crm/bt/revision
index c24b6ae77..72f523f36 100644
--- a/master/bt5/slapos_crm/bt/revision
+++ b/master/bt5/slapos_crm/bt/revision
@@ -1 +1 @@
-38
\ No newline at end of file
+39
\ No newline at end of file
-- 
2.30.9