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