Commit 307e1012 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud: Stop orphans on SoftwareInstance_tryToStopCollect

    In case the instance isn't linked to the tree properly (due Garbage Collect unlinked it), stop the instance directly anyway.
parent 6009bdf0
......@@ -4,14 +4,12 @@ if REQUEST is not None:
instance = context
if (instance.getSlapState() == "start_requested"):
instance_tree = instance.getSpecialiseValue(portal_type="Instance Tree")
if (instance_tree.getSlapState() == "stop_requested"):
# Buildout may not propagate the stop request
requester = instance.getSuccessorRelatedValue()
if (instance.getRelativeUrl() in requester.getSuccessorList()) and \
(requester.getSlapState() == "stop_requested"):
# For security, only stop if parent is also stopped
if instance.getSlapState() != "start_requested":
# Only continue if the instance is started
return
instance_tree = instance.getSpecialiseValue(portal_type="Instance Tree")
if (instance_tree.getSlapState() == "stop_requested"):
if instance.getPortalType() == 'Software Instance':
is_slave = False
......@@ -21,6 +19,21 @@ if (instance.getSlapState() == "start_requested"):
raise NotImplementedError, "Unknown portal type %s of %s" % \
(instance.getPortalType(), instance.getRelativeUrl())
# Buildout may not propagate the stop request
requester = instance.getSuccessorRelatedValue()
if requester is None:
# Instance is orphan, so it stops itself.
instance.requestStop(
software_release=instance.getUrlString(),
software_type=instance.getSourceReference(),
instance_xml=instance.getTextContent(),
sla_xml=instance.getSlaXml(),
shared=is_slave,
comment="Stop collect %s" % instance.getRelativeUrl())
else:
if (instance.getRelativeUrl() in requester.getSuccessorList()) and \
(requester.getSlapState() == "stop_requested"):
# For security, only stop if parent is also stopped
requester.requestInstance(
software_release=instance.getUrlString(),
software_title=instance.getTitle(),
......
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