Commit b4bc0853 authored by Romain Courteaud's avatar Romain Courteaud

slapos_pdm: drop Compute Node upgrade

This is now handled manually by updating the Allocation Supply
parent fcd7b15b
<?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_ComputeNodeCheckUpgradeSoftwareRelease</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Create Upgrade Decision for compute_nodes to upgrade Software Releases to a newer version.</string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>slapos_pdm_compute_node_create_upgrade_decision</string> </value>
</item>
<item>
<key> <string>periodicity_day_frequency</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>periodicity_hour</string> </key>
<value>
<tuple>
<int>0</int>
</tuple>
</value>
</item>
<item>
<key> <string>periodicity_hour_frequency</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>periodicity_minute</string> </key>
<value>
<tuple>
<int>8</int>
</tuple>
</value>
</item>
<item>
<key> <string>periodicity_minute_frequency</string> </key>
<value>
<none/>
</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>1406073600.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>sense_method_id</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Create Upgrade Decision for compute_nodes</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
portal = context.getPortalObject()
default_upgrade_scope_uid = [
portal.portal_categories.upgrade_scope.auto.getUid(),
portal.portal_categories.upgrade_scope.confirmation.getUid()
]
if default_upgrade_scope_uid:
portal.portal_catalog.searchAndActivate(
portal_type='Compute Node',
validation_state = 'validated',
default_upgrade_scope_uid=default_upgrade_scope_uid,
method_id = 'ComputeNode_checkAndCreateUpgradeDecision',
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_ComputeNodeCheckUpgradeSoftwareRelease</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from DateTime import DateTime
compute_node = context
portal = context.getPortalObject()
upgrade_scope = context.getUpgradeScope()
if upgrade_scope in ["never", "disabled"]:
return
full_software_release_list = [si.url_string for si in
portal.portal_catalog(
select_dict = {"url_string": None},
portal_type='Software Installation',
default_aggregate_uid=compute_node.getUid(),
validation_state='validated'
) if si.getSlapState() == 'start_requested']
if len(full_software_release_list) == 0:
return
# group SR by Software Product to avoid two upgrade Decision for the same product
software_release_list = portal.portal_catalog(
portal_type='Software Release',
url_string=full_software_release_list,
group_by=['default_aggregate_uid']
)
upgrade_decision_list = []
for software_release in software_release_list:
software_product_reference = software_release.getAggregateReference()
if software_product_reference in [None, ""]:
continue
sorted_list = portal.SoftwareProduct_getSortedSoftwareReleaseList(
software_product_reference=software_product_reference)
# Check if there is a new version of this software Product
if sorted_list and \
sorted_list[0].getUrlString() not in full_software_release_list:
newer_release = sorted_list[0]
title = 'A new version of %s is available for %s' % \
(software_product_reference, context.getTitle())
# If exist upgrade decision in progress try to cancel it
decision_in_progress = newer_release.\
SoftwareRelease_getUpgradeDecisionInProgress(compute_node.getUid())
if decision_in_progress:
decision_in_progress.reviewRegistration(
software_release_url=newer_release.getUrlString())
if decision_in_progress.getSimulationState() != "cancelled":
continue
upgrade_decision = newer_release.SoftwareRelease_createUpgradeDecision(
source_url=compute_node.getRelativeUrl(),
title=title)
upgrade_decision.approveRegistration(
upgrade_scope=compute_node.getUpgradeScope("ask_confirmation"))
upgrade_decision_list.append(upgrade_decision)
return upgrade_decision_list
<?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></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ComputeNode_checkAndCreateUpgradeDecision</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -8,9 +8,7 @@ if not source_product: ...@@ -8,9 +8,7 @@ if not source_product:
return return
portal_type = source_product.getPortalType() portal_type = source_product.getPortalType()
if portal_type == 'Compute Node': if portal_type == 'Instance Tree':
person_url = source_product.getSourceAdministration()
elif portal_type == 'Instance Tree':
person_url = source_product.getDestinationSection() person_url = source_product.getDestinationSection()
else: else:
return return
......
...@@ -3,7 +3,6 @@ notification_message_module/slapos_upgrade_delivered_compute_node_notification ...@@ -3,7 +3,6 @@ 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 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_compute_node_create_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_planned
......
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