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: ...@@ -78,7 +78,9 @@ class SlapOSCacheMixin:
'since': '%s' % last_modified, 'since': '%s' % last_modified,
'state': "", 'state': "",
"text": "#error no data found for %s" % self.getReference(), "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 # Prepare for xml marshalling
#data_dict["text"] = data_dict["text"].decode("UTF-8") #data_dict["text"] = data_dict["text"].decode("UTF-8")
...@@ -128,7 +130,9 @@ class SlapOSCacheMixin: ...@@ -128,7 +130,9 @@ class SlapOSCacheMixin:
'created_at': '%s' % created_at, 'created_at': '%s' % created_at,
'text': '%s' % text, 'text': '%s' % text,
'since': '%s' % since, 'since': '%s' % since,
'state': state 'state': state,
'reference': self.getReference(),
'portal_type': self.getPortalType()
}) })
cache_duration = self._getAccessStatusCacheFactory().cache_duration cache_duration = self._getAccessStatusCacheFactory().cache_duration
......
...@@ -6,12 +6,6 @@ ...@@ -6,12 +6,6 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>SlapOSCacheMixin</string> </value> <value> <string>SlapOSCacheMixin</string> </value>
...@@ -61,28 +55,13 @@ ...@@ -61,28 +55,13 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <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> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -95,7 +74,7 @@ ...@@ -95,7 +74,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -104,7 +83,7 @@ ...@@ -104,7 +83,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
......
...@@ -11,7 +11,9 @@ def get_compute_partition_dict(reference): ...@@ -11,7 +11,9 @@ def get_compute_partition_dict(reference):
compute_partition_dict[compute_partition.getTitle()] = software_instance.getAccessStatus() compute_partition_dict[compute_partition.getTitle()] = software_instance.getAccessStatus()
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'],
"reference": compute_node_dict['reference']}
# 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())
news_dict = {"instance" : []} news_dict = {"instance" : []}
news_dict = {
"portal_type": context.getPortalType(),
"reference": context.getReference(),
"title": context.getTitle(),
"instance" : []}
if context.getSlapState() == 'stop_requested': if context.getSlapState() == 'stop_requested':
news_dict["is_stopped"] = 1 news_dict["is_stopped"] = 1
......
...@@ -651,6 +651,10 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin): ...@@ -651,6 +651,10 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
<string>%(created_at)s</string> <string>%(created_at)s</string>
<string>no_data</string> <string>no_data</string>
<int>1</int> <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</string>
<string>%(since)s</string> <string>%(since)s</string>
<string>state</string> <string>state</string>
...@@ -703,6 +707,10 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin): ...@@ -703,6 +707,10 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
<int>0</int> <int>0</int>
<string>no_data_since_5_minutes</string> <string>no_data_since_5_minutes</string>
<int>0</int> <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</string>
<string>%(since)s</string> <string>%(since)s</string>
<string>state</string> <string>state</string>
...@@ -815,6 +823,10 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin): ...@@ -815,6 +823,10 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
<string>%(created_at)s</string> <string>%(created_at)s</string>
<string>no_data</string> <string>no_data</string>
<int>1</int> <int>1</int>
<string>portal_type</string>
<string>Software Installation</string>
<string>reference</string>
<string>%(reference)s</string>
<string>since</string> <string>since</string>
<string>%(since)s</string> <string>%(since)s</string>
<string>state</string> <string>state</string>
...@@ -887,6 +899,10 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin): ...@@ -887,6 +899,10 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
<int>0</int> <int>0</int>
<string>no_data_since_5_minutes</string> <string>no_data_since_5_minutes</string>
<int>0</int> <int>0</int>
<string>portal_type</string>
<string>Software Installation</string>
<string>reference</string>
<string>%(reference)s</string>
<string>since</string> <string>since</string>
<string>%(since)s</string> <string>%(since)s</string>
<string>state</string> <string>state</string>
...@@ -902,6 +918,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin): ...@@ -902,6 +918,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
since=since, since=since,
url_string=url_string, url_string=url_string,
compute_node_id=self.compute_node_id, compute_node_id=self.compute_node_id,
reference=software_installation.getReference()
) )
self.assertEqual(expected_xml, got_xml, self.assertEqual(expected_xml, got_xml,
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))])) '\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
...@@ -936,6 +953,10 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin): ...@@ -936,6 +953,10 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
<int>0</int> <int>0</int>
<string>no_data_since_5_minutes</string> <string>no_data_since_5_minutes</string>
<int>0</int> <int>0</int>
<string>portal_type</string>
<string>Software Installation</string>
<string>reference</string>
<string>%(reference)s</string>
<string>since</string> <string>since</string>
<string>%(since)s</string> <string>%(since)s</string>
<string>state</string> <string>state</string>
...@@ -951,6 +972,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin): ...@@ -951,6 +972,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
since=since, since=since,
url_string=url_string, url_string=url_string,
compute_node_id=self.compute_node_id, compute_node_id=self.compute_node_id,
reference=software_installation.getReference()
) )
self.assertEqual(expected_xml, got_xml, self.assertEqual(expected_xml, got_xml,
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))])) '\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
...@@ -985,6 +1007,10 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin): ...@@ -985,6 +1007,10 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
<int>0</int> <int>0</int>
<string>no_data_since_5_minutes</string> <string>no_data_since_5_minutes</string>
<int>0</int> <int>0</int>
<string>portal_type</string>
<string>Software Installation</string>
<string>reference</string>
<string>%(reference)s</string>
<string>since</string> <string>since</string>
<string>%(since)s</string> <string>%(since)s</string>
<string>state</string> <string>state</string>
...@@ -1000,6 +1026,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin): ...@@ -1000,6 +1026,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
since=since, since=since,
url_string=url_string, url_string=url_string,
compute_node_id=self.compute_node_id, compute_node_id=self.compute_node_id,
reference=software_installation.getReference()
) )
self.assertEqual(expected_xml, got_xml, self.assertEqual(expected_xml, got_xml,
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))])) '\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
...@@ -1324,6 +1351,10 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1324,6 +1351,10 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<string>%(created_at)s</string> <string>%(created_at)s</string>
<string>no_data</string> <string>no_data</string>
<int>1</int> <int>1</int>
<string>portal_type</string>
<string>Software Instance</string>
<string>reference</string>
<string>%(instance_guid)s</string>
<string>since</string> <string>since</string>
<string>%(since)s</string> <string>%(since)s</string>
<string>state</string> <string>state</string>
...@@ -1375,6 +1406,10 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1375,6 +1406,10 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<string>%(created_at)s</string> <string>%(created_at)s</string>
<string>no_data</string> <string>no_data</string>
<int>1</int> <int>1</int>
<string>portal_type</string>
<string>Software Instance</string>
<string>reference</string>
<string>%(instance_guid)s</string>
<string>since</string> <string>since</string>
<string>%(since)s</string> <string>%(since)s</string>
<string>state</string> <string>state</string>
...@@ -1749,6 +1784,10 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1749,6 +1784,10 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<int>0</int> <int>0</int>
<string>no_data_since_5_minutes</string> <string>no_data_since_5_minutes</string>
<int>0</int> <int>0</int>
<string>portal_type</string>
<string>Software Instance</string>
<string>reference</string>
<string>%(instance_guid)s</string>
<string>since</string> <string>since</string>
<string>%(since)s</string> <string>%(since)s</string>
<string>state</string> <string>state</string>
...@@ -1797,6 +1836,10 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1797,6 +1836,10 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<int>0</int> <int>0</int>
<string>no_data_since_5_minutes</string> <string>no_data_since_5_minutes</string>
<int>0</int> <int>0</int>
<string>portal_type</string>
<string>Software Instance</string>
<string>reference</string>
<string>%(instance_guid)s</string>
<string>since</string> <string>since</string>
<string>%(since)s</string> <string>%(since)s</string>
<string>state</string> <string>state</string>
...@@ -1847,6 +1890,10 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1847,6 +1890,10 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<int>0</int> <int>0</int>
<string>no_data_since_5_minutes</string> <string>no_data_since_5_minutes</string>
<int>0</int> <int>0</int>
<string>portal_type</string>
<string>Software Instance</string>
<string>reference</string>
<string>%(instance_guid)s</string>
<string>since</string> <string>since</string>
<string>%(since)s</string> <string>%(since)s</string>
<string>state</string> <string>state</string>
...@@ -1907,6 +1954,10 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1907,6 +1954,10 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<int>0</int> <int>0</int>
<string>no_data_since_5_minutes</string> <string>no_data_since_5_minutes</string>
<int>0</int> <int>0</int>
<string>portal_type</string>
<string>Software Instance</string>
<string>reference</string>
<string>%(instance_guid)s</string>
<string>since</string> <string>since</string>
<string>%(since)s</string> <string>%(since)s</string>
<string>state</string> <string>state</string>
...@@ -2227,6 +2278,10 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -2227,6 +2278,10 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<int>0</int> <int>0</int>
<string>no_data_since_5_minutes</string> <string>no_data_since_5_minutes</string>
<int>0</int> <int>0</int>
<string>portal_type</string>
<string>Software Instance</string>
<string>reference</string>
<string>%(instance_guid)s</string>
<string>since</string> <string>since</string>
<string>%(since)s</string> <string>%(since)s</string>
<string>state</string> <string>state</string>
...@@ -2274,6 +2329,10 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -2274,6 +2329,10 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<int>0</int> <int>0</int>
<string>no_data_since_5_minutes</string> <string>no_data_since_5_minutes</string>
<int>0</int> <int>0</int>
<string>portal_type</string>
<string>Software Instance</string>
<string>reference</string>
<string>%(instance_guid)s</string>
<string>since</string> <string>since</string>
<string>%(since)s</string> <string>%(since)s</string>
<string>state</string> <string>state</string>
...@@ -2520,6 +2579,10 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2520,6 +2579,10 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
<string>%(created_at)s</string> <string>%(created_at)s</string>
<string>no_data</string> <string>no_data</string>
<int>1</int> <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</string>
<string>%(since)s</string> <string>%(since)s</string>
<string>state</string> <string>state</string>
...@@ -2572,6 +2635,10 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2572,6 +2635,10 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
<int>0</int> <int>0</int>
<string>no_data_since_5_minutes</string> <string>no_data_since_5_minutes</string>
<int>0</int> <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</string>
<string>%(since)s</string> <string>%(since)s</string>
<string>state</string> <string>state</string>
...@@ -2649,6 +2716,10 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2649,6 +2716,10 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
<string>%(created_at)s</string> <string>%(created_at)s</string>
<string>no_data</string> <string>no_data</string>
<int>1</int> <int>1</int>
<string>portal_type</string>
<string>Software Instance</string>
<string>reference</string>
<string>%(instance_guid)s</string>
<string>since</string> <string>since</string>
<string>%(since)s</string> <string>%(since)s</string>
<string>state</string> <string>state</string>
...@@ -2702,6 +2773,10 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2702,6 +2773,10 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
<string>%(created_at)s</string> <string>%(created_at)s</string>
<string>no_data</string> <string>no_data</string>
<int>1</int> <int>1</int>
<string>portal_type</string>
<string>Software Instance</string>
<string>reference</string>
<string>%(instance_guid)s</string>
<string>since</string> <string>since</string>
<string>%(since)s</string> <string>%(since)s</string>
<string>state</string> <string>state</string>
...@@ -3013,6 +3088,10 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -3013,6 +3088,10 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
<int>0</int> <int>0</int>
<string>no_data_since_5_minutes</string> <string>no_data_since_5_minutes</string>
<int>0</int> <int>0</int>
<string>portal_type</string>
<string>Software Instance</string>
<string>reference</string>
<string>%(instance_guid)s</string>
<string>since</string> <string>since</string>
<string>%(since)s</string> <string>%(since)s</string>
<string>state</string> <string>state</string>
...@@ -3027,6 +3106,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -3027,6 +3106,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
created_at=created_at, created_at=created_at,
since=since, since=since,
person_reference=self.person_reference, person_reference=self.person_reference,
instance_guid=self.start_requested_software_instance.getReference()
) )
self.assertEqual(expected_xml, got_xml, self.assertEqual(expected_xml, got_xml,
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))])) '\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