Commit 5f97fcb8 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_subscription_request: Render KVMCluster parameter with less parameters.

parent f7aa629e
......@@ -25,3 +25,10 @@ def Base_instanceXmlToDict(self, xml):
LOG('SubscriptionRequest', INFO, 'Issue during parsing xml:', error=True)
return result_dict
def SubscriptionCondition_renderParameter(self, amount=0, **kw):
method_id = self.getParameterTemplateRendererMethodId()
if method_id is not None:
return getattr(self, method_id)(amount=amount, **kw)
return self.getTextContent()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_function</string> </key>
<value> <string>Base_instanceXmlToDict</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>SlapOSSubscriptionRequest</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_instanceXmlToDict</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -5,6 +5,9 @@
This adapt the definition of KVM to instantiate multiple VMs instead a single
for example.
"""
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
import json
parameter_text = context.getTextContent()
......
......@@ -50,7 +50,15 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>amount=10, **kw</string> </value>
<value> <string>amount=0, REQUEST=None, **kw</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
......
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
pass #raise Unauthorized
if context.getSimulationState() not in ["draft", "planned"]:
# Don't modify it anymore
......@@ -20,17 +20,16 @@ if subscription_condition is None:
"It was not possible to find the appropriate Condition %s for this Subscription" \
% subscription_condition_reference)
instance_xml = subscription_condition.SubscriptionCondition_renderParameter(
amount=int(context.getQuantity()))
# Get Subscription condition for this Subscription Request
subscription_configuration = {
"instance_xml": subscription_condition.getTextContent(),
"instance_xml": instance_xml,
"software_type": subscription_condition.getSourceReference(),
"url": subscription_condition.getUrlString(),
"shared": subscription_condition.getRootSlave(),
"subject_list": subscription_condition.getSubjectList(),
"sla_xml": subscription_condition.getSlaXml(),
"specialise": subscription_condition.getRelativeUrl()
}
email = context.getDestinationSectionValue().getDefaultEmailText()
now = DateTime()
......@@ -41,6 +40,5 @@ context.edit(
text_content=subscription_configuration["instance_xml"],
start_date=now,
root_slave=subscription_configuration["shared"],
subject_list=subscription_configuration["subject_list"],
specialise_value=subscription_condition
)
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