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 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
from DateTime import DateTime\n
<value> <string>from DateTime import DateTime\n
\n
computer = context\n
portal = context.getPortalObject()\n
......@@ -65,6 +63,8 @@ if allocation_scope != \'open/public\' and \\\n
\n
is_service_provider = False\n
person = computer.getSourceAdministrationValue(portal_type="Person")\n
if not person:\n
return\n
\n
for assignment in person.contentValues(portal_type="Assignment"):\n
if assignment.getRole() == \'service_provider\':\n
......@@ -79,6 +79,7 @@ if not is_service_provider:\n
computer.edit(**edit_kw)\n
\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_description = \'Allocation scope has been changed back to \' \\\n
\'open/personal for %s\' % computer_reference\n
......@@ -86,7 +87,6 @@ if not is_service_provider:\n
notification_reference = \'slapos-crm-computer_allocation_scope.notification\'\n
notification_message = portal.portal_notifications.getDocumentValue(\n
reference=notification_reference)\n
ressource = portal.service_module.slapos_crm_information.getRelativeUrl()\n
mapping_dict = {\'computer_title\':computer.getTitle(),\n
\'computer_id\':computer_reference,\n
\'allocation_scope\':allocation_scope}\n
......@@ -110,35 +110,13 @@ if not is_service_provider:\n
simulation_state = \'suspended\',\n
source_project_uid = computer.getUid()\n
)\n
if support_request is None:\n
# Existing ticket not found, can not create event for the moment\n
return\n
support_request_url = support_request.getRelativeUrl()\n
\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
if support_request is None:\n
# Existing ticket not found, can not create event for the moment\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>
\n
support_request.SupportRequest_trySendNotificationMessage(message_title,\n
message, person.getRelativeUrl())\n
</string> </value>
</item>
<item>
<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
\ No newline at end of file
34
\ No newline at end of file
......@@ -4,6 +4,8 @@ portal_alarms/slapos_check_cloud_is_full
portal_alarms/slapos_check_computer_state
portal_alarms/slapos_check_software_instance_state
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_delete_hosting_subscription
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