Commit bd1d5b1a authored by Łukasz Nowak's avatar Łukasz Nowak

slapos_pdm: Support Hosting Subscription with many root Software Instances

Since during maintenance of Hosting Subscription it's possible to end up with
many root Software Instances (of which many might be destroy_requested) it's
needed to support such situation while creating upgrade decision and finding
upgradeable Software Release.
parent 54c18e60
...@@ -6,9 +6,12 @@ upgrade_scope = context.getUpgradeScope() ...@@ -6,9 +6,12 @@ upgrade_scope = context.getUpgradeScope()
if upgrade_scope in ["never", "disabled"]: if upgrade_scope in ["never", "disabled"]:
return return
root_instance = hosting_subscription.getPredecessorValue(portal_type=["Software Instance", "Slave Instance"]) root_instance_list = [
if root_instance is None: q for q in hosting_subscription.getPredecessorValueList(portal_type=["Software Instance", "Slave Instance"])
if q.getSlapState() != 'destroy_requested']
if len(root_instance_list) == 0:
return return
root_instance = root_instance_list[0]
slave_upgrade = False slave_upgrade = False
if root_instance.getPortalType() == 'Slave Instance': if root_instance.getPortalType() == 'Slave Instance':
......
...@@ -11,9 +11,10 @@ slap_state = ['start_requested', 'stop_requested'] ...@@ -11,9 +11,10 @@ slap_state = ['start_requested', 'stop_requested']
if not hosting_subscription.getSlapState() in slap_state: if not hosting_subscription.getSlapState() in slap_state:
return None return None
source_instance = hosting_subscription.getPredecessorValue() source_instance_list = [q for q in hosting_subscription.getPredecessorValueList() if q.getSlapState() in slap_state]
if not source_instance or source_instance.getSlapState() not in slap_state: if len(source_instance_list) == 0:
return None return None
source_instance = source_instance_list[0]
software_release = hosting_subscription.HostingSubscription_getNewerSofwareRelease() software_release = hosting_subscription.HostingSubscription_getNewerSofwareRelease()
if not software_release: if not software_release:
......
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