Commit 984b64c9 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud: Add reference and portal_type on access status

   The access status is now widely used and often fetch in bulk (list of software instances of a computer). Include reference and portal_type gives a hind of which object the message is from, which helps on gadgets and APIs (by reducing the number of fetches for example).
parent 62d6f6cf
......@@ -78,7 +78,9 @@ class SlapOSCacheMixin:
'since': '%s' % last_modified,
'state': "",
"text": "#error no data found for %s" % self.getReference(),
"no_data": 1
"no_data": 1,
'reference': self.getReference(),
'portal_type': self.getPortalType()
}
# Prepare for xml marshalling
#data_dict["text"] = data_dict["text"].decode("UTF-8")
......@@ -128,7 +130,9 @@ class SlapOSCacheMixin:
'created_at': '%s' % created_at,
'text': '%s' % text,
'since': '%s' % since,
'state': state
'state': state,
'reference': self.getReference(),
'portal_type': self.getPortalType()
})
cache_duration = self._getAccessStatusCacheFactory().cache_duration
......
......@@ -6,12 +6,6 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>SlapOSCacheMixin</string> </value>
......@@ -61,28 +55,13 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
......@@ -95,7 +74,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -104,7 +83,7 @@
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
......
......@@ -11,7 +11,9 @@ def get_compute_partition_dict(reference):
compute_partition_dict[compute_partition.getTitle()] = software_instance.getAccessStatus()
return {"compute_node": compute_node_dict,
"partition": compute_partition_dict}
"partition": compute_partition_dict,
"portal_type": compute_node_dict['portal_type'],
"reference": compute_node_dict['reference']}
# Use Cache here, at least transactional one.
return get_compute_partition_dict(context.getReference())
news_dict = {"instance" : []}
news_dict = {
"portal_type": context.getPortalType(),
"reference": context.getReference(),
"title": context.getTitle(),
"instance" : []}
if context.getSlapState() == 'stop_requested':
news_dict["is_stopped"] = 1
......
......@@ -651,6 +651,10 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
<string>%(created_at)s</string>
<string>no_data</string>
<int>1</int>
<string>portal_type</string>
<string>Compute Node</string>
<string>reference</string>
<string>%(compute_node_id)s</string>
<string>since</string>
<string>%(since)s</string>
<string>state</string>
......@@ -703,6 +707,10 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
<int>0</int>
<string>no_data_since_5_minutes</string>
<int>0</int>
<string>portal_type</string>
<string>Compute Node</string>
<string>reference</string>
<string>%(compute_node_id)s</string>
<string>since</string>
<string>%(since)s</string>
<string>state</string>
......@@ -815,6 +823,10 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
<string>%(created_at)s</string>
<string>no_data</string>
<int>1</int>
<string>portal_type</string>
<string>Software Installation</string>
<string>reference</string>
<string>%(reference)s</string>
<string>since</string>
<string>%(since)s</string>
<string>state</string>
......@@ -887,6 +899,10 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
<int>0</int>
<string>no_data_since_5_minutes</string>
<int>0</int>
<string>portal_type</string>
<string>Software Installation</string>
<string>reference</string>
<string>%(reference)s</string>
<string>since</string>
<string>%(since)s</string>
<string>state</string>
......@@ -902,6 +918,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
since=since,
url_string=url_string,
compute_node_id=self.compute_node_id,
reference=software_installation.getReference()
)
self.assertEqual(expected_xml, got_xml,
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
......@@ -936,6 +953,10 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
<int>0</int>
<string>no_data_since_5_minutes</string>
<int>0</int>
<string>portal_type</string>
<string>Software Installation</string>
<string>reference</string>
<string>%(reference)s</string>
<string>since</string>
<string>%(since)s</string>
<string>state</string>
......@@ -951,6 +972,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
since=since,
url_string=url_string,
compute_node_id=self.compute_node_id,
reference=software_installation.getReference()
)
self.assertEqual(expected_xml, got_xml,
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
......@@ -985,6 +1007,10 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
<int>0</int>
<string>no_data_since_5_minutes</string>
<int>0</int>
<string>portal_type</string>
<string>Software Installation</string>
<string>reference</string>
<string>%(reference)s</string>
<string>since</string>
<string>%(since)s</string>
<string>state</string>
......@@ -1000,6 +1026,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
since=since,
url_string=url_string,
compute_node_id=self.compute_node_id,
reference=software_installation.getReference()
)
self.assertEqual(expected_xml, got_xml,
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
......@@ -1324,6 +1351,10 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<string>%(created_at)s</string>
<string>no_data</string>
<int>1</int>
<string>portal_type</string>
<string>Software Instance</string>
<string>reference</string>
<string>%(instance_guid)s</string>
<string>since</string>
<string>%(since)s</string>
<string>state</string>
......@@ -1375,6 +1406,10 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<string>%(created_at)s</string>
<string>no_data</string>
<int>1</int>
<string>portal_type</string>
<string>Software Instance</string>
<string>reference</string>
<string>%(instance_guid)s</string>
<string>since</string>
<string>%(since)s</string>
<string>state</string>
......@@ -1749,6 +1784,10 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<int>0</int>
<string>no_data_since_5_minutes</string>
<int>0</int>
<string>portal_type</string>
<string>Software Instance</string>
<string>reference</string>
<string>%(instance_guid)s</string>
<string>since</string>
<string>%(since)s</string>
<string>state</string>
......@@ -1797,6 +1836,10 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<int>0</int>
<string>no_data_since_5_minutes</string>
<int>0</int>
<string>portal_type</string>
<string>Software Instance</string>
<string>reference</string>
<string>%(instance_guid)s</string>
<string>since</string>
<string>%(since)s</string>
<string>state</string>
......@@ -1847,6 +1890,10 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<int>0</int>
<string>no_data_since_5_minutes</string>
<int>0</int>
<string>portal_type</string>
<string>Software Instance</string>
<string>reference</string>
<string>%(instance_guid)s</string>
<string>since</string>
<string>%(since)s</string>
<string>state</string>
......@@ -1907,6 +1954,10 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<int>0</int>
<string>no_data_since_5_minutes</string>
<int>0</int>
<string>portal_type</string>
<string>Software Instance</string>
<string>reference</string>
<string>%(instance_guid)s</string>
<string>since</string>
<string>%(since)s</string>
<string>state</string>
......@@ -2227,6 +2278,10 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<int>0</int>
<string>no_data_since_5_minutes</string>
<int>0</int>
<string>portal_type</string>
<string>Software Instance</string>
<string>reference</string>
<string>%(instance_guid)s</string>
<string>since</string>
<string>%(since)s</string>
<string>state</string>
......@@ -2274,6 +2329,10 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<int>0</int>
<string>no_data_since_5_minutes</string>
<int>0</int>
<string>portal_type</string>
<string>Software Instance</string>
<string>reference</string>
<string>%(instance_guid)s</string>
<string>since</string>
<string>%(since)s</string>
<string>state</string>
......@@ -2520,6 +2579,10 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
<string>%(created_at)s</string>
<string>no_data</string>
<int>1</int>
<string>portal_type</string>
<string>Compute Node</string>
<string>reference</string>
<string>%(compute_node_id)s</string>
<string>since</string>
<string>%(since)s</string>
<string>state</string>
......@@ -2572,6 +2635,10 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
<int>0</int>
<string>no_data_since_5_minutes</string>
<int>0</int>
<string>portal_type</string>
<string>Compute Node</string>
<string>reference</string>
<string>%(compute_node_id)s</string>
<string>since</string>
<string>%(since)s</string>
<string>state</string>
......@@ -2649,6 +2716,10 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
<string>%(created_at)s</string>
<string>no_data</string>
<int>1</int>
<string>portal_type</string>
<string>Software Instance</string>
<string>reference</string>
<string>%(instance_guid)s</string>
<string>since</string>
<string>%(since)s</string>
<string>state</string>
......@@ -2702,6 +2773,10 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
<string>%(created_at)s</string>
<string>no_data</string>
<int>1</int>
<string>portal_type</string>
<string>Software Instance</string>
<string>reference</string>
<string>%(instance_guid)s</string>
<string>since</string>
<string>%(since)s</string>
<string>state</string>
......@@ -3013,6 +3088,10 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
<int>0</int>
<string>no_data_since_5_minutes</string>
<int>0</int>
<string>portal_type</string>
<string>Software Instance</string>
<string>reference</string>
<string>%(instance_guid)s</string>
<string>since</string>
<string>%(since)s</string>
<string>state</string>
......@@ -3027,6 +3106,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
created_at=created_at,
since=since,
person_reference=self.person_reference,
instance_guid=self.start_requested_software_instance.getReference()
)
self.assertEqual(expected_xml, got_xml,
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
......
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