Commit d679bce2 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_pdm: Ensure upgrade is possible before continue

Check if the software installation is really well installed before continue
parent 22f7c7de
portal = context.getPortalObject()
# This won't work well on clusters deployed on multiple computers.
root_instance = context.getPredecessorValue(
portal_type=["Software Instance", "Slave Instance"])
if root_instance is not None and root_instance.getPortalType() == 'Slave Instance':
return True
# Get Computer List
instance_list = context.getSpecialiseValueList(
portal_type="Software Instance")
computer_list = []
for instance in instance_list:
if instance.getSlapState() == "destroy_requested":
continue
partition = instance.getAggregateValue(portal_type="Computer Partition")
if partition is None:
continue
computer_list.append(partition.getParentValue().getUid())
if computer_list is None:
return True
full_software_installation_list = [si for si in
portal.portal_catalog(
portal_type='Software Installation',
url_string=software_release_url,
default_aggregate_uid=computer_list,
validation_state='validated'
) if si.getSlapState() == 'start_requested']
if len(full_software_installation_list) == len(set(computer_list)):
# Software is available for the root instance
software_installation = full_software_installation_list[0]
message = software_installation.Base_getNewsDict()['text']
if message.startswith("#access"):
return True
<?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>_params</string> </key>
<value> <string>software_release_url</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>HostingSubscription_isUpgradePossible</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -12,11 +12,14 @@ if software_release is None:
return False
software_release_url = software_release.getUrlString()
person = hosting_subscription.getDestinationSectionValue(portal_type="Person")
status = hosting_subscription.getSlapState()
# Test if the Software is available at the Computer.
if not hosting_subscription.HostingSubscription_isUpgradePossible(
software_release_url=software_release_url):
return
status = hosting_subscription.getSlapState()
if status == "start_requested":
state = "started"
elif status == "stop_requested":
......
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