Commit c3b37c97 authored by Romain Courteaud's avatar Romain Courteaud

slapos_cloud: stop instance tree propagation on instance_slap_interface_workflow

Some alarm call request directly on the Instance Tree (this is expected)
parent d7ffbddc
......@@ -25,6 +25,18 @@ if is_slave not in [True, False]:
# Instance tree is used as the root of the instance tree
if requester_instance.getPortalType() == "Instance Tree":
instance_tree = requester_instance
# Do not propagate instante tree changes if current user
# subscription status is not OK
subscription_state = instance_tree.Service_getSubscriptionStatus()
if subscription_state in ('not_subscribed', 'nopaid'):
context.REQUEST.set('request_instance', None)
return
elif subscription_state in ('subscribed', 'todestroy'):
pass
else:
raise NotImplementedError('Unhandled subscription state: %s' % subscription_state)
else:
instance_tree = requester_instance.getSpecialiseValue(portal_type="Instance Tree")
......
......@@ -91,23 +91,15 @@ elif (root_state == "destroyed"):
else:
raise ValueError, "state should be started, stopped or destroyed"
subscription_state = request_instance_tree.Service_getSubscriptionStatus()
request_instance_tree.log('subscription_state %s' % subscription_state)
if subscription_state in ('not_subscribed', 'nopaid'):
context.REQUEST.set('request_instance', None)
pass
elif subscription_state in ('subscribed', 'todestroy'):
request_instance_tree.requestInstance(
software_release=software_release_url_string,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=is_slave,
state=root_state,
)
else:
raise NotImplementedError('Unhandled subscription state: %s' % subscription_state)
request_instance_tree.requestInstance(
software_release=software_release_url_string,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=is_slave,
state=root_state,
)
# Change the state at the end to allow to execute updateLocalRoles only once in the transaction
validation_state = request_instance_tree.getValidationState()
......
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