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

slapos_jio: Display allocation information for Software/Shared Instances

See merge request nexedi/slapos.core!524
parents 0cbc0062 53ae6991
Pipeline #28281 failed with stage
in 0 seconds
......@@ -167,7 +167,8 @@
"Associated Tickets",
"Instances",
"Instance Tree:",
"Software Logo"
"Software Logo",
"Node"
];
return new RSVP.Queue()
.push(function () {
......@@ -199,6 +200,7 @@
['title', result[1][3]],
['reference', result[1][4]],
['portal_type', result[1][5]],
['SoftwareInstance_getAllocationInformation', result[1][31]],
['SoftwareInstance_getReportedState', result[1][11]],
['SoftwareInstance_getNewsDict', result[1][1]]
],
......
......@@ -110,7 +110,9 @@
"Parameter",
"Value",
"Status",
"Data updated."
"Data updated.",
"Node",
"Partition"
];
return new RSVP.Queue()
.push(function () {
......@@ -213,6 +215,17 @@
"hidden": 0,
"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": {
"description": "",
"title": result[2][6],
......@@ -259,7 +272,7 @@
[["my_title"], ["my_reference"], ['my_monitoring_status']]
], [
"right",
[["my_specialise_title"], ["my_source_reference"]]
[["my_specialise_title"], ["my_source_reference"], ["my_allocation_information"]]
], [
"center",
[["my_url_string"], ["my_text_content"]]
......
......@@ -238,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1000.58063.29277.1706</string> </value>
<value> <string>1008.13874.12169.28194</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -258,7 +258,7 @@
</tuple>
<state>
<tuple>
<float>1655115820.43</float>
<float>1684250249.63</float>
<string>UTC</string>
</tuple>
</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 @@
<string>my_specialise_title</string>
<string>my_news</string>
<string>my_connection_parameter_list</string>
<string>my_allocation_information</string>
</list>
</value>
</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):
return instance
def _makeComputeNode(self, owner=None, allocation_scope='open/public'):
compute_node = self.portal.compute_node_module\
.template_compute_node.Base_createCloneDocument(batch_mode=1)
compute_node.edit(reference="TESTCOMP-%s" % compute_node.getId())
compute_node.validate()
_, partition0 =SlapOSTestCaseMixinWithAbort._makeComputeNode(
self, owner=owner, allocation_scope=allocation_scope
)
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",
title="slappart0", id="slappart0")
compute_node.newContent(portal_type="Compute Partition",
title="slappart1", id="slappart1")
self.partition1.markFree()
self.partition1.validate()
self.tic()
self.changeSkin('Hal')
return compute_node
return self.compute_node
def _makeComputerNetwork(self):
network = self.portal.computer_network_module.newContent()
network.edit(reference="TESTNET-%s" % network.getId())
......@@ -562,7 +565,7 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin):
def test_with_instance(self):
compute_node = self._makeComputeNode()
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())
self.tic()
......@@ -578,7 +581,7 @@ class TestComputeNode_getNewsDict(TestSlapOSHalJsonStyleMixin):
u'state': u'start_requested',
u'text': u'#access OK',
u'user': u'SlapOS Master'},
'partition': {'slappart0': {'created_at': self.created_at,
'partition': {self.partition0.getReference(): {'created_at': self.created_at,
'no_data': 1,
'portal_type': instance.getPortalType(),
'reference': instance.getReference(),
......@@ -599,7 +602,7 @@ class TestComputerNetwork_getNewsDict(TestSlapOSHalJsonStyleMixin):
network = self._makeComputerNetwork()
compute_node = self._makeComputeNode()
instance = self._makeInstance()
instance.setAggregateValue(compute_node.slappart0)
instance.setAggregateValue(self.partition0)
compute_node.setSubordinationValue(network)
self.tic()
......@@ -623,7 +626,7 @@ class TestComputerNetwork_getNewsDict(TestSlapOSHalJsonStyleMixin):
'reference': network.getReference(),
'partition':
{ compute_node.getReference():
{'slappart0': {'created_at': self.created_at,
{self.partition0.getReference(): {'created_at': self.created_at,
'no_data': 1,
'portal_type': instance.getPortalType(),
'reference': instance.getReference(),
......@@ -659,7 +662,7 @@ class TestOrganisation_getNewsDict(TestSlapOSHalJsonStyleMixin):
organisation = self._makeOrganisation()
compute_node = self._makeComputeNode()
instance = self._makeInstance()
instance.setAggregateValue(compute_node.slappart0)
instance.setAggregateValue(self.partition0)
organisation.fake_compute_node_list = [compute_node]
self.tic()
......@@ -684,7 +687,7 @@ class TestOrganisation_getNewsDict(TestSlapOSHalJsonStyleMixin):
u'user': u'SlapOS Master'}},
'partition':
{ compute_node.getReference():
{'slappart0': {'created_at': self.created_at,
{self.partition0.getReference(): {'created_at': self.created_at,
'no_data': 1,
'portal_type': instance.getPortalType(),
'reference': instance.getReference(),
......@@ -720,7 +723,7 @@ class TestProject_getNewsDict(TestSlapOSHalJsonStyleMixin):
project = self._makeProject()
compute_node = self._makeComputeNode()
instance = self._makeInstance()
instance.setAggregateValue(compute_node.slappart0)
instance.setAggregateValue(self.partition0)
project.fake_compute_node_list = [compute_node]
self.tic()
......@@ -746,7 +749,7 @@ class TestProject_getNewsDict(TestSlapOSHalJsonStyleMixin):
u'user': u'SlapOS Master'}},
'partition':
{ compute_node.getReference():
{'slappart0': {'created_at': self.created_at,
{self.partition0.getReference(): {'created_at': self.created_at,
'no_data': 1,
'portal_type': instance.getPortalType(),
'reference': instance.getReference(),
......@@ -1797,6 +1800,45 @@ return []""")
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