Commit e639b481 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud: Bang related instance when stop/destroy allocated shared instance

  Whenever the allocated shared (slave) instance is destroyed or stopped, isn't included on the getComputerInformation, so the timestamp can eventually go back in time (so partition skips process).

  This ensures that the partition information gets a newer timestamp (larger them the previous one).
parent e3b07565
instance = state_change['object']
if (instance.getPortalType() in ["Software Instance", "Slave Instance"]) and (instance.getSlapState() != 'destroy_requested'):
instance.bang(bang_tree=False, comment="State changed from %s to destroy_requested" % instance.getSlapState())
if instance.getSlapState() != 'destroy_requested':
portal_type = instance.getPortalType()
if portal_type in ["Software Instance", "Slave Instance"]:
instance.bang(
bang_tree=False,
comment="State changed from %s to destroy_requested" % instance.getSlapState())
if portal_type == "Slave Instance":
partition = instance.getAggregateValue()
if partition is not None:
software_instance = partition.getAggregateRelatedValue(portal_type="Software Instance")
if software_instance is not None:
software_instance.bang(bang_tree=False,
comment="State changed from %s (shared) to destroy_requested" % instance.getSlapState())
......@@ -52,6 +52,12 @@
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_RequestedInstance_bangIfStateChangeToDestroyed</string> </value>
......
instance = state_change['object']
if (instance.getPortalType() in ["Software Instance", "Slave Instance"]) and (instance.getSlapState() != 'start_requested'):
instance.bang(bang_tree=False, comment="State changed from %s to start_requested" % instance.getSlapState())
if instance.getSlapState() != 'start_requested':
portal_type = instance.getPortalType()
if portal_type in ["Software Instance", "Slave Instance"]:
instance.bang(
bang_tree=False,
comment="State changed from %s to start_requested" % instance.getSlapState())
......@@ -52,6 +52,12 @@
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_RequestedInstance_bangIfStateChangeToStarted</string> </value>
......
instance = state_change['object']
if (instance.getPortalType() in ["Software Instance", "Slave Instance"]) and (instance.getSlapState() != 'stop_requested'):
instance.bang(bang_tree=False, comment="State changed from %s to stop_requested" % instance.getSlapState())
if instance.getSlapState() != 'stop_requested':
portal_type = instance.getPortalType()
if portal_type in ["Software Instance", "Slave Instance"]:
instance.bang(
bang_tree=False,
comment="State changed from %s to stop_requested" % instance.getSlapState())
if portal_type == "Slave Instance":
partition = instance.getAggregateValue()
if partition is not None:
software_instance = partition.getAggregateRelatedValue(portal_type="Software Instance")
if software_instance is not None:
software_instance.bang(bang_tree=False,
comment="State changed from %s (shared) to stop_requested" % instance.getSlapState())
......@@ -52,6 +52,12 @@
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_RequestedInstance_bangIfStateChangeToStopped</string> </value>
......
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