Commit 960a4068 authored by Vivien Alger's avatar Vivien Alger

Support Request generation: Alarm_checkCloudIsFull refactoring

parent 06c32a51
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Person" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>__translation_dict</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>allocation_tester</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>first_name</string> </key>
<value> <string>Member</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>allocation_tester</string> </value>
</item>
<item>
<key> <string>last_name</string> </key>
<value> <string>Template</string> </value>
</item>
<item>
<key> <string>password</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Person</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Allocation tester</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value> <string>{SSHA}f1gAG3A53rfwjkLB/+Ex89MtocZz/4V9K4TZ</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Support Request" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>source_section/organisation_module/slapos</string>
<string>source_trade/organisation_module/slapos</string>
<string>source/organisation_module/slapos</string>
<string>resource/service_module/slapos_crm_monitoring</string>
</tuple>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>SR-282</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>slapos_crm_support_request_template_for_monitoring</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Support Request</string> </value>
</item>
<item>
<key> <string>price</string> </key>
<value> <float>0.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Template Support Request For Monitoring</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/string</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>preferred_software_release_to_test_for_space_property</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
<item>
<key> <string>preference</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>property_default</string> </key>
<value> <string>python:\'\'</string> </value>
</item>
<item>
<key> <string>write_permission</string> </key>
<value> <string>Manage properties</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/string</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>preferred_support_request_resource_for_monitoring_property</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
<item>
<key> <string>preference</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>property_default</string> </key>
<value> <string>python:\'\'</string> </value>
</item>
<item>
<key> <string>write_permission</string> </key>
<value> <string>Manage properties</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -52,23 +52,25 @@
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
\n
computer_list = portal.portal_catalog(\n
portal_type=\'Computer\',\n
validation_state = \'validated\',\n
capacity_scope = \'open\',\n
limit = 1\n
)\n
software_release_preference = portal.portal_preferences.getPreferredSoftwareReleaseToTestForSpace()\n
\n
if len(computer_list) == 0:\n
context.activate(tag=tag).Base_generateSupportRequestForSlapOS(\n
"VIFIB public cloud is full",\n
"No more computer with open capacity scope, add more ASAP"\n
if software_release_preference != \'\':\n
software_release_list = software_release_preference.split("\\n")\n
\n
portal.portal_catalog.searchAndActivate(\n
portal_type = \'Software Release\',\n
url_string = software_release_list,\n
\n
method_id = \'SoftwareRelease_testForAllocation\',\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>*args, **kw</string> </value>
<value> <string>tag, fixit, params</string> </value>
</item>
<item>
<key> <string>id</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>from DateTime import DateTime\n
\n
portal = context.getPortalObject()\n
\n
support_request_in_progress = portal.portal_catalog.getResultValue(\n
portal_type = \'Support Request\',\n
title = title,\n
simulation_state = ["validated","submitted","suspended"],\n
source_project_value = source_relative_url\n
)\n
\n
if support_request_in_progress is None:\n
support_request = portal.\\\n
support_request_module.\\\n
slapos_crm_support_request_template_for_monitoring.\\\n
Base_createCloneDocument(batch_mode=1)\n
support_request.edit(\n
title = title,\n
description = description,\n
start_date = DateTime(),\n
source_project_value = source_relative_url\n
)\n
support_request.validate()\n
\n
return support_request.getRelativeUrl()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>title, description, source_relative_url</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_generateSupportRequestForSlapOS</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -58,7 +58,7 @@ partition_list = portal.portal_catalog(portal_type = \'Computer Partition\',\n
)\n
\n
for partition in partition_list:\n
instance = partition.getAggregateRelatedValue()\n
instance = partition.getAggregateRelatedValue(portal_type=\'Software Instance\')\n
if instance is not None:\n
instance.activate().SoftwareInstance_checkState()\n
</string> </value>
......
......@@ -53,19 +53,29 @@
<value> <string encoding="cdata"><![CDATA[
from DateTime import DateTime\n
import json\n
\n
portal = context.getPortalObject()\n
\n
last_contact = context.Computer_getLastestContactedDate()\n
reference = context.getReference()\n
memcached_dict = context.getPortalObject().portal_memcached.getMemcachedDict(\n
key_prefix=\'slap_tool\',\n
plugin_path=\'portal_memcached/default_memcached_plugin\')\n
\n
try:\n
d = memcached_dict[reference]\n
except KeyError:\n
return\n
\n
if last_contact != "Computer didn\'t contact the server":\n
if (DateTime() - last_contact) > 1:\n
tag = "Support Request generation for %s" % reference\n
context.activate(tag=tag).Base_generateSupportRequestForSlapOS(\n
"Support Request for %s" % reference,\n
"%s has not contacted the server for more than 24 hours" % reference\n
)\n
d = json.loads(d)\n
last_contact = DateTime(d.get(\'created_at\'))\n
\n
if (DateTime() - last_contact) > 1:\n
return context.Base_generateSupportRequestForSlapOS(\n
"Lost contact with %s" % reference,\n
"%s has not contacted the server for more than 24 hours (last contact date: %s)" % (reference, last_contact),\n
context.getRelativeUrl()\n
)\n
]]></string> </value>
......
......@@ -69,24 +69,28 @@ d = json.loads(d)\n
result = d[\'text\']\n
last_contact = DateTime(d.get(\'created_at\'))\n
now = DateTime()\n
title = ""\n
\n
if result.startswith(\'#error \'):\n
# If no change in the last 2 hours generate a support request\n
if (now - last_contact) > 0.08:\n
tag = "Support Request generation for %s" % reference\n
context.activate(tag=tag).Base_generateSupportRequestForSlapOS(\n
"Support Request for %s" % reference,\n
"%s has been in error state for more than 2 hours" % reference\n
)\n
title = "Instance %s in error state" % reference\n
description = "%s has been in error state for more than 2 hours (last contact date: %s)" % (reference, last_contact)\n
\n
elif result.startswith(\'#access \'):\n
# If there was no contact for more than one day generate a support request\n
if (now - last_contact) > 1:\n
tag = "Support Request generation for %s" % reference\n
context.activate(tag=tag).Base_generateSupportRequestForSlapOS(\n
"Support Request for %s" % reference,\n
"%s has not contacted the server for more than 24 hours" % reference\n
)\n
title = "Instance %s in unknown state" % reference\n
description = "%s has not contacted the server for more than 24 hours (last contact date: %s)" % (reference, last_contact)\n
\n
if title != "":\n
return context.Base_generateSupportRequestForSlapOS(\n
title,\n
description,\n
context.getRelativeUrl()\n
)\n
]]></string> </value>
......
<?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>portal = context.getPortalObject()\n
software_release = context\n
software_release_url = software_release.getUrlString()\n
\n
user = portal.person_module.allocation_tester\n
\n
result = user.Person_restrictMethodAsShadowUser(\n
shadow_document=user,\n
callable_object=user.Person_findPartition,\n
argument_list=[\n
software_release_url,\n
\'\',\n
\'Software Instance\',\n
{}\n
],\n
argument_dict={\n
\'test_mode\': True})\n
\n
if not result:\n
title = "Can\'t allocate new instances for software release %s" % software_release_url\n
description = "Need more public computers that can instanciate the software release %s" % software_release_url\n
\n
return software_release.Base_generateSupportRequestForSlapOS(\n
title,\n
description,\n
software_release.getRelativeUrl()\n
)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SoftwareRelease_testForAllocation</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -97,6 +97,7 @@
<string>my_preferred_support_request_template</string>
<string>my_preferred_web_message_template</string>
<string>my_preferred_slapos_web_site_url</string>
<string>my_preferred_support_request_resource_for_monitoring</string>
</list>
</value>
</item>
......@@ -106,6 +107,7 @@
<list>
<string>my_preferred_regularisation_request_use_list</string>
<string>my_preferred_regularisation_request_resource</string>
<string>my_preferred_software_release_to_test_for_space</string>
</list>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_preferred_software_release_to_test_for_space</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_text_area_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Software Release To Test For Space</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_preferred_support_request_resource_for_monitoring</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_string_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Resource For Monitoring Support Request</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
22
\ No newline at end of file
23
\ No newline at end of file
event_module/slapos_crm_web_message_template
person_module/allocation_tester
portal_alarms/slapos_check_cloud_is_full
portal_alarms/slapos_check_computer_state
portal_alarms/slapos_check_software_instance_state
......@@ -21,4 +22,5 @@ service_module/slapos_crm_invoice_cancellation
service_module/slapos_crm_spam
service_module/slapos_crm_stop_acknowledgement
service_module/slapos_crm_stop_reminder
support_request_module/slapos_crm_support_request_template
\ No newline at end of file
support_request_module/slapos_crm_support_request_template
support_request_module/slapos_crm_support_request_template_for_monitoring
\ No newline at end of file
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