Commit b9b92bde authored by Romain Courteaud's avatar Romain Courteaud

slapos_cloud: only propagate Instance Tree parameters to the Software/Slave...

slapos_cloud: only propagate Instance Tree parameters to the Software/Slave Instance only if an Open Sale Order exists
parent adf21e8b
service = context
portal = context.getPortalObject()
# If no open order, subscription must be approved
open_sale_order_movement_list = portal.portal_catalog(
portal_type=['Open Sale Order Line', 'Open Sale Order Cell'],
aggregate__uid=service.getUid(),
validation_state='validated',
limit=1
)
if len(open_sale_order_movement_list) == 0:
return "not_subscribed"
# Check if there are some ongoing Regularisation Requestion
# if so, return to_pay
return "subscribed"
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</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></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Service_getSubscriptionStatus</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -91,15 +91,22 @@ elif (root_state == "destroyed"):
else:
raise ValueError, "state should be started, stopped or destroyed"
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,
)
subscription_state = request_instance_tree.Service_getSubscriptionStatus()
request_instance_tree.log('subscription_state %s' % subscription_state)
if subscription_state in ('not_subscribed', 'nopaid'):
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)
# 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