Commit 55d7438a authored by Alain Takoudjou's avatar Alain Takoudjou Committed by Rafael Monnerat

Split Alarm script Computer_checkAndUpdateAllocationScope

parent f885dc34
...@@ -50,9 +50,7 @@ ...@@ -50,9 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string>from DateTime import DateTime\n
from DateTime import DateTime\n
\n \n
computer = context\n computer = context\n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
...@@ -65,6 +63,8 @@ if allocation_scope != \'open/public\' and \\\n ...@@ -65,6 +63,8 @@ if allocation_scope != \'open/public\' and \\\n
\n \n
is_service_provider = False\n is_service_provider = False\n
person = computer.getSourceAdministrationValue(portal_type="Person")\n person = computer.getSourceAdministrationValue(portal_type="Person")\n
if not person:\n
return\n
\n \n
for assignment in person.contentValues(portal_type="Assignment"):\n for assignment in person.contentValues(portal_type="Assignment"):\n
if assignment.getRole() == \'service_provider\':\n if assignment.getRole() == \'service_provider\':\n
...@@ -79,6 +79,7 @@ if not is_service_provider:\n ...@@ -79,6 +79,7 @@ if not is_service_provider:\n
computer.edit(**edit_kw)\n computer.edit(**edit_kw)\n
\n \n
# Create a ticket (or re-open it) for this issue!\n # Create a ticket (or re-open it) for this issue!\n
support_request = None\n
request_title = \'Allocation scope has been changed for %s\' % computer_reference\n request_title = \'Allocation scope has been changed for %s\' % computer_reference\n
request_description = \'Allocation scope has been changed back to \' \\\n request_description = \'Allocation scope has been changed back to \' \\\n
\'open/personal for %s\' % computer_reference\n \'open/personal for %s\' % computer_reference\n
...@@ -86,7 +87,6 @@ if not is_service_provider:\n ...@@ -86,7 +87,6 @@ if not is_service_provider:\n
notification_reference = \'slapos-crm-computer_allocation_scope.notification\'\n notification_reference = \'slapos-crm-computer_allocation_scope.notification\'\n
notification_message = portal.portal_notifications.getDocumentValue(\n notification_message = portal.portal_notifications.getDocumentValue(\n
reference=notification_reference)\n reference=notification_reference)\n
ressource = portal.service_module.slapos_crm_information.getRelativeUrl()\n
mapping_dict = {\'computer_title\':computer.getTitle(),\n mapping_dict = {\'computer_title\':computer.getTitle(),\n
\'computer_id\':computer_reference,\n \'computer_id\':computer_reference,\n
\'allocation_scope\':allocation_scope}\n \'allocation_scope\':allocation_scope}\n
...@@ -113,32 +113,10 @@ if not is_service_provider:\n ...@@ -113,32 +113,10 @@ if not is_service_provider:\n
if support_request is None:\n if support_request is None:\n
# Existing ticket not found, can not create event for the moment\n # Existing ticket not found, can not create event for the moment\n
return\n return\n
support_request_url = support_request.getRelativeUrl()\n
\n \n
# create Web message if needed for this ticket\n support_request.SupportRequest_trySendNotificationMessage(message_title,\n
last_event = context.portal_catalog.getResultValue(\n message, person.getRelativeUrl())\n
follow_up_uid=support_request.getUid(), \n </string> </value>
sort_on=[(\'delivery.start_date\', \'DESC\')],\n
)\n
if last_event and \\\n
(DateTime() - last_event.getStartDate() < 1):\n
# User has already been notified this last 24h.\n
return\n
event = portal.event_module.slapos_crm_web_message_template.\\\n
Base_createCloneDocument(batch_mode=1)\n
event.edit(\n
title=message_title,\n
text_content=message,\n
start_date = DateTime(),\n
resource = ressource,\n
source=person.getRelativeUrl(),\n
follow_up=support_request_url,\n
)\n
event.stop()\n
event.deliver()\n
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
......
<?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[
support_request = context\n
portal = context.getPortalObject()\n
\n
ressource = portal.service_module.slapos_crm_information.getRelativeUrl()\n
# create Web message if needed for this ticket\n
last_event = context.portal_catalog.getResultValue(\n
follow_up_uid=support_request.getUid(), \n
sort_on=[(\'delivery.start_date\', \'DESC\')],\n
)\n
if last_event and \\\n
(DateTime() - last_event.getStartDate() < 1):\n
# User has already been notified this last 24h.\n
return\n
event = portal.event_module.slapos_crm_web_message_template.\\\n
Base_createCloneDocument(batch_mode=1)\n
event.edit(\n
title=message_title,\n
text_content=message,\n
start_date = DateTime(),\n
resource = ressource,\n
source=source_relative_url,\n
follow_up=support_request.getRelativeUrl(),\n
)\n
event.stop()\n
event.deliver()\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>message_title, message, source_relative_url</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SupportRequest_trySendNotificationMessage</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
33 34
\ No newline at end of file \ No newline at end of file
...@@ -4,6 +4,8 @@ portal_alarms/slapos_check_cloud_is_full ...@@ -4,6 +4,8 @@ portal_alarms/slapos_check_cloud_is_full
portal_alarms/slapos_check_computer_state portal_alarms/slapos_check_computer_state
portal_alarms/slapos_check_software_instance_state portal_alarms/slapos_check_software_instance_state
portal_alarms/slapos_crm_cancel_invoice portal_alarms/slapos_crm_cancel_invoice
portal_alarms/slapos_crm_check_partially_allocated_instance
portal_alarms/slapos_crm_check_update_allocation_scope
portal_alarms/slapos_crm_create_regularisation_request portal_alarms/slapos_crm_create_regularisation_request
portal_alarms/slapos_crm_delete_hosting_subscription portal_alarms/slapos_crm_delete_hosting_subscription
portal_alarms/slapos_crm_invalidate_suspended_regularisation_request portal_alarms/slapos_crm_invalidate_suspended_regularisation_request
......
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