Commit fd20044c authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Rework status gadget usage to rely on renderjs_extra

   This makes it complies with the ERP5 Form usage.

   Cleans up the calls and remove remove unecessary scripts since they
   were just proxify getAccessStatus for no reason.
parent 39c33ce0
...@@ -114,9 +114,7 @@ ...@@ -114,9 +114,7 @@
</item> </item>
<item> <item>
<key> <string>default</string> </key> <key> <string>default</string> </key>
<value> <value> <string></string> </value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
...@@ -152,7 +150,9 @@ ...@@ -152,7 +150,9 @@
</item> </item>
<item> <item>
<key> <string>renderjs_extra</string> </key> <key> <string>renderjs_extra</string> </key>
<value> <string></string> </value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
...@@ -253,7 +253,7 @@ ...@@ -253,7 +253,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string>python: {"result": cell.getAggregateRelatedValue(portal_type="Software Instance").getAccessStatus()}</string> </value> <value> <string>python: [(\'jio_key\', cell.getAggregateRelated(portal_type="Software Instance")), (\'result\', cell.getAggregateRelatedValue(portal_type="Software Instance").getAccessStatus())]</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -226,11 +226,17 @@ ...@@ -226,11 +226,17 @@
}) })
.declareMethod("render", function (options) { .declareMethod("render", function (options) {
// Save will force the gadget to be updated so // crash as soon as possible to detect wrong configuration
// result is empty. if (!(options.hasOwnProperty('jio_key') &&
var state_dict = options.value.result || {}; options.hasOwnProperty('result'))) {
state_dict.jio_key = options.value.jio_key; throw new Error(
'status gadget did not receive jio_key and result values'
);
}
var state_dict = options.result || {};
state_dict.jio_key = options.jio_key;
return this.changeState(state_dict); return this.changeState(state_dict);
}); });
}(window, rJS, domsugar)); }(window, rJS, domsugar));
\ No newline at end of file
...@@ -114,9 +114,7 @@ ...@@ -114,9 +114,7 @@
</item> </item>
<item> <item>
<key> <string>default</string> </key> <key> <string>default</string> </key>
<value> <value> <string></string> </value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
...@@ -152,7 +150,9 @@ ...@@ -152,7 +150,9 @@
</item> </item>
<item> <item>
<key> <string>renderjs_extra</string> </key> <key> <string>renderjs_extra</string> </key>
<value> <string></string> </value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
...@@ -253,7 +253,7 @@ ...@@ -253,7 +253,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string>python: {"result": cell.getAccessStatus()}</string> </value> <value> <string>python: [(\'jio_key\', cell.getRelativeUrl()), (\'result\', cell.getAccessStatus())]</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
/*global window, rJS, RSVP */ /*global window, rJS, RSVP, JSON */
/*jslint nomen: true, indent: 2, maxerr: 3*/ /*jslint nomen: true, indent: 2, maxerr: 3*/
(function (window, rJS, RSVP) { (function (window, rJS, RSVP, JSON) {
"use strict"; "use strict";
rJS(window) rJS(window)
...@@ -19,19 +19,21 @@ ...@@ -19,19 +19,21 @@
var gadget = this; var gadget = this;
return gadget.jio_allDocs(param_list[0]) return gadget.jio_allDocs(param_list[0])
.push(function (result) { .push(function (result) {
var i, value, news, len = result.data.total_rows; var i, value, value_jio_key, len = result.data.total_rows;
for (i = 0; i < len; i += 1) { for (i = 0; i < len; i += 1) {
if ((result.data.rows[i].value.hasOwnProperty("ComputeNode_getNewsDict"))) { if ((result.data.rows[i].value.hasOwnProperty("getAccessStatus"))) {
value = result.data.rows[i].id; value_jio_key = result.data.rows[i].id;
news = result.data.rows[i].value.ComputeNode_getNewsDict; value = result.data.rows[i].value.getAccessStatus;
result.data.rows[i].value.ComputeNode_getNewsDict = { result.data.rows[i].value.getAccessStatus = {
field_gadget_param : { field_gadget_param : {
css_class: "", css_class: "",
description: "The Status", description: "The Status",
hidden: 0, hidden: 0,
"default": {jio_key: value, default: "",
result: news, renderjs_extra: JSON.stringify({
portal_type: "Compute Node"}, jio_key: value_jio_key,
result: value
}),
key: "status", key: "status",
url: "gadget_slapos_status.html", url: "gadget_slapos_status.html",
title: "Status", title: "Status",
...@@ -86,7 +88,7 @@ ...@@ -86,7 +88,7 @@
['title', result[3][0]], ['title', result[3][0]],
['reference', result[3][1]], ['reference', result[3][1]],
['allocation_scope_title', result[3][2]], ['allocation_scope_title', result[3][2]],
['ComputeNode_getNewsDict', result[3][3]] ['getAccessStatus', result[3][3]]
], ],
form_list = result[0]; form_list = result[0];
lines_limit = result[1]; lines_limit = result[1];
...@@ -151,4 +153,4 @@ ...@@ -151,4 +153,4 @@
}); });
}); });
}); });
}(window, rJS, RSVP)); }(window, rJS, RSVP, JSON));
\ No newline at end of file \ No newline at end of file
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1001.59387.30502.30993</string> </value> <value> <string>1010.39712.21917.33587</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -258,7 +258,7 @@ ...@@ -258,7 +258,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1659068807.75</float> <float>1692646587.64</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global window, rJS, RSVP */ /*global window, rJS, RSVP, JSON */
/*jslint nomen: true, indent: 2, maxerr: 3 */ /*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP) { (function (window, rJS, RSVP, JSON) {
"use strict"; "use strict";
rJS(window) rJS(window)
...@@ -28,18 +28,19 @@ ...@@ -28,18 +28,19 @@
.push(function (result) { .push(function (result) {
var i, value, value_jio_key, len = result.data.total_rows; var i, value, value_jio_key, len = result.data.total_rows;
for (i = 0; i < len; i += 1) { for (i = 0; i < len; i += 1) {
if (1 || (result.data.rows[i].value.SoftwareInstallation_getNewsDict)) { if (1 || (result.data.rows[i].value.getAccessStatus)) {
value = result.data.rows[i].value.SoftwareInstallation_getNewsDict; value = result.data.rows[i].value.getAccessStatus;
value_jio_key = result.data.rows[i].id; value_jio_key = result.data.rows[i].id;
result.data.rows[i].value.SoftwareInstallation_getNewsDict = { result.data.rows[i].value.getAccessStatus = {
field_gadget_param : { field_gadget_param : {
css_class: "", css_class: "",
description: "The Status", description: "The Status",
hidden: 0, hidden: 0,
"default": { "default": "",
renderjs_extra: JSON.stringify({
jio_key: value_jio_key, jio_key: value_jio_key,
result: value, result: value
portal_type: "Software Installation"}, }),
key: "status", key: "status",
url: "gadget_slapos_status.html", url: "gadget_slapos_status.html",
title: "Status", title: "Status",
...@@ -67,20 +68,14 @@ ...@@ -67,20 +68,14 @@
return form_gadget.getContent(); return form_gadget.getContent();
}) })
.push(function (content) { .push(function (content) {
return gadget.updateDocument(content) return gadget.updateDocument(content);
.push(function (ndoc) {
ndoc.allocation_scope = content.allocation_scope;
return gadget.render({
jio_key: gadget.state.jio_key,
doc: ndoc
});
});
}) })
.push(function () { .push(function () {
return gadget.notifySubmitted({message: gadget.message_translation, status: 'success'}); return gadget.notifySubmitted({message: gadget.message_translation, status: 'success'});
}); });
}) })
.declareMethod("triggerSubmit", function () { .declareMethod("triggerSubmit", function () {
return this.element.querySelector('button[type="submit"]').click(); return this.element.querySelector('button[type="submit"]').click();
}) })
...@@ -153,7 +148,7 @@ ...@@ -153,7 +148,7 @@
column_list = [ column_list = [
['SoftwareInstallation_getSoftwareReleaseInformation', results[2][1]], ['SoftwareInstallation_getSoftwareReleaseInformation', results[2][1]],
['url_string', results[2][2]], ['url_string', results[2][2]],
['SoftwareInstallation_getNewsDict', results[2][3]] ['getAccessStatus', results[2][3]]
], ],
ticket_column_list = [ ticket_column_list = [
['title', results[2][4]], ['title', results[2][4]],
...@@ -304,9 +299,11 @@ ...@@ -304,9 +299,11 @@
"my_monitoring_status": { "my_monitoring_status": {
"description": "", "description": "",
"title": results[2][29], "title": results[2][29],
"default": {jio_key: gadget.state.jio_key, "default": "",
result: gadget.state.doc.news, "renderjs_extra": JSON.stringify({
portal_type: "Compute Node"}, jio_key: gadget.state.jio_key,
result: gadget.state.doc.news
}),
"css_class": "", "css_class": "",
"required": 0, "required": 0,
"editable": 0, "editable": 0,
...@@ -416,4 +413,4 @@ ...@@ -416,4 +413,4 @@
return gadget.updateHeader(header_dict); return gadget.updateHeader(header_dict);
}); });
}); });
}(window, rJS, RSVP)); }(window, rJS, RSVP, JSON));
\ No newline at end of file \ No newline at end of file
...@@ -267,7 +267,7 @@ ...@@ -267,7 +267,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1009.49086.48551.49459</string> </value> <value> <string>1010.39674.54022.30344</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -287,7 +287,7 @@ ...@@ -287,7 +287,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1690911267.44</float> <float>1692648139.06</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -28,31 +28,28 @@ ...@@ -28,31 +28,28 @@
var gadget = this; var gadget = this;
return gadget.jio_allDocs(param_list[0]) return gadget.jio_allDocs(param_list[0])
.push(function (result) { .push(function (result) {
var i, value, news, len = result.data.total_rows; var i, value, value_jio_key, len = result.data.total_rows;
for (i = 0; i < len; i += 1) { for (i = 0; i < len; i += 1) {
if (1 || (result.data.rows[i].value.hasOwnProperty("ComputeNode_getNewsDict"))) { if (result.data.rows[i].value.hasOwnProperty("getAccessStatus")) {
value = result.data.rows[i].id; value_jio_key = result.data.rows[i].id;
news = result.data.rows[i].value.ComputeNode_getNewsDict; value = result.data.rows[i].value.getAccessStatus;
result.data.rows[i].value.ComputeNode_getNewsDict = { result.data.rows[i].value.getAccessStatus = {
field_gadget_param : { field_gadget_param : {
css_class: "", css_class: "",
description: "The Status", description: "The Status",
hidden: 0, hidden: 0,
"default": { "default": "",
jio_key: value, renderjs_extra: JSON.stringify({
result: news, jio_key: value_jio_key,
portal_type: "Compute Node" result: value
}, }),
key: "status", key: "status",
url: "gadget_slapos_status.html", url: "gadget_slapos_status.html",
title: gadget.title_translation, title: gadget.title_translation,
type: "GadgetField" type: "GadgetField"
} }
}; };
result.data.rows[i].value["listbox_uid:list"] = { result.data.rows[i].value["listbox_uid:list"] = {};
//key: "listbox_uid:list",
//value: 2713
};
} }
} }
return result; return result;
...@@ -121,7 +118,7 @@ ...@@ -121,7 +118,7 @@
['title', result[1][1]], ['title', result[1][1]],
['reference', result[1][2]], ['reference', result[1][2]],
['allocation_scope_translated_title', result[1][3]], ['allocation_scope_translated_title', result[1][3]],
['ComputeNode_getNewsDict', result[1][4]] ['getAccessStatus', result[1][4]]
]; ];
return result[0].render({ return result[0].render({
erp5_document: { erp5_document: {
...@@ -151,8 +148,11 @@ ...@@ -151,8 +148,11 @@
"my_monitoring_status": { "my_monitoring_status": {
"description": "", "description": "",
"title": result[1][5], "title": result[1][5],
"default": {jio_key: gadget.state.jio_key, "default": "",
result: gadget.state.doc.news}, "renderjs_extra": JSON.stringify({
jio_key: gadget.state.jio_key,
result: gadget.state.doc.news
}),
"css_class": "", "css_class": "",
"required": 0, "required": 0,
"editable": 0, "editable": 0,
......
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1009.17464.55631.39321</string> </value> <value> <string>1010.39734.62596.14779</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -258,7 +258,7 @@ ...@@ -258,7 +258,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1687465625.96</float> <float>1692672489.88</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global window, rJS, RSVP, jIO, Blob, btoa */ /*global window, rJS, RSVP, jIO, btoa, JSON */
/*jslint nomen: true, indent: 2, maxerr: 3 */ /*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, btoa) { (function (window, rJS, RSVP, jIO, btoa, JSON) {
"use strict"; "use strict";
rJS(window) rJS(window)
...@@ -27,17 +27,21 @@ ...@@ -27,17 +27,21 @@
var gadget = this; var gadget = this;
return gadget.jio_allDocs(param_list[0]) return gadget.jio_allDocs(param_list[0])
.push(function (result) { .push(function (result) {
var i, value, jio_key_value, len = result.data.total_rows; var i, value, value_jio_key, len = result.data.total_rows;
for (i = 0; i < len; i += 1) { for (i = 0; i < len; i += 1) {
if (1 || (result.data.rows[i].value.SoftwareInstance_getNewsDict)) { if (1 || (result.data.rows[i].value.SoftwareInstance_getNewsDict)) {
value = result.data.rows[i].value.SoftwareInstance_getNewsDict; value = result.data.rows[i].value.SoftwareInstance_getNewsDict;
jio_key_value = result.data.rows[i].id; value_jio_key = result.data.rows[i].id;
result.data.rows[i].value.SoftwareInstance_getNewsDict = { result.data.rows[i].value.SoftwareInstance_getNewsDict = {
field_gadget_param : { field_gadget_param : {
css_class: "", css_class: "",
description: gadget.description_translation, description: gadget.description_translation,
hidden: 0, hidden: 0,
"default": {jio_key: jio_key_value, result: value}, "default": "",
renderjs_extra: JSON.stringify({
jio_key: value_jio_key,
result: value
}),
key: "status", key: "status",
url: "gadget_slapos_status.html", url: "gadget_slapos_status.html",
title: gadget.title_translation, title: gadget.title_translation,
...@@ -49,7 +53,7 @@ ...@@ -49,7 +53,7 @@
value: 2713 value: 2713
}; };
} }
if (1 || (result.data.rows[i].value.hasOwnProperty("connection_key"))) { if (result.data.rows[i].value.hasOwnProperty("connection_key")) {
value = result.data.rows[i].value.connection_key; value = result.data.rows[i].value.connection_key;
result.data.rows[i].value.connection_key = { result.data.rows[i].value.connection_key = {
field_gadget_param : { field_gadget_param : {
...@@ -345,8 +349,11 @@ ...@@ -345,8 +349,11 @@
"my_monitoring_status": { "my_monitoring_status": {
"description": "", "description": "",
"title": result[1][23], "title": result[1][23],
"default": {jio_key: gadget.state.jio_key, "default": "",
result: gadget.state.doc.news}, "renderjs_extra": JSON.stringify({
jio_key: gadget.state.jio_key,
result: gadget.state.doc.news
}),
"css_class": "", "css_class": "",
"required": 0, "required": 0,
"editable": 0, "editable": 0,
...@@ -543,4 +550,4 @@ ...@@ -543,4 +550,4 @@
return gadget.updateHeader(header_dict); return gadget.updateHeader(header_dict);
}); });
}); });
}(window, rJS, RSVP, btoa)); }(window, rJS, RSVP, jIO, btoa, JSON));
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1008.51163.7897.31249</string> </value> <value> <string>1009.49086.48551.49459</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -258,7 +258,7 @@ ...@@ -258,7 +258,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1687459175.1</float> <float>1692645657.66</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global window, rJS, RSVP */ /*global window, rJS, RSVP, JSON */
/*jslint nomen: true, indent: 2, maxerr: 3*/ /*jslint nomen: true, indent: 2, maxerr: 3*/
(function (window, rJS, RSVP) { (function (window, rJS, RSVP, JSON) {
"use strict"; "use strict";
rJS(window) rJS(window)
...@@ -18,18 +18,21 @@ ...@@ -18,18 +18,21 @@
var gadget = this; var gadget = this;
return gadget.jio_allDocs(param_list[0]) return gadget.jio_allDocs(param_list[0])
.push(function (result) { .push(function (result) {
var i, value, news, len = result.data.total_rows; var i, value, value_jio_key, len = result.data.total_rows;
for (i = 0; i < len; i += 1) { for (i = 0; i < len; i += 1) {
if (result.data.rows[i].value.hasOwnProperty("ComputerNetwork_getNewsDict")) { if (result.data.rows[i].value.hasOwnProperty("ComputerNetwork_getNewsDict")) {
value = result.data.rows[i].id; value_jio_key = result.data.rows[i].id;
news = result.data.rows[i].value.ComputerNetwork_getNewsDict; value = result.data.rows[i].value.ComputerNetwork_getNewsDict;
result.data.rows[i].value.ComputerNetwork_getNewsDict = { result.data.rows[i].value.ComputerNetwork_getNewsDict = {
field_gadget_param : { field_gadget_param : {
css_class: "", css_class: "",
description: "The Status", description: "The Status",
hidden: 0, hidden: 0,
"default": {jio_key: value, default: "",
result: news}, renderjs_extra: JSON.stringify({
jio_key: value_jio_key,
result: value
}),
key: "status", key: "status",
url: "gadget_slapos_status.html", url: "gadget_slapos_status.html",
title: "Status", title: "Status",
...@@ -141,4 +144,4 @@ ...@@ -141,4 +144,4 @@
}); });
}); });
}); });
}(window, rJS, RSVP)); }(window, rJS, RSVP, JSON));
\ No newline at end of file \ No newline at end of file
...@@ -249,7 +249,7 @@ ...@@ -249,7 +249,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1001.59379.40192.59272</string> </value> <value> <string>1010.39717.23460.37051</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -269,7 +269,7 @@ ...@@ -269,7 +269,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1659068921.68</float> <float>1692646374.56</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global window, rJS, RSVP */ /*global window, rJS, RSVP, JSON */
/*jslint nomen: true, indent: 2, maxerr: 3*/ /*jslint nomen: true, indent: 2, maxerr: 3*/
(function (window, rJS, RSVP) { (function (window, rJS, RSVP, JSON) {
"use strict"; "use strict";
rJS(window) rJS(window)
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
.declareAcquiredMethod("redirect", "redirect") .declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("reload", "reload") .declareAcquiredMethod("reload", "reload")
.declareAcquiredMethod("getSetting", "getSetting") .declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("setSetting", "setSetting")
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs") .declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment") .declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
...@@ -19,16 +18,20 @@ ...@@ -19,16 +18,20 @@
var gadget = this; var gadget = this;
return gadget.jio_allDocs(param_list[0]) return gadget.jio_allDocs(param_list[0])
.push(function (result) { .push(function (result) {
var i, value, news, len = result.data.total_rows; var i, value, value_jio_key, len = result.data.total_rows;
for (i = 0; i < len; i += 1) { for (i = 0; i < len; i += 1) {
if (1 || (result.data.rows[i].value.hasOwnProperty("InstanceTree_getNewsDict"))) { if (result.data.rows[i].value.hasOwnProperty("InstanceTree_getNewsDict")) {
value = result.data.rows[i].id; value_jio_key = result.data.rows[i].id;
news = result.data.rows[i].value.InstanceTree_getNewsDict; value = result.data.rows[i].value.InstanceTree_getNewsDict;
result.data.rows[i].value.InstanceTree_getNewsDict = { result.data.rows[i].value.InstanceTree_getNewsDict = {
field_gadget_param : { field_gadget_param : {
css_class: "", css_class: "",
hidden: 0, hidden: 0,
default: {jio_key: value, result: news}, default: "",
renderjs_extra: JSON.stringify({
jio_key: value_jio_key,
result: value
}),
key: "status", key: "status",
url: "gadget_slapos_status.html", url: "gadget_slapos_status.html",
type: "GadgetField" type: "GadgetField"
...@@ -105,4 +108,4 @@ ...@@ -105,4 +108,4 @@
}); });
}); });
}); });
}(window, rJS, RSVP)); }(window, rJS, RSVP, JSON));
\ No newline at end of file \ No newline at end of file
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1001.59388.52713.22408</string> </value> <value> <string>1010.39704.42949.15616</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -258,7 +258,7 @@ ...@@ -258,7 +258,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1659068879.32</float> <float>1692646558.09</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global window, rJS, RSVP */ /*global window, rJS, RSVP, JSON */
/*jslint nomen: true, indent: 2, maxerr: 3*/ /*jslint nomen: true, indent: 2, maxerr: 3*/
(function (window, rJS, RSVP) { (function (window, rJS, RSVP, JSON) {
'use strict'; 'use strict';
rJS(window) rJS(window)
...@@ -24,10 +24,7 @@ ...@@ -24,10 +24,7 @@
value_jio_key, value_jio_key,
len = result.data.total_rows; len = result.data.total_rows;
for (i = 0; i < len; i += 1) { for (i = 0; i < len; i += 1) {
if ( if (result.data.rows[i].value.hasOwnProperty('Organisation_getNewsDict')) {
1 ||
result.data.rows[i].value.hasOwnProperty('Organisation_getNewsDict')
) {
value_jio_key = result.data.rows[i].id; value_jio_key = result.data.rows[i].id;
value = result.data.rows[i].value.Organisation_getNewsDict; value = result.data.rows[i].value.Organisation_getNewsDict;
result.data.rows[i].value.Organisation_getNewsDict = { result.data.rows[i].value.Organisation_getNewsDict = {
...@@ -35,7 +32,11 @@ ...@@ -35,7 +32,11 @@
css_class: '', css_class: '',
description: 'The Status', description: 'The Status',
hidden: 0, hidden: 0,
default: { jio_key: value_jio_key, result: value }, default: "",
renderjs_extra: JSON.stringify({
jio_key: value_jio_key,
result: value
}),
key: 'status', key: 'status',
url: 'gadget_slapos_status.html', url: 'gadget_slapos_status.html',
title: 'Status', title: 'Status',
...@@ -94,7 +95,6 @@ ...@@ -94,7 +95,6 @@
column_list = [ column_list = [
['title', result[2][0]], ['title', result[2][0]],
['reference', result[2][1]], ['reference', result[2][1]],
//['default_address_region_title', result[2][2]],
['Organisation_getNewsDict', result[2][3]] ['Organisation_getNewsDict', result[2][3]]
]; ];
destination_list = '%22NULL%22%2C'; destination_list = '%22NULL%22%2C';
...@@ -168,4 +168,4 @@ ...@@ -168,4 +168,4 @@
}); });
}); });
}); });
}(window, rJS, RSVP)); }(window, rJS, RSVP, JSON));
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1001.59386.28929.32102</string> </value> <value> <string>1010.39714.20170.25019</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -258,7 +258,7 @@ ...@@ -258,7 +258,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1659068860.66</float> <float>1692645285.36</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global window, rJS, RSVP, jIO, Blob */ /*global window, rJS, RSVP, JSON */
/*jslint nomen: true, indent: 2, maxerr: 3 */ /*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP) { (function (window, rJS, RSVP, JSON) {
"use strict"; "use strict";
rJS(window) rJS(window)
...@@ -30,17 +30,21 @@ ...@@ -30,17 +30,21 @@
.push(function (result) { .push(function (result) {
var i, value, value_jio_key, len = result.data.total_rows; var i, value, value_jio_key, len = result.data.total_rows;
for (i = 0; i < len; i += 1) { for (i = 0; i < len; i += 1) {
if (1 || (result.data.rows[i].value.hasOwnProperty("ComputeNode_getNewsDict"))) { if (result.data.rows[i].value.hasOwnProperty("getAccessStatus")) {
value_jio_key = result.data.rows[i].id; value_jio_key = result.data.rows[i].id;
value = result.data.rows[i].value.ComputeNode_getNewsDict; value = result.data.rows[i].value.getAccessStatus;
result.data.rows[i].value.ComputeNode_getNewsDict = { result.data.rows[i].value.getAccessStatus = {
field_gadget_param : { field_gadget_param : {
css_class: "", css_class: "",
description: gadget.description_translation, description: gadget.description_translation,
hidden: 0, hidden: 0,
"default": {jio_key: value_jio_key, result: value, portal_type: "Compute Node"}, default: "",
key: "status", key: "status",
url: "gadget_slapos_status.html", url: "gadget_slapos_status.html",
renderjs_extra: JSON.stringify({
jio_key: value_jio_key,
result: value
}),
title: gadget.title_translation, title: gadget.title_translation,
type: "GadgetField" type: "GadgetField"
} }
...@@ -117,7 +121,7 @@ ...@@ -117,7 +121,7 @@
column_list = [ column_list = [
['title', result[2][0]], ['title', result[2][0]],
['reference', result[2][1]], ['reference', result[2][1]],
['ComputeNode_getNewsDict', result[2][9]] ['getAccessStatus', result[2][9]]
]; ];
return result[0].render({ return result[0].render({
erp5_document: { erp5_document: {
...@@ -169,8 +173,11 @@ ...@@ -169,8 +173,11 @@
"my_monitoring_status": { "my_monitoring_status": {
"description": "", "description": "",
"title": result[2][4], "title": result[2][4],
"default": {jio_key: gadget.state.jio_key, "default": "",
result: gadget.state.doc.news}, "renderjs_extra": JSON.stringify({
jio_key: gadget.state.jio_key,
result: gadget.state.doc.news
}),
"css_class": "", "css_class": "",
"required": 1, "required": 1,
"editable": 0, "editable": 0,
...@@ -270,4 +277,4 @@ ...@@ -270,4 +277,4 @@
return gadget.updateHeader(header_dict); return gadget.updateHeader(header_dict);
}); });
}); });
}(window, rJS, RSVP)); }(window, rJS, RSVP, JSON));
\ No newline at end of file \ No newline at end of file
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>999.2068.62564.17</string> </value> <value> <string>1010.39676.63129.16622</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -256,7 +256,7 @@ ...@@ -256,7 +256,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1654874891.91</float> <float>1692673382.31</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global window, rJS, RSVP, jIO, Blob */ /*global window, rJS, RSVP, JSON */
/*jslint nomen: true, indent: 2, maxerr: 3 */ /*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP) { (function (window, rJS, RSVP, JSON) {
"use strict"; "use strict";
rJS(window) rJS(window)
...@@ -153,10 +153,11 @@ ...@@ -153,10 +153,11 @@
"my_monitoring_status": { "my_monitoring_status": {
"description": "", "description": "",
"title": result[2][8], "title": result[2][8],
"default": { "default": "",
"renderjs_extra": JSON.stringify({
jio_key: gadget.state.jio_key, jio_key: gadget.state.jio_key,
result: gadget.state.doc.news result: gadget.state.doc.news
}, }),
"css_class": "", "css_class": "",
"required": 1, "required": 1,
"editable": 0, "editable": 0,
...@@ -210,4 +211,4 @@ ...@@ -210,4 +211,4 @@
return gadget.updateHeader(header_dict); return gadget.updateHeader(header_dict);
}); });
}); });
}(window, rJS, RSVP)); }(window, rJS, RSVP, JSON));
\ No newline at end of file \ No newline at end of file
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1001.26171.19762.42854</string> </value> <value> <string>1006.58340.40727.23620</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -258,7 +258,7 @@ ...@@ -258,7 +258,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1657906193.21</float> <float>1692645366.58</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global window, rJS, RSVP, jIO, Blob */ /*global window, rJS, RSVP, JSON */
/*jslint nomen: true, indent: 2, maxerr: 3 */ /*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP) { (function (window, rJS, JSON) {
"use strict"; "use strict";
rJS(window) rJS(window)
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
.push(function (result) { .push(function (result) {
var i, value, len = result.data.total_rows; var i, value, len = result.data.total_rows;
for (i = 0; i < len; i += 1) { for (i = 0; i < len; i += 1) {
if (1 || (result.data.rows[i].value.hasOwnProperty("connection_key"))) { if (result.data.rows[i].value.hasOwnProperty("connection_key")) {
value = result.data.rows[i].value.connection_key; value = result.data.rows[i].value.connection_key;
result.data.rows[i].value.connection_key = { result.data.rows[i].value.connection_key = {
field_gadget_param : { field_gadget_param : {
...@@ -164,11 +164,11 @@ ...@@ -164,11 +164,11 @@
"my_monitoring_status": { "my_monitoring_status": {
"description": "", "description": "",
"title": result[2][2], "title": result[2][2],
"default": { "default": "",
"renderjs_extra": JSON.stringify({
jio_key: gadget.state.jio_key, jio_key: gadget.state.jio_key,
result: gadget.state.doc.news, result: gadget.state.doc.news
portal_type: gadget.state.doc.portal_type }),
},
"css_class": "", "css_class": "",
"required": 1, "required": 1,
"editable": 0, "editable": 0,
...@@ -307,4 +307,4 @@ ...@@ -307,4 +307,4 @@
return gadget.updateHeader(header_dict); return gadget.updateHeader(header_dict);
}); });
}); });
}(window, rJS, RSVP)); }(window, rJS, RSVP, JSON));
\ No newline at end of file \ No newline at end of file
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1008.13874.12169.28194</string> </value> <value> <string>1010.39695.33171.41693</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -258,7 +258,7 @@ ...@@ -258,7 +258,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1684250249.63</float> <float>1692644162.31</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global document, window, Option, rJS, RSVP, Chart, UriTemplate, domsugar */ /*global document, window, rJS, RSVP, Chart, domsugar, JSON */
/*jslint nomen: true, indent: 2, maxerr: 3 */ /*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, domsugar) { (function (window, rJS, RSVP, domsugar, JSON) {
"use strict"; "use strict";
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
gadget_klass gadget_klass
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
.declareAcquiredMethod("getTranslationList", "getTranslationList") .declareAcquiredMethod("getTranslationList", "getTranslationList")
.declareAcquiredMethod("redirect", "redirect") .declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("updateHeader", "updateHeader") .declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("updateConfiguration", "updateConfiguration")
.declareAcquiredMethod("getSetting", "getSetting") .declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs") .declareAcquiredMethod("jio_allDocs", "jio_allDocs")
...@@ -41,7 +40,11 @@ ...@@ -41,7 +40,11 @@
css_class: "", css_class: "",
description: "The Status", description: "The Status",
hidden: 0, hidden: 0,
"default": {jio_key: value_jio_key, result: value}, default: "",
renderjs_extra: JSON.stringify({
jio_key: value_jio_key,
result: value
}),
key: "status", key: "status",
url: "gadget_slapos_status.html", url: "gadget_slapos_status.html",
title: "Status", title: "Status",
...@@ -393,4 +396,4 @@ ...@@ -393,4 +396,4 @@
}); });
}); });
}); });
}(window, rJS, RSVP, domsugar)); }(window, rJS, RSVP, domsugar, JSON));
\ No newline at end of file \ No newline at end of file
...@@ -249,7 +249,7 @@ ...@@ -249,7 +249,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1004.6436.36702.26948</string> </value> <value> <string>1010.39708.44914.39287</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -269,7 +269,7 @@ ...@@ -269,7 +269,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1668205150.06</float> <float>1692644993.84</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
return context.getAccessStatus()
<?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>REQUEST=None</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ComputeNode_getNewsDict</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -126,7 +126,7 @@ ...@@ -126,7 +126,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string>here/ComputeNode_getNewsDict</string> </value> <value> <string>here/getAccessStatus</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
portal_type = context.getPortalType() portal_type = context.getPortalType()
if portal_type == "Compute Node": if portal_type == "Compute Node":
return context.ComputeNode_getNewsDict(**kw) return context.getAccessStatus(**kw)
if portal_type == "Instance Tree": if portal_type == "Instance Tree":
return context.InstanceTree_getNewsDict(**kw) return context.InstanceTree_getNewsDict(**kw)
......
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
return context.getAccessStatus()
<?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>REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SoftwareInstallation_getNewsDict</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -126,7 +126,7 @@ ...@@ -126,7 +126,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string>here/SoftwareInstallation_getNewsDict</string> </value> <value> <string>here/getAccessStatus</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -389,201 +389,6 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -389,201 +389,6 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin):
self.assertEqual(_decode_with_json(news_dict), self.assertEqual(_decode_with_json(news_dict),
_decode_with_json(expected_news_dict)) _decode_with_json(expected_news_dict))
class TestSoftwareInstallation_getNewsDict(TestSlapOSHalJsonStyleMixin):
def test(self):
installation = self._makeSoftwareInstallation()
self._logFakeAccess(installation)
news_dict = installation.SoftwareInstallation_getNewsDict()
expected_news_dict = {'created_at': self.created_at,
'no_data_since_15_minutes': 0,
'no_data_since_5_minutes': 0,
'portal_type': installation.getPortalType(),
'reference': installation.getReference(),
'since': self.created_at,
'state': 'start_requested',
'text': '#access OK',
'user': 'SlapOS Master'}
self.assertEqual(_decode_with_json(news_dict),
_decode_with_json(expected_news_dict))
def test_stopped(self):
installation = self._makeSoftwareInstallation()
self._logFakeAccess(installation,
state='stop_requested')
news_dict = installation.SoftwareInstallation_getNewsDict()
installation.getSlapState = fakeStopRequestedSlapState
expected_news_dict = {'created_at': self.created_at,
'no_data_since_15_minutes': 0,
'no_data_since_5_minutes': 0,
'portal_type': installation.getPortalType(),
'reference': installation.getReference(),
'since': self.created_at,
'state': 'stop_requested',
'text': '#access OK',
'user': 'SlapOS Master'}
self.assertEqual(_decode_with_json(news_dict),
_decode_with_json(expected_news_dict))
def test_destroyed(self):
installation = self._makeSoftwareInstallation()
self._logFakeAccess(installation,
state='destroy_requested')
news_dict = installation.SoftwareInstallation_getNewsDict()
installation.getSlapState = fakeDestroyRequestedSlapState
expected_news_dict = {'created_at': self.created_at,
'no_data_since_15_minutes': 0,
'no_data_since_5_minutes': 0,
'portal_type': installation.getPortalType(),
'reference': installation.getReference(),
'since': self.created_at,
'state': 'destroy_requested',
'text': '#access OK',
'user': 'SlapOS Master'}
self.assertEqual(_decode_with_json(news_dict),
_decode_with_json(expected_news_dict))
def test_no_data(self):
installation = self._makeSoftwareInstallation()
news_dict = installation.SoftwareInstallation_getNewsDict()
expected_news_dict = {'created_at': self.created_at,
'no_data': 1,
'portal_type': installation.getPortalType(),
'reference': installation.getReference(),
'since': self.created_at,
'state': '',
'text': '#error no data found for %s' % installation.getReference(),
'user': 'SlapOS Master'
}
self.assertEqual(_decode_with_json(news_dict),
_decode_with_json(expected_news_dict))
class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin):
def test(self):
compute_node = self._makeComputeNode()
self._logFakeAccess(compute_node)
news_dict = compute_node.ComputeNode_getNewsDict()
expected_news_dict = {'created_at': self.created_at,
'no_data_since_15_minutes': 0,
'no_data_since_5_minutes': 0,
'portal_type': compute_node.getPortalType(),
'reference': compute_node.getReference(),
'since': self.created_at,
'state': 'start_requested',
'text': '#access OK',
'user': 'SlapOS Master'}
self.assertEqual(_decode_with_json(news_dict),
_decode_with_json(expected_news_dict))
self.tic()
# Retest so cache is evaludated
news_dict = compute_node.ComputeNode_getNewsDict()
self.assertEqual(_decode_with_json(news_dict),
_decode_with_json(expected_news_dict))
def test_stopped(self):
compute_node = self._makeComputeNode()
self._logFakeAccess(compute_node,
state='stop_requested')
news_dict = compute_node.ComputeNode_getNewsDict()
compute_node.getSlapState = fakeStopRequestedSlapState
expected_news_dict = {'created_at': self.created_at,
'no_data_since_15_minutes': 0,
'no_data_since_5_minutes': 0,
'portal_type': compute_node.getPortalType(),
'reference': compute_node.getReference(),
'since': self.created_at,
'state': 'stop_requested',
'text': '#access OK',
'user': 'SlapOS Master'
}
self.assertEqual(_decode_with_json(news_dict),
_decode_with_json(expected_news_dict))
self.tic()
# Retest so cache is evaludated
news_dict = compute_node.ComputeNode_getNewsDict()
self.assertEqual(_decode_with_json(news_dict),
_decode_with_json(expected_news_dict))
def test_destroyed(self):
compute_node = self._makeComputeNode()
self._logFakeAccess(compute_node,
state='destroy_requested')
news_dict = compute_node.ComputeNode_getNewsDict()
compute_node.getSlapState = fakeDestroyRequestedSlapState
expected_news_dict = {'created_at': self.created_at,
'no_data_since_15_minutes': 0,
'no_data_since_5_minutes': 0,
'portal_type': compute_node.getPortalType(),
'reference': compute_node.getReference(),
'since': self.created_at,
'state': 'destroy_requested',
'text': '#access OK',
'user': 'SlapOS Master'
}
self.assertEqual(_decode_with_json(news_dict),
_decode_with_json(expected_news_dict))
self.tic()
# Retest so cache is evaludated
news_dict = compute_node.ComputeNode_getNewsDict()
self.assertEqual(_decode_with_json(news_dict),
_decode_with_json(expected_news_dict))
def test_no_data(self):
compute_node = self._makeComputeNode()
news_dict = compute_node.ComputeNode_getNewsDict()
expected_news_dict = {'created_at': self.created_at,
'no_data': 1,
'portal_type': compute_node.getPortalType(),
'reference': compute_node.getReference(),
'since': self.created_at,
'state': '',
'text': '#error no data found for %s' % compute_node.getReference(),
'user': 'SlapOS Master'
}
self.assertEqual(_decode_with_json(news_dict),
_decode_with_json(expected_news_dict))
self.tic()
# Retest so cache is evaludated
news_dict = compute_node.ComputeNode_getNewsDict()
self.assertEqual(_decode_with_json(news_dict),
_decode_with_json(expected_news_dict))
def test_with_instance(self):
compute_node = self._makeComputeNode()
instance = self._makeInstance()
instance.setAggregateValue(self.partition0)
self.tic()
self._logFakeAccess(compute_node)
news_dict = compute_node.ComputeNode_getNewsDict()
expected_news_dict = {u'created_at': u'%s' % self.created_at,
'no_data_since_15_minutes': 0,
'no_data_since_5_minutes': 0,
'portal_type': compute_node.getPortalType(),
'reference': compute_node.getReference(),
u'since': u'%s' % self.created_at,
u'state': u'start_requested',
u'text': u'#access OK',
u'user': u'SlapOS Master'
}
self.assertEqual(_decode_with_json(news_dict),
_decode_with_json(expected_news_dict))
self.tic()
# Retest so cache is evaludated
news_dict = compute_node.ComputeNode_getNewsDict()
self.assertEqual(_decode_with_json(news_dict),
_decode_with_json(expected_news_dict))
class TestComputerNetwork_getNewsDict(TestSlapOSHalJsonStyleMixin): class TestComputerNetwork_getNewsDict(TestSlapOSHalJsonStyleMixin):
def test(self): def test(self):
......
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