Commit db424f23 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Extend slapos_intent implementation to include sla_xml and text_content parameters

This allow us auto-request things more easily.
parent 82a3139c
...@@ -19,8 +19,6 @@ ...@@ -19,8 +19,6 @@
.declareAcquiredMethod("notifySubmitting", "notifySubmitting") .declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted') .declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // declared methods
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -93,18 +91,37 @@ ...@@ -93,18 +91,37 @@
}) })
.push(function (result) { .push(function (result) {
var software_release = result[1], var software_release = result[1],
url = result[2], url = result[2],
title = options.software_title ? options.software_title: "Instance ", doc = {
doc = {}; url_string: software_release.url_string,
title: options.software_title ? options.software_title: "Instance {uid}",
doc.url_string = software_release.url_string; relative_url: options.jio_key
doc.title = title; };
doc.text_content = ""; if (options.software_type) {
doc.relative_url = options.jio_key; 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() return gadget.notifySubmitting()
.push(function () { .push(function () {
return gadget.jio_putAttachment(doc.relative_url, var query = [];
url + doc.relative_url + "/SoftwareRelease_requestHostingSubscription", doc); 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) { .push(function (key) {
return gadget.notifySubmitted({message: 'New service created.', status: 'success'}) return gadget.notifySubmitted({message: 'New service created.', status: 'success'})
......
...@@ -259,7 +259,7 @@ ...@@ -259,7 +259,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>zope</string> </value> <value> <string>ERP5TypeTestCase</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -273,7 +273,7 @@ ...@@ -273,7 +273,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>965.20911.3973.32989</string> </value> <value> <string>965.43749.35238.39116</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -291,7 +291,7 @@ ...@@ -291,7 +291,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1517939506.98</float> <float>1519310062.31</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -7,10 +7,13 @@ if shared == "true": ...@@ -7,10 +7,13 @@ if shared == "true":
if shared in ["false", "", None]: if shared in ["false", "", None]:
shared = False shared = False
if not title: if not title:
raise ValueError("Service Title is mandatory!") 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( hosting_subscription = portal.portal_catalog.getResultValue(
portal_type='Hosting Subscription', portal_type='Hosting Subscription',
validation_state="validated", validation_state="validated",
...@@ -31,9 +34,8 @@ if person is None: ...@@ -31,9 +34,8 @@ if person is None:
if software_type in [None, ""]: if software_type in [None, ""]:
software_type = "RootSoftwareInstance" software_type = "RootSoftwareInstance"
if text_content == "": if text_content in ["", None]:
text_content = """ text_content = """<?xml version='1.0' encoding='utf-8' ?>
<?xml version="1.0" encoding="utf-8" ?>
<instance> <instance>
</instance>""" </instance>"""
...@@ -48,8 +50,6 @@ request_kw.update( ...@@ -48,8 +50,6 @@ request_kw.update(
state="started", state="started",
) )
sla_xml = ""
for sla_category_id, sla_category in [ for sla_category_id, sla_category in [
('computer_guid', computer_guid), ('computer_guid', computer_guid),
]: ]:
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <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>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
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