Commit db424f23 by Rafael Monnerat

slapos_jio: Extend slapos_intent implementation to include sla_xml and text_content parameters

This allow us auto-request things more easily.
1 parent 82a3139c
......@@ -19,8 +19,6 @@
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
......@@ -93,18 +91,37 @@
})
.push(function (result) {
var software_release = result[1],
url = result[2],
title = options.software_title ? options.software_title: "Instance ",
doc = {};
doc.url_string = software_release.url_string;
doc.title = title;
doc.text_content = "";
doc.relative_url = options.jio_key;
url = result[2],
doc = {
url_string: software_release.url_string,
title: options.software_title ? options.software_title: "Instance {uid}",
relative_url: options.jio_key
};
if (options.software_type) {
doc.software_type = options.software_type;
}
if (options.text_content) {
doc.text_content = options.text_content;
}
if (options.shared) {
doc.shared = options.shared;
}
return gadget.notifySubmitting()
.push(function () {
return gadget.jio_putAttachment(doc.relative_url,
url + doc.relative_url + "/SoftwareRelease_requestHostingSubscription", doc);
var query = [];
query.push("title=" + encodeURIComponent(doc.title));
if (doc.software_type) {
query.push("software_type=" + encodeURIComponent(doc.software_type));
}
if (doc.shared) {
query.push("shared=" + encodeURIComponent(doc.shared));
}
if (doc.text_content) {
query.push("text_content=" + encodeURIComponent(doc.text_content));
}
return gadget.jio_getAttachment(doc.relative_url,
url + doc.relative_url + "/SoftwareRelease_requestHostingSubscription?" + query.join("&"));
})
.push(function (key) {
return gadget.notifySubmitted({message: 'New service created.', status: 'success'})
......
......@@ -259,7 +259,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>ERP5TypeTestCase</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -273,7 +273,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>965.20911.3973.32989</string> </value>
<value> <string>965.43749.35238.39116</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -291,7 +291,7 @@
</tuple>
<state>
<tuple>
<float>1517939506.98</float>
<float>1519310062.31</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -7,10 +7,13 @@ if shared == "true":
if shared in ["false", "", None]:
shared = False
if not title:
raise ValueError("Service Title is mandatory!")
if "{uid}" in title:
uid_ = portal.portal_ids.generateNewId(id_group=("vifib", "kvm"), default=1)
title = title.replace("{uid}", str(uid_))
hosting_subscription = portal.portal_catalog.getResultValue(
portal_type='Hosting Subscription',
validation_state="validated",
......@@ -31,9 +34,8 @@ if person is None:
if software_type in [None, ""]:
software_type = "RootSoftwareInstance"
if text_content == "":
text_content = """
<?xml version="1.0" encoding="utf-8" ?>
if text_content in ["", None]:
text_content = """<?xml version='1.0' encoding='utf-8' ?>
<instance>
</instance>"""
......@@ -48,8 +50,6 @@ request_kw.update(
state="started",
)
sla_xml = ""
for sla_category_id, sla_category in [
('computer_guid', computer_guid),
]:
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>title, text_content="", software_type=None, shared=False, computer_guid=None</string> </value>
<value> <string>title, text_content="", software_type=None, shared=False, computer_guid=None, sla_xml=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!