Commit 3ed279c9 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Display allocation information for Software/Shared Instances

See merge request !524
parents 0cbc0062 53ae6991
...@@ -167,7 +167,8 @@ ...@@ -167,7 +167,8 @@
"Associated Tickets", "Associated Tickets",
"Instances", "Instances",
"Instance Tree:", "Instance Tree:",
"Software Logo" "Software Logo",
"Node"
]; ];
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
...@@ -199,6 +200,7 @@ ...@@ -199,6 +200,7 @@
['title', result[1][3]], ['title', result[1][3]],
['reference', result[1][4]], ['reference', result[1][4]],
['portal_type', result[1][5]], ['portal_type', result[1][5]],
['SoftwareInstance_getAllocationInformation', result[1][31]],
['SoftwareInstance_getReportedState', result[1][11]], ['SoftwareInstance_getReportedState', result[1][11]],
['SoftwareInstance_getNewsDict', result[1][1]] ['SoftwareInstance_getNewsDict', result[1][1]]
], ],
......
...@@ -110,7 +110,9 @@ ...@@ -110,7 +110,9 @@
"Parameter", "Parameter",
"Value", "Value",
"Status", "Status",
"Data updated." "Data updated.",
"Node",
"Partition"
]; ];
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
...@@ -213,6 +215,17 @@ ...@@ -213,6 +215,17 @@
"hidden": 0, "hidden": 0,
"type": "StringField" "type": "StringField"
}, },
"my_allocation_information": {
"description": "",
"title": result[2][12],
"default": gadget.state.doc.allocation_information,
"css_class": "",
"required": 1,
"editable": 0,
"key": "allocation_information",
"hidden": 0,
"type": "StringField"
},
"my_text_content": { "my_text_content": {
"description": "", "description": "",
"title": result[2][6], "title": result[2][6],
...@@ -259,7 +272,7 @@ ...@@ -259,7 +272,7 @@
[["my_title"], ["my_reference"], ['my_monitoring_status']] [["my_title"], ["my_reference"], ['my_monitoring_status']]
], [ ], [
"right", "right",
[["my_specialise_title"], ["my_source_reference"]] [["my_specialise_title"], ["my_source_reference"], ["my_allocation_information"]]
], [ ], [
"center", "center",
[["my_url_string"], ["my_text_content"]] [["my_url_string"], ["my_text_content"]]
......
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1000.58063.29277.1706</string> </value> <value> <string>1008.13874.12169.28194</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>1655115820.43</float> <float>1684250249.63</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
if context.getAggregate() is None:
return context.Base_translateString("Not allocated")
partition = context.getAggregateValue(checked_permission="View")
if partition is not None:
return "%s (%s)" % (
partition.getParentValue().getReference(),
partition.getReference())
return context.Base_translateString("Restricted information")
<?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>**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SoftwareInstance_getAllocationInformation</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -107,6 +107,7 @@ ...@@ -107,6 +107,7 @@
<string>my_specialise_title</string> <string>my_specialise_title</string>
<string>my_news</string> <string>my_news</string>
<string>my_connection_parameter_list</string> <string>my_connection_parameter_list</string>
<string>my_allocation_information</string>
</list> </list>
</value> </value>
</item> </item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>default</string>
<string>editable</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_allocation_information</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_string_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value>
<list>
<tuple>
<string>Compute Partition</string>
<string>Compute Partition</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Allocation Information</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>here/SoftwareInstance_getAllocationInformation</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -100,20 +100,23 @@ class TestSlapOSHalJsonStyleMixin(SlapOSTestCaseMixinWithAbort): ...@@ -100,20 +100,23 @@ class TestSlapOSHalJsonStyleMixin(SlapOSTestCaseMixinWithAbort):
return instance return instance
def _makeComputeNode(self, owner=None, allocation_scope='open/public'): def _makeComputeNode(self, owner=None, allocation_scope='open/public'):
compute_node = self.portal.compute_node_module\ _, partition0 =SlapOSTestCaseMixinWithAbort._makeComputeNode(
.template_compute_node.Base_createCloneDocument(batch_mode=1) self, owner=owner, allocation_scope=allocation_scope
compute_node.edit(reference="TESTCOMP-%s" % compute_node.getId()) )
compute_node.validate()
self.partition0 = partition0
reference = 'TESTPART-%s' % self.generateNewId()
self.partition1 = self.compute_node.newContent(
portal_type="Compute Partition",
title="slappart1", reference=reference, id="slappart1")
compute_node.newContent(portal_type="Compute Partition", self.partition1.markFree()
title="slappart0", id="slappart0") self.partition1.validate()
compute_node.newContent(portal_type="Compute Partition",
title="slappart1", id="slappart1")
self.tic() self.tic()
self.changeSkin('Hal') self.changeSkin('Hal')
return compute_node return self.compute_node
def _makeComputerNetwork(self): def _makeComputerNetwork(self):
network = self.portal.computer_network_module.newContent() network = self.portal.computer_network_module.newContent()
network.edit(reference="TESTNET-%s" % network.getId()) network.edit(reference="TESTNET-%s" % network.getId())
...@@ -562,7 +565,7 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -562,7 +565,7 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin):
def test_with_instance(self): def test_with_instance(self):
compute_node = self._makeComputeNode() compute_node = self._makeComputeNode()
instance = self._makeInstance() instance = self._makeInstance()
instance.setAggregateValue(compute_node.slappart0) instance.setAggregateValue(self.partition0)
monitor_url = 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Software Instance" AND aggregate_reference:%s' % (compute_node.getReference()) 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()
...@@ -578,7 +581,7 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -578,7 +581,7 @@ class TestComputeNode_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'},
'partition': {'slappart0': {'created_at': self.created_at, 'partition': {self.partition0.getReference(): {'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(),
...@@ -599,7 +602,7 @@ class TestComputerNetwork_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -599,7 +602,7 @@ class TestComputerNetwork_getNewsDict(TestSlapOSHalJsonStyleMixin):
network = self._makeComputerNetwork() network = self._makeComputerNetwork()
compute_node = self._makeComputeNode() compute_node = self._makeComputeNode()
instance = self._makeInstance() instance = self._makeInstance()
instance.setAggregateValue(compute_node.slappart0) instance.setAggregateValue(self.partition0)
compute_node.setSubordinationValue(network) compute_node.setSubordinationValue(network)
self.tic() self.tic()
...@@ -623,7 +626,7 @@ class TestComputerNetwork_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -623,7 +626,7 @@ class TestComputerNetwork_getNewsDict(TestSlapOSHalJsonStyleMixin):
'reference': network.getReference(), 'reference': network.getReference(),
'partition': 'partition':
{ compute_node.getReference(): { compute_node.getReference():
{'slappart0': {'created_at': self.created_at, {self.partition0.getReference(): {'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(),
...@@ -659,7 +662,7 @@ class TestOrganisation_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -659,7 +662,7 @@ class TestOrganisation_getNewsDict(TestSlapOSHalJsonStyleMixin):
organisation = self._makeOrganisation() organisation = self._makeOrganisation()
compute_node = self._makeComputeNode() compute_node = self._makeComputeNode()
instance = self._makeInstance() instance = self._makeInstance()
instance.setAggregateValue(compute_node.slappart0) instance.setAggregateValue(self.partition0)
organisation.fake_compute_node_list = [compute_node] organisation.fake_compute_node_list = [compute_node]
self.tic() self.tic()
...@@ -684,7 +687,7 @@ class TestOrganisation_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -684,7 +687,7 @@ class TestOrganisation_getNewsDict(TestSlapOSHalJsonStyleMixin):
u'user': u'SlapOS Master'}}, u'user': u'SlapOS Master'}},
'partition': 'partition':
{ compute_node.getReference(): { compute_node.getReference():
{'slappart0': {'created_at': self.created_at, {self.partition0.getReference(): {'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(),
...@@ -720,7 +723,7 @@ class TestProject_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -720,7 +723,7 @@ class TestProject_getNewsDict(TestSlapOSHalJsonStyleMixin):
project = self._makeProject() project = self._makeProject()
compute_node = self._makeComputeNode() compute_node = self._makeComputeNode()
instance = self._makeInstance() instance = self._makeInstance()
instance.setAggregateValue(compute_node.slappart0) instance.setAggregateValue(self.partition0)
project.fake_compute_node_list = [compute_node] project.fake_compute_node_list = [compute_node]
self.tic() self.tic()
...@@ -746,7 +749,7 @@ class TestProject_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -746,7 +749,7 @@ class TestProject_getNewsDict(TestSlapOSHalJsonStyleMixin):
u'user': u'SlapOS Master'}}, u'user': u'SlapOS Master'}},
'partition': 'partition':
{ compute_node.getReference(): { compute_node.getReference():
{'slappart0': {'created_at': self.created_at, {self.partition0.getReference(): {'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(),
...@@ -1797,6 +1800,45 @@ return []""") ...@@ -1797,6 +1800,45 @@ return []""")
self.portal.SoftwareProduct_getSoftwareReleaseAsHateoas("fake", True)) self.portal.SoftwareProduct_getSoftwareReleaseAsHateoas("fake", True))
) )
class TestSoftwareInstance_getAllocationInformation(TestSlapOSHalJsonStyleMixin):
def test_SoftwareInstance_getAllocationInformation_not_allocated(self):
self._makeTree()
self.changeSkin('RJS')
self.login(self.person_user.getUserId())
self.assertEqual("Not allocated",
self.software_instance.SoftwareInstance_getAllocationInformation())
def test_SoftwareInstance_getAllocationInformation(self):
computer_owner = self._makePerson(user=1)
self._makeComputeNode(owner=computer_owner)
self._makeComplexComputeNode(person=computer_owner)
started_instance = self.compute_node.partition1.getAggregateRelatedValue(
portal_type='Software Instance')
self.changeSkin('RJS')
self.login(computer_owner.getUserId())
self.assertEqual("%s (partition1)" % self.compute_node.getReference(),
started_instance.SoftwareInstance_getAllocationInformation())
def test_SoftwareInstance_getAllocationInformation_restricted_information(self):
computer_owner = self._makePerson(user=1)
self._makeComputeNode(owner=computer_owner)
requester = self._makePerson(user=1)
self._makeComplexComputeNode(person=requester)
started_instance = self.compute_node.partition1.getAggregateRelatedValue(
portal_type='Software Instance')
# ensure it dont have good admin assignment
for assignment in requester.contentValues(portal_type="Assignment"):
assignment.setGroup(None)
assignment.setRole("member")
self.tic()
self.changeSkin('RJS')
self.login(requester.getUserId())
self.assertEqual("Restricted information",
started_instance.SoftwareInstance_getAllocationInformation())
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