Commit 4af007fa authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Let the API provide the monitor_url

  This makes monitor url, JS agnostic and part of API.
  This also places the real url (bookmarkable) on the gadget link, not requiring to rely on master to redirect.
parent f84f7b57
...@@ -206,11 +206,11 @@ ...@@ -206,11 +206,11 @@
class: "ui-btn ui-btn-icon-left ui-icon-desktop" class: "ui-btn ui-btn-icon-left ui-icon-desktop"
}; };
if (result && result.portal_type && result.portal_type === "Compute Node") { if (result && result.monitor_url) {
monitor_url = 'https://monitor.app.officejs.com/#/' + monitor_url = result.monitor_url
'?page=ojsm_dispatch&query=portal_type%3A%22Software%20Instance%22%20' + }
'AND%20aggregate_reference%3A%22' + result.reference + '%22';
if (result && result.portal_type && result.portal_type === "Compute Node") {
main_link_configuration_dict.href = monitor_url; main_link_configuration_dict.href = monitor_url;
main_link_configuration_dict.target = "_target"; main_link_configuration_dict.target = "_target";
main_link_configuration_dict.text = 'Compute Node'; main_link_configuration_dict.text = 'Compute Node';
...@@ -250,13 +250,7 @@ ...@@ -250,13 +250,7 @@
result.portal_type === "Software Instance" || result.portal_type === "Software Instance" ||
result.portal_type === "Slave Instance" result.portal_type === "Slave Instance"
)) { )) {
monitor_url = 'https://monitor.app.officejs.com/#/' + status_class = getInstanceStatus(result);
'?page=ojsm_dispatch&query=' +
'portal_type%3A%22Software%20Instance%22%20AND%20reference%3A%22' +
result.reference + '%22';
if (result && result.news) {
status_class = getInstanceStatus(result.news);
}
right_class = "ui-btn-hide"; right_class = "ui-btn-hide";
if (status_class === 'ui-btn-is-slave') { if (status_class === 'ui-btn-is-slave') {
status_class = 'ui-btn-no-data ui-btn-color-white'; status_class = 'ui-btn-no-data ui-btn-color-white';
...@@ -278,19 +272,6 @@ ...@@ -278,19 +272,6 @@
status_class = getInstanceTreeStatus(result.news); status_class = getInstanceTreeStatus(result.news);
} }
// it should verify if the monitor-base-url is ready. // it should verify if the monitor-base-url is ready.
for (i in result.connection_parameter_list) {
if (result.connection_parameter_list.hasOwnProperty(i)) {
if (result.connection_parameter_list[i].connection_key ===
"monitor-setup-url") {
monitor_url = result.connection_parameter_list[i].connection_value;
}
}
}
if (monitor_url === "") {
monitor_url = 'https://monitor.app.officejs.com/#/' +
'?page=ojsm_dispatch&query=portal_type' +
'%3A%22Instance%20Tree%22%20AND%20title%3A' + result.title;
}
right_class = "ui-btn-hide"; right_class = "ui-btn-hide";
if (status_class === 'ui-btn-is-slave') { if (status_class === 'ui-btn-is-slave') {
status_class = 'ui-btn-no-data ui-btn-color-white'; status_class = 'ui-btn-no-data ui-btn-color-white';
...@@ -307,8 +288,6 @@ ...@@ -307,8 +288,6 @@
main_link_configuration_dict.text = 'Instance'; main_link_configuration_dict.text = 'Instance';
} }
} else { } else {
monitor_url = gadget.state.jio_key + '/Base_redirectToMonitor';
main_link_configuration_dict.href = monitor_url; main_link_configuration_dict.href = monitor_url;
main_link_configuration_dict.target = "_target"; main_link_configuration_dict.target = "_target";
main_link_configuration_dict.text = 'Compute Node'; main_link_configuration_dict.text = 'Compute Node';
...@@ -351,7 +330,9 @@ ...@@ -351,7 +330,9 @@
if (gadget.state.jio_key) { if (gadget.state.jio_key) {
return gadget.jio_get(gadget.state.jio_key) return gadget.jio_get(gadget.state.jio_key)
.push(function (result) { .push(function (result) {
return gadget.changeState(result); var state_dict = result.news || {};
state_dict.jio_key = gadget.state.jio_key;
return gadget.changeState(state_dict);
}); });
} }
}, 300000) }, 300000)
......
...@@ -274,7 +274,7 @@ ...@@ -274,7 +274,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1001.20643.53333.20275</string> </value> <value> <string>1001.50668.64434.580</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -292,7 +292,7 @@ ...@@ -292,7 +292,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1656964043.27</float> <float>1658520198.62</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -10,4 +10,7 @@ for compute_node in compute_node_list: ...@@ -10,4 +10,7 @@ for compute_node in compute_node_list:
compute_partition_dict[compute_node.getReference()] = news_dict["partition"] compute_partition_dict[compute_node.getReference()] = news_dict["partition"]
return {"compute_node": compute_node_dict, return {"compute_node": compute_node_dict,
"partition": compute_partition_dict} "partition": compute_partition_dict,
"reference": context.getReference(),
"portal_type": context.getPortalType(),
"monitor_url": context.Base_getStatusMonitorUrl()}
base_url = 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Software Instance" AND '
if context.getPortalType() == "Organisation":
compute_node_reference = ",".join([ '"' + i.getReference() + '"' for i in context.Organisation_getComputeNodeTrackingList()])
return base_url + "aggregate_reference:(%s)" % compute_node_reference
if context.getPortalType() == "Project":
compute_node_reference = ",".join([ '"' + i.getReference() + '"' for i in context.Project_getComputeNodeTrackingList()])
return base_url + "aggregate_reference:(%s)" % compute_node_reference
if context.getPortalType() == "Computer Network":
compute_node_reference = ",".join([ '"' + i.getReference() + '"' for i in context.getSubordinationRelatedValueList(portal_type="Compute Node")])
return base_url + "aggregate_reference:(%s)" % compute_node_reference
if context.getPortalType() == "Instance Tree":
for connection_parameter in context.InstanceTree_getConnectionParameterList():
if connection_parameter['connection_key'] == "monitor-setup-url":
return context.REQUEST.RESPONSE.redirect(connection_parameter['connection_key'])
base_url = 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Instance Tree" AND '
return base_url + "title:(%s)" % context.getTitle()
if context.getPortalType() in ["Software Instance", "Slave Instance"]:
return base_url + "reference:%s" % context.getReference()
if context.getPortalType() == "Compute Node":
return base_url + "aggregate_reference:%s" % context.getReference()
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>Base_redirectToMonitor</string> </value> <value> <string>Base_getStatusMonitorUrl</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
base_url = 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Software Instance" AND '
if context.getPortalType() == "Organisation":
compute_node_reference = ",".join([ '"' + i.getReference() + '"' for i in context.Organisation_getComputeNodeTrackingList()])
return context.REQUEST.RESPONSE.redirect(base_url + "aggregate_reference:(%s)" % compute_node_reference)
if context.getPortalType() == "Project":
compute_node_reference = ",".join([ '"' + i.getReference() + '"' for i in context.Project_getComputeNodeTrackingList()])
return context.REQUEST.RESPONSE.redirect(base_url + "aggregate_reference:(%s)" % compute_node_reference)
...@@ -13,7 +13,8 @@ def get_compute_partition_dict(reference): ...@@ -13,7 +13,8 @@ def get_compute_partition_dict(reference):
return {"compute_node": compute_node_dict, return {"compute_node": compute_node_dict,
"partition": compute_partition_dict, "partition": compute_partition_dict,
"portal_type": compute_node_dict['portal_type'], "portal_type": compute_node_dict['portal_type'],
"reference": compute_node_dict['reference']} "reference": compute_node_dict['reference'],
"monitor_url": context.Base_getStatusMonitorUrl()}
# Use Cache here, at least transactional one. # Use Cache here, at least transactional one.
return get_compute_partition_dict(context.getReference()) return get_compute_partition_dict(context.getReference())
...@@ -3,6 +3,7 @@ news_dict = { ...@@ -3,6 +3,7 @@ news_dict = {
"portal_type": context.getPortalType(), "portal_type": context.getPortalType(),
"reference": context.getReference(), "reference": context.getReference(),
"title": context.getTitle(), "title": context.getTitle(),
"monitor_url": context.Base_getStatusMonitorUrl(),
"instance" : []} "instance" : []}
if context.getSlapState() == 'stop_requested': if context.getSlapState() == 'stop_requested':
......
...@@ -7,6 +7,7 @@ if portal_type == "Slave Instance": ...@@ -7,6 +7,7 @@ if portal_type == "Slave Instance":
return { return {
"user": "SlapOS Master", "user": "SlapOS Master",
"text": "#nodata is a slave %s" % context.getReference(), "text": "#nodata is a slave %s" % context.getReference(),
"monitor_url": context.Base_getStatusMonitorUrl(),
"is_slave": 1 "is_slave": 1
} }
...@@ -15,6 +16,7 @@ if portal_type == "Software Instance" and slap_state == "stop_requested": ...@@ -15,6 +16,7 @@ if portal_type == "Software Instance" and slap_state == "stop_requested":
return { return {
"user": "SlapOS Master", "user": "SlapOS Master",
"text": "#nodata is an stopped instance %s" % context.getReference(), "text": "#nodata is an stopped instance %s" % context.getReference(),
"monitor_url": context.Base_getStatusMonitorUrl(),
"is_stopped": 1 "is_stopped": 1
} }
...@@ -22,7 +24,10 @@ if portal_type == "Software Instance" and slap_state == "destroy_requested": ...@@ -22,7 +24,10 @@ if portal_type == "Software Instance" and slap_state == "destroy_requested":
return { return {
"user": "SlapOS Master", "user": "SlapOS Master",
"text": "#nodata is an destroyed instance %s" % context.getReference(), "text": "#nodata is an destroyed instance %s" % context.getReference(),
"monitor_url": context.Base_getStatusMonitorUrl(),
"is_destroyed": 1 "is_destroyed": 1
} }
return context.getAccessStatus() news_dict = context.getAccessStatus()
news_dict["monitor_url"] = context.Base_getStatusMonitorUrl()
return news_dict
...@@ -161,7 +161,8 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -161,7 +161,8 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin):
'instance': [], 'instance': [],
'portal_type': instance_tree.getPortalType(), 'portal_type': instance_tree.getPortalType(),
'reference': instance_tree.getReference(), 'reference': instance_tree.getReference(),
'title': instance_tree.getTitle() 'title': instance_tree.getTitle(),
'monitor_url': 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Instance Tree" AND title:(Template Instance Tree)'
} }
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))
...@@ -174,6 +175,7 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -174,6 +175,7 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin):
'portal_type': instance_tree.getPortalType(), 'portal_type': instance_tree.getPortalType(),
'reference': instance_tree.getReference(), 'reference': instance_tree.getReference(),
'title': instance_tree.getTitle(), 'title': instance_tree.getTitle(),
'monitor_url': 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Instance Tree" AND title:(Template Instance Tree)',
'is_slave': 1 'is_slave': 1
} }
self.assertEqual(news_dict, self.assertEqual(news_dict,
...@@ -187,6 +189,7 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -187,6 +189,7 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin):
'portal_type': instance_tree.getPortalType(), 'portal_type': instance_tree.getPortalType(),
'reference': instance_tree.getReference(), 'reference': instance_tree.getReference(),
'title': instance_tree.getTitle(), 'title': instance_tree.getTitle(),
'monitor_url': 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Instance Tree" AND title:(Template Instance Tree)',
'is_stopped': 1 'is_stopped': 1
} }
self.assertEqual(_decode_with_json(news_dict), self.assertEqual(_decode_with_json(news_dict),
...@@ -200,6 +203,7 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -200,6 +203,7 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin):
'portal_type': instance_tree.getPortalType(), 'portal_type': instance_tree.getPortalType(),
'reference': instance_tree.getReference(), 'reference': instance_tree.getReference(),
'title': instance_tree.getTitle(), 'title': instance_tree.getTitle(),
'monitor_url': 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Instance Tree" AND title:(Template Instance Tree)',
'is_destroyed': 1 'is_destroyed': 1
} }
self.assertEqual(_decode_with_json(news_dict), self.assertEqual(_decode_with_json(news_dict),
...@@ -216,11 +220,15 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -216,11 +220,15 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin):
'portal_type': instance_tree.getPortalType(), 'portal_type': instance_tree.getPortalType(),
'reference': instance_tree.getReference(), 'reference': instance_tree.getReference(),
'title': instance_tree.getTitle(), 'title': instance_tree.getTitle(),
'monitor_url': 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Instance Tree" AND title:(Template Instance Tree)',
'instance': [{'created_at': self.created_at, 'instance': [{'created_at': self.created_at,
'no_data': 1, 'no_data': 1,
'portal_type': instance.getPortalType(), 'portal_type': instance.getPortalType(),
'reference': instance.getReference(), 'reference': instance.getReference(),
'since': self.created_at, 'since': self.created_at,
'monitor_url': 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Software Instance" AND reference:%s' % (
instance.getReference()
),
'state': '', 'state': '',
'text': '#error no data found for %s' % instance.getReference(), 'text': '#error no data found for %s' % instance.getReference(),
'user': 'SlapOS Master'}] 'user': 'SlapOS Master'}]
...@@ -239,7 +247,8 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -239,7 +247,8 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin):
'portal_type': instance_tree.getPortalType(), 'portal_type': instance_tree.getPortalType(),
'reference': instance_tree.getReference(), 'reference': instance_tree.getReference(),
'title': instance_tree.getTitle(), 'title': instance_tree.getTitle(),
'instance': [] 'instance': [],
'monitor_url': 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Instance Tree" AND title:(Template Instance Tree)'
} }
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))
...@@ -258,12 +267,16 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -258,12 +267,16 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin):
'portal_type': instance_tree.getPortalType(), 'portal_type': instance_tree.getPortalType(),
'reference': instance_tree.getReference(), 'reference': instance_tree.getReference(),
'title': instance_tree.getTitle(), 'title': instance_tree.getTitle(),
'monitor_url': 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Instance Tree" AND title:(Template Instance Tree)',
'instance': [ 'instance': [
{'created_at': self.created_at, {'created_at': self.created_at,
'no_data': 1, 'no_data': 1,
'portal_type': instance0.getPortalType(), 'portal_type': instance0.getPortalType(),
'reference': instance0.getReference(), 'reference': instance0.getReference(),
'since': self.created_at, 'since': self.created_at,
'monitor_url': 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Software Instance" AND reference:%s' % (
instance0.getReference()
),
'state': '', 'state': '',
'text': '#error no data found for %s' % instance0.getReference(), 'text': '#error no data found for %s' % instance0.getReference(),
'user': 'SlapOS Master'}, 'user': 'SlapOS Master'},
...@@ -272,6 +285,9 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -272,6 +285,9 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin):
'portal_type': instance.getPortalType(), 'portal_type': instance.getPortalType(),
'reference': instance.getReference(), 'reference': instance.getReference(),
'since': self.created_at, 'since': self.created_at,
'monitor_url': 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Software Instance" AND reference:%s' % (
instance.getReference()
),
'state': '', 'state': '',
'text': '#error no data found for %s' % instance.getReference(), 'text': '#error no data found for %s' % instance.getReference(),
'user': 'SlapOS Master'}]} 'user': 'SlapOS Master'}]}
...@@ -290,6 +306,9 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -290,6 +306,9 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin):
'no_data_since_5_minutes': 0, 'no_data_since_5_minutes': 0,
'portal_type': instance.getPortalType(), 'portal_type': instance.getPortalType(),
'reference': instance.getReference(), 'reference': instance.getReference(),
'monitor_url': 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Software Instance" AND reference:%s' % (
instance.getReference()
),
'since': self.created_at, 'since': self.created_at,
'state': 'start_requested', 'state': 'start_requested',
'text': '#access OK', 'text': '#access OK',
...@@ -310,6 +329,9 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -310,6 +329,9 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin):
'since': self.created_at, 'since': self.created_at,
'state': '', 'state': '',
'text': '#error no data found for %s' % instance.getReference(), 'text': '#error no data found for %s' % instance.getReference(),
'monitor_url': 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Software Instance" AND reference:%s' % (
instance.getReference()
),
'user': 'SlapOS Master'} 'user': 'SlapOS Master'}
self.assertEqual(_decode_with_json(news_dict), self.assertEqual(_decode_with_json(news_dict),
...@@ -323,6 +345,9 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -323,6 +345,9 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin):
'reference': instance.getReference(), 'reference': instance.getReference(),
'is_slave': 1, 'is_slave': 1,
'text': '#nodata is a slave %s' % instance.getReference(), 'text': '#nodata is a slave %s' % instance.getReference(),
'monitor_url': 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Software Instance" AND reference:%s' % (
instance.getReference()
),
'user': 'SlapOS Master'} 'user': 'SlapOS Master'}
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))
...@@ -336,6 +361,9 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -336,6 +361,9 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin):
"reference": instance.getReference(), "reference": instance.getReference(),
"user": "SlapOS Master", "user": "SlapOS Master",
"text": "#nodata is an stopped instance %s" % instance.getReference(), "text": "#nodata is an stopped instance %s" % instance.getReference(),
'monitor_url': 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Software Instance" AND reference:%s' % (
instance.getReference()
),
"is_stopped": 1 "is_stopped": 1
} }
self.assertEqual(_decode_with_json(news_dict), self.assertEqual(_decode_with_json(news_dict),
...@@ -350,6 +378,9 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -350,6 +378,9 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin):
"reference": instance.getReference(), "reference": instance.getReference(),
"user": "SlapOS Master", "user": "SlapOS Master",
"text": "#nodata is an destroyed instance %s" % instance.getReference(), "text": "#nodata is an destroyed instance %s" % instance.getReference(),
'monitor_url': 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Software Instance" AND reference:%s' % (
instance.getReference()
),
"is_destroyed": 1 "is_destroyed": 1
} }
self.assertEqual(_decode_with_json(news_dict), self.assertEqual(_decode_with_json(news_dict),
...@@ -424,7 +455,8 @@ class TestSoftwareInstallation_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -424,7 +455,8 @@ class TestSoftwareInstallation_getNewsDict(TestSlapOSHalJsonStyleMixin):
'since': self.created_at, 'since': self.created_at,
'state': '', 'state': '',
'text': '#error no data found for %s' % installation.getReference(), 'text': '#error no data found for %s' % installation.getReference(),
'user': 'SlapOS Master'} 'user': 'SlapOS Master'
}
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))
...@@ -435,6 +467,7 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -435,6 +467,7 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin):
compute_node = self._makeComputeNode() compute_node = self._makeComputeNode()
self._logFakeAccess(compute_node) self._logFakeAccess(compute_node)
news_dict = compute_node.ComputeNode_getNewsDict() news_dict = compute_node.ComputeNode_getNewsDict()
monitor_url = 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Software Instance" AND aggregate_reference:%s' % (compute_node.getReference())
expected_news_dict = {'compute_node': expected_news_dict = {'compute_node':
{'created_at': self.created_at, {'created_at': self.created_at,
'no_data_since_15_minutes': 0, 'no_data_since_15_minutes': 0,
...@@ -447,7 +480,8 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -447,7 +480,8 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin):
'user': 'SlapOS Master'}, 'user': 'SlapOS Master'},
'partition': {}, 'partition': {},
'portal_type': compute_node.getPortalType(), 'portal_type': compute_node.getPortalType(),
'reference': compute_node.getReference() 'reference': compute_node.getReference(),
'monitor_url': monitor_url
} }
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))
...@@ -458,6 +492,7 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -458,6 +492,7 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin):
state='stop_requested') state='stop_requested')
news_dict = compute_node.ComputeNode_getNewsDict() news_dict = compute_node.ComputeNode_getNewsDict()
compute_node.getSlapState = fakeStopRequestedSlapState compute_node.getSlapState = fakeStopRequestedSlapState
monitor_url = 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Software Instance" AND aggregate_reference:%s' % (compute_node.getReference())
expected_news_dict = {'compute_node': expected_news_dict = {'compute_node':
{'created_at': self.created_at, {'created_at': self.created_at,
...@@ -471,7 +506,8 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -471,7 +506,8 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin):
'user': 'SlapOS Master'}, 'user': 'SlapOS Master'},
'partition': {}, 'partition': {},
'portal_type': compute_node.getPortalType(), 'portal_type': compute_node.getPortalType(),
'reference': compute_node.getReference() 'reference': compute_node.getReference(),
'monitor_url': monitor_url
} }
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))
...@@ -482,6 +518,7 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -482,6 +518,7 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin):
state='destroy_requested') state='destroy_requested')
news_dict = compute_node.ComputeNode_getNewsDict() news_dict = compute_node.ComputeNode_getNewsDict()
compute_node.getSlapState = fakeDestroyRequestedSlapState compute_node.getSlapState = fakeDestroyRequestedSlapState
monitor_url = 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Software Instance" AND aggregate_reference:%s' % (compute_node.getReference())
expected_news_dict = {'compute_node': expected_news_dict = {'compute_node':
{'created_at': self.created_at, {'created_at': self.created_at,
...@@ -495,7 +532,8 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -495,7 +532,8 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin):
'user': 'SlapOS Master'}, 'user': 'SlapOS Master'},
'partition': {}, 'partition': {},
'portal_type': compute_node.getPortalType(), 'portal_type': compute_node.getPortalType(),
'reference': compute_node.getReference() 'reference': compute_node.getReference(),
'monitor_url': monitor_url
} }
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))
...@@ -503,6 +541,7 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -503,6 +541,7 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin):
def test_no_data(self): def test_no_data(self):
compute_node = self._makeComputeNode() compute_node = self._makeComputeNode()
news_dict = compute_node.ComputeNode_getNewsDict() news_dict = compute_node.ComputeNode_getNewsDict()
monitor_url = 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Software Instance" AND aggregate_reference:%s' % (compute_node.getReference())
expected_news_dict = {'compute_node': expected_news_dict = {'compute_node':
{'created_at': self.created_at, {'created_at': self.created_at,
'no_data': 1, 'no_data': 1,
...@@ -514,7 +553,8 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -514,7 +553,8 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin):
'user': 'SlapOS Master'}, 'user': 'SlapOS Master'},
'partition': {}, 'partition': {},
'portal_type': compute_node.getPortalType(), 'portal_type': compute_node.getPortalType(),
'reference': compute_node.getReference() 'reference': compute_node.getReference(),
'monitor_url': monitor_url
} }
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))
...@@ -523,6 +563,7 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -523,6 +563,7 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin):
compute_node = self._makeComputeNode() compute_node = self._makeComputeNode()
instance = self._makeInstance() instance = self._makeInstance()
instance.setAggregateValue(compute_node.slappart0) instance.setAggregateValue(compute_node.slappart0)
monitor_url = 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Software Instance" AND aggregate_reference:%s' % (compute_node.getReference())
self.tic() self.tic()
self._logFakeAccess(compute_node) self._logFakeAccess(compute_node)
...@@ -546,7 +587,8 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -546,7 +587,8 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin):
'text': '#error no data found for %s' % (instance.getReference()), 'text': '#error no data found for %s' % (instance.getReference()),
'user': 'SlapOS Master'}}, 'user': 'SlapOS Master'}},
'portal_type': compute_node.getPortalType(), 'portal_type': compute_node.getPortalType(),
'reference': compute_node.getReference() 'reference': compute_node.getReference(),
'monitor_url': monitor_url
} }
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))
...@@ -574,6 +616,11 @@ class TestComputerNetwork_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -574,6 +616,11 @@ class TestComputerNetwork_getNewsDict(TestSlapOSHalJsonStyleMixin):
u'state': u'start_requested', u'state': u'start_requested',
u'text': u'#access OK', u'text': u'#access OK',
u'user': u'SlapOS Master'}}, u'user': u'SlapOS Master'}},
'monitor_url': 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Software Instance" AND aggregate_reference:("%s")' % (
compute_node.getReference()
),
'portal_type': network.getPortalType(),
'reference': network.getReference(),
'partition': 'partition':
{ compute_node.getReference(): { compute_node.getReference():
{'slappart0': {'created_at': self.created_at, {'slappart0': {'created_at': self.created_at,
...@@ -595,7 +642,12 @@ class TestComputerNetwork_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -595,7 +642,12 @@ class TestComputerNetwork_getNewsDict(TestSlapOSHalJsonStyleMixin):
def test_no_data(self): def test_no_data(self):
network = self._makeComputerNetwork() network = self._makeComputerNetwork()
news_dict = network.ComputerNetwork_getNewsDict() news_dict = network.ComputerNetwork_getNewsDict()
expected_news_dict = {'compute_node': {}, 'partition': {}} expected_news_dict = {
'compute_node': {},
'partition': {},
'monitor_url': 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Software Instance" AND aggregate_reference:()',
'portal_type': network.getPortalType(),
'reference': network.getReference()}
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))
...@@ -613,7 +665,13 @@ class TestOrganisation_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -613,7 +665,13 @@ class TestOrganisation_getNewsDict(TestSlapOSHalJsonStyleMixin):
self.tic() self.tic()
self._logFakeAccess(compute_node) self._logFakeAccess(compute_node)
news_dict = organisation.Organisation_getNewsDict() news_dict = organisation.Organisation_getNewsDict()
expected_news_dict = {'compute_node': expected_news_dict = {
'monitor_url': 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Software Instance" AND aggregate_reference:("%s")' % (
compute_node.getReference()
),
'portal_type': 'Organisation',
'reference': organisation.getReference(),
'compute_node':
{ compute_node.getReference(): { compute_node.getReference():
{u'created_at': u'%s' % self.created_at, {u'created_at': u'%s' % self.created_at,
'no_data_since_15_minutes': 0, 'no_data_since_15_minutes': 0,
...@@ -645,7 +703,12 @@ class TestOrganisation_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -645,7 +703,12 @@ class TestOrganisation_getNewsDict(TestSlapOSHalJsonStyleMixin):
def test_no_data(self): def test_no_data(self):
organisation = self._makeOrganisation() organisation = self._makeOrganisation()
news_dict = organisation.Organisation_getNewsDict() news_dict = organisation.Organisation_getNewsDict()
expected_news_dict = {'compute_node': {}, 'partition': {}} expected_news_dict = {
'compute_node': {},
'partition': {},
'monitor_url': 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Software Instance" AND aggregate_reference:()',
'portal_type': 'Organisation',
'reference': organisation.getReference()}
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))
...@@ -663,7 +726,14 @@ class TestProject_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -663,7 +726,14 @@ class TestProject_getNewsDict(TestSlapOSHalJsonStyleMixin):
self.tic() self.tic()
self._logFakeAccess(compute_node) self._logFakeAccess(compute_node)
news_dict = project.Project_getNewsDict() news_dict = project.Project_getNewsDict()
expected_news_dict = {'compute_node': monitor_url = 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Software Instance" AND aggregate_reference:("%s")' % (
compute_node.getReference()
)
expected_news_dict = {
'monitor_url': monitor_url,
'portal_type': 'Project',
'reference': project.getReference(),
'compute_node':
{ compute_node.getReference(): { compute_node.getReference():
{u'created_at': u'%s' % self.created_at, {u'created_at': u'%s' % self.created_at,
'no_data_since_15_minutes': 0, 'no_data_since_15_minutes': 0,
...@@ -695,7 +765,13 @@ class TestProject_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -695,7 +765,13 @@ class TestProject_getNewsDict(TestSlapOSHalJsonStyleMixin):
def test_no_data(self): def test_no_data(self):
project = self._makeProject() project = self._makeProject()
news_dict = project.Project_getNewsDict() news_dict = project.Project_getNewsDict()
expected_news_dict = {'compute_node': {}, 'partition': {}} expected_news_dict = {
'compute_node': {},
'partition': {},
'monitor_url': 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Software Instance" AND aggregate_reference:()',
'portal_type': 'Project',
'reference': project.getReference()}
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))
......
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