Commit 94b4e994 authored by Romain Courteaud's avatar Romain Courteaud

slapos_pdm: drop UpgradeDecision_notify

parent cf903d26
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Notification Message" 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>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_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>_Delete_objects_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>Associate</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>group/company</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>slapos-upgrade-compute-node.notification</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>This email is used to inform the user about an Upgrade</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>slapos_upgrade_compute_node_notification</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Notification Message</string> </value>
</item>
<item>
<key> <string>text_content</string> </key>
<value> <string encoding="cdata"><![CDATA[
Dear User,\n
<br>\n
<br> New version of the ${software_product_title} has been released.\n
<br>\n
<br> Install right now on Compute Node <b> ${compute_node_title} (${compute_node_reference}) </b> the newest version of ${software_product_title}:\n
<br>\n
<br> &nbsp;&nbsp;&nbsp; <b> ${software_release_name} ${software_release_reference} </b>\n
<br>\n
<br> Click <Accept> button to launch the Installation.\n
<br>\n
<br> If you don\'t want to use this new version, please cancel the upgrade request by clicking on <Reject> button.\n
<br>\n
<br>Thank you for use our services,\n
<br>Support Team\n
<br>\n
<br> Details:\n
<br>\n
<br> ${software_release_name} ${software_release_reference} Software Release URL :\n
<br>\n
<br> &nbsp;&nbsp;&nbsp; ${new_software_release_url}\n
<br>
]]></string> </value>
</item>
<item>
<key> <string>text_content_substitution_mapping_method_id</string> </key>
<value> <string>NotificationMessage_getSubstitutionMappingDictFromArgument</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Upgrade your Software Installation</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Notification Message" 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>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_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>_Delete_objects_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>Associate</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>group/company</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>slapos-upgrade-instance-tree.notification</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>This email is used to inform the user about an Upgrade</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>slapos_upgrade_instance_tree_notification</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Notification Message</string> </value>
</item>
<item>
<key> <string>text_content</string> </key>
<value> <string encoding="cdata"><![CDATA[
Dear User,\n
<br>\n
<br> New version of the ${software_product_title} has been released.\n
<br>\n
<br> Launch the upgrade on your instance <strong> ${instance_tree_title} </strong> to the newest version <strong> ${software_release_name} ${software_release_reference} </strong> by clicking on <Accept> button.\n
<br>\n
<br> If you don\'t want to use this new version, please cancel the upgrade request by clicking on <Reject> button.\n
<br>\n
<br>Thank you for use our services,\n
<br>Support Team\n
<br>\n
<br> Details:\n
<br>\n
<br> Current Software Release URL:\n
<br>\n
<br> &nbsp;&nbsp;&nbsp; ${old_software_release_url}\n
<br>\n
<br> New Software Release URL:\n
<br>\n
<br> &nbsp;&nbsp;&nbsp; ${new_software_release_url}\n
<br>
]]></string> </value>
</item>
<item>
<key> <string>text_content_substitution_mapping_method_id</string> </key>
<value> <string>NotificationMessage_getSubstitutionMappingDictFromArgument</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Upgrade your Instance Tree</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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_processPlannedUpgradeDecision</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>slapos_pdm_upgrade_decision_process_planned</string> </value>
</item>
<item>
<key> <string>periodicity_day_frequency</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>periodicity_hour</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_hour_frequency</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>periodicity_minute</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_minute_frequency</string> </key>
<value> <int>5</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="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="DateTime" module="DateTime.DateTime"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<tuple>
<float>3660.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>Process Planned Upgrade Decisions</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
portal = context.getPortalObject()
portal.portal_catalog.searchAndActivate(
portal_type='Upgrade Decision',
simulation_state='planned',
method_id='UpgradeDecision_notify',
activate_kw={'tag': tag }
)
context.activate(after_tag=tag).getId()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</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>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_processPlannedUpgradeDecision</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from DateTime import DateTime
# Review if the upgrade is applicable before notify.
context.reviewUpgrade()
if context.getSimulationState() != 'planned':
# XXX Don't notify the ones which are not planned.
return
portal = context.getPortalObject()
person = context.getDestinationDecisionValue(portal_type="Person")
if not person:
raise ValueError("Inconsistent Upgrade Decision, No Destination Decision")
instance_tree = context.UpgradeDecision_getAggregateValue("Instance Tree")
compute_node = context.UpgradeDecision_getAggregateValue("Compute Node")
software_release = context.UpgradeDecision_getAggregateValue("Software Release")
software_product_title = software_release.getAggregateTitle(
portal_type="Software Product")
mapping_dict = {
'software_product_title': software_product_title,
'software_release_name': software_release.getTitle(),
'software_release_reference': software_release.getReference(),
'new_software_release_url': software_release.getUrlString(),
}
if instance_tree is not None:
notification_message_reference = 'slapos-upgrade-instance-tree.notification'
title = "New Upgrade available for %s" % instance_tree.getTitle()
mapping_dict.update(**{
'instance_tree_title': instance_tree.getTitle(),
'old_software_release_url': instance_tree.getUrlString()})
elif compute_node is not None:
notification_message_reference = 'slapos-upgrade-compute-node.notification'
title = "New Software available for Installation at %s" % compute_node.getTitle()
mapping_dict.update(**{'compute_node_title': compute_node.getTitle(),
'compute_node_reference': compute_node.getReference()})
if notification_message_reference is None:
raise ValueError("No Notification Message")
notification_message = portal.portal_notifications.getDocumentValue(
reference=notification_message_reference)
message = notification_message.asEntireHTML(
substitution_method_parameter_dict={'mapping_dict': mapping_dict})
context.notify(message_title=title,
message=message,
destination_relative_url=person.getRelativeUrl())
event = context.REQUEST.get("upgrade_decision_notified_item")
if event is not None:
context.confirm()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</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>_params</string> </key>
<value> <string>**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>UpgradeDecision_notify</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
notification_message_module/slapos_upgrade_compute_node_notification
notification_message_module/slapos_upgrade_delivered_compute_node_notification notification_message_module/slapos_upgrade_delivered_compute_node_notification
notification_message_module/slapos_upgrade_delivered_instance_tree_notification notification_message_module/slapos_upgrade_delivered_instance_tree_notification
notification_message_module/slapos_upgrade_instance_tree_notification
portal_alarms/slapos_pdm_auto_cancel_upgrade_decision portal_alarms/slapos_pdm_auto_cancel_upgrade_decision
portal_alarms/slapos_pdm_destroy_software_installation_with_archived_software_release portal_alarms/slapos_pdm_destroy_software_installation_with_archived_software_release
portal_alarms/slapos_pdm_instance_tree_create_upgrade_decision portal_alarms/slapos_pdm_instance_tree_create_upgrade_decision
portal_alarms/slapos_pdm_upgrade_decision_process_planned
portal_alarms/slapos_pdm_upgrade_decision_process_started portal_alarms/slapos_pdm_upgrade_decision_process_started
portal_alarms/slapos_pdm_upgrade_decision_process_stopped portal_alarms/slapos_pdm_upgrade_decision_process_stopped
upgrade_decision_module/template_upgrade_decision upgrade_decision_module/template_upgrade_decision
\ 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