Commit 1bccd5f6 authored by Romain Courteaud's avatar Romain Courteaud

slapos_slap_tool:

* project reference is required for compute node
* require a project when requesting an instance tree
* Remote Node has no user_id
* _makeComplexComputeNode need a project
* product/release
* Release
* test
* no source administration on compute node
* project on compute node
* fix person assignment
* proj reference
* test
* project reference
* getSoftwareReleaseListFromSoftwareProduct is related to a project
* getSoftwareReleaseListFromSoftwareProduct requires a project reference
* release are not published anymore
* test: bypass subscription request
* drop template_compute_node
parent 72f74d01
...@@ -16,7 +16,9 @@ def getComputeNodeReferenceAndUserId(item): ...@@ -16,7 +16,9 @@ def getComputeNodeReferenceAndUserId(item):
if partition is not None: if partition is not None:
compute_node = partition.getParentValue() compute_node = partition.getParentValue()
if compute_node is not None and compute_node.getValidationState() == 'validated': if (compute_node is not None) and \
(compute_node.getPortalType() == 'Compute Node') and \
(compute_node.getValidationState() == 'validated'):
return compute_node, compute_node.getReference(), compute_node.getUserId() return compute_node, compute_node.getReference(), compute_node.getUserId()
return None, None, None return None, None, None
......
...@@ -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>SlapOSSlapTool</string> </value> <value> <string>SlapOSSlapTool</string> </value>
...@@ -55,28 +49,13 @@ ...@@ -55,28 +49,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>
...@@ -89,7 +68,7 @@ ...@@ -89,7 +68,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>
...@@ -98,7 +77,7 @@ ...@@ -98,7 +77,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>
......
...@@ -5,8 +5,8 @@ class TestSlapOSCoreComputeNodeUpdateFromDict(SlapOSTestCaseMixinWithAbort): ...@@ -5,8 +5,8 @@ class TestSlapOSCoreComputeNodeUpdateFromDict(SlapOSTestCaseMixinWithAbort):
def afterSetUp(self): def afterSetUp(self):
SlapOSTestCaseMixinWithAbort.afterSetUp(self) SlapOSTestCaseMixinWithAbort.afterSetUp(self)
self.compute_node = self.portal.compute_node_module.template_compute_node\ self.compute_node = self.portal.compute_node_module\
.Base_createCloneDocument(batch_mode=1) .newContent(portal_type="Compute Node")
self.compute_node.edit( self.compute_node.edit(
reference='TESTC-%s' % self.generateNewId(), reference='TESTC-%s' % self.generateNewId(),
) )
......
...@@ -371,7 +371,7 @@ class SlapTool(BaseTool): ...@@ -371,7 +371,7 @@ class SlapTool(BaseTool):
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getSoftwareReleaseListFromSoftwareProduct') 'getSoftwareReleaseListFromSoftwareProduct')
def getSoftwareReleaseListFromSoftwareProduct(self, def getSoftwareReleaseListFromSoftwareProduct(self, project_reference,
software_product_reference=None, software_release_url=None): software_product_reference=None, software_release_url=None):
""" """
Get the list of all published Software Releases related to one of either: Get the list of all published Software Releases related to one of either:
...@@ -382,12 +382,23 @@ class SlapTool(BaseTool): ...@@ -382,12 +382,23 @@ class SlapTool(BaseTool):
If referenced Software Product does not exist, return empty list. If referenced Software Product does not exist, return empty list.
If referenced Software Release does not exist, raise. If referenced Software Release does not exist, raise.
""" """
project_list = self.getPortalObject().portal_catalog.portal_catalog(
portal_type='Project',
reference=project_reference,
validation_state='validated',
limit=2
)
if len(project_list) != 1:
raise NotImplementedError("%i projects '%s'" % (len(project_list), project_reference))
project = project_list[0]
if software_product_reference is None: if software_product_reference is None:
assert(software_release_url is not None) assert(software_release_url is not None)
software_product_reference = self.getPortalObject().portal_catalog.unrestrictedSearchResults( software_product_reference = self.getPortalObject().portal_catalog.unrestrictedSearchResults(
portal_type='Software Release', portal_type='Software Product Release Variation',
parent__follow_up__uid=project.getUid(),
url_string=software_release_url url_string=software_release_url
)[0].getObject().getAggregateValue().getReference() )[0].getObject().getParentValue().getReference()
else: else:
# Don't accept both parameters # Don't accept both parameters
assert(software_release_url is None) assert(software_release_url is None)
...@@ -395,13 +406,14 @@ class SlapTool(BaseTool): ...@@ -395,13 +406,14 @@ class SlapTool(BaseTool):
software_product_list = self.getPortalObject().portal_catalog.unrestrictedSearchResults( software_product_list = self.getPortalObject().portal_catalog.unrestrictedSearchResults(
portal_type='Software Product', portal_type='Software Product',
reference=software_product_reference, reference=software_product_reference,
follow_up__uid=project.getUid(),
validation_state='published') validation_state='published')
if len(software_product_list) is 0: if len(software_product_list) is 0:
return dumps([]) return dumps([])
if len(software_product_list) > 1: if len(software_product_list) > 1:
raise NotImplementedError('Several Software Product with the same title.') raise NotImplementedError('Several Software Product with the same title.')
software_release_list = \ software_release_list = \
software_product_list[0].getObject().getAggregateRelatedValueList() software_product_list[0].getObject().contentValues(portal_type='Software Product Release Variation')
def sortkey(software_release): def sortkey(software_release):
publication_date = software_release.getEffectiveDate() publication_date = software_release.getEffectiveDate()
...@@ -418,9 +430,7 @@ class SlapTool(BaseTool): ...@@ -418,9 +430,7 @@ class SlapTool(BaseTool):
) )
return dumps( return dumps(
[software_release.getUrlString() [software_release.getUrlString()
for software_release in software_release_list for software_release in software_release_list])
if software_release.getValidationState() in \
['published', 'published_alive']])
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getHateoasUrl') 'getHateoasUrl')
...@@ -506,20 +516,20 @@ class SlapTool(BaseTool): ...@@ -506,20 +516,20 @@ class SlapTool(BaseTool):
return self._supplySupply(url, computer_id, state) return self._supplySupply(url, computer_id, state)
@convertToREST @convertToREST
def _requestComputeNode(self, compute_node_title): def _requestComputeNode(self, compute_node_title, project_reference):
portal = self.getPortalObject() portal = self.getPortalObject()
person = portal.portal_membership.getAuthenticatedMember().getUserValue() person = portal.portal_membership.getAuthenticatedMember().getUserValue()
person.requestComputeNode(compute_node_title=compute_node_title) person.requestComputeNode(compute_node_title=compute_node_title, project_reference=project_reference)
compute_node = ComputeNode(self.REQUEST.get('compute_node_reference').decode("UTF-8")) compute_node = ComputeNode(self.REQUEST.get('compute_node_reference').decode("UTF-8"))
return dumps(compute_node) return dumps(compute_node)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'requestComputer') 'requestComputer')
def requestComputer(self, computer_title): def requestComputer(self, computer_title, project_reference):
""" """
Request Compute Node Request Compute Node
""" """
return self._requestComputeNode(computer_title) return self._requestComputeNode(computer_title, project_reference)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'buildingSoftwareRelease') 'buildingSoftwareRelease')
...@@ -613,7 +623,7 @@ class SlapTool(BaseTool): ...@@ -613,7 +623,7 @@ class SlapTool(BaseTool):
def requestComputerPartition(self, computer_id=None, def requestComputerPartition(self, computer_id=None,
computer_partition_id=None, software_release=None, software_type=None, computer_partition_id=None, software_release=None, software_type=None,
partition_reference=None, partition_parameter_xml=None, partition_reference=None, partition_parameter_xml=None,
filter_xml=None, state=None, shared_xml=_MARKER): filter_xml=None, state=None, shared_xml=_MARKER, project_reference=None):
""" """
Asynchronously requests creation of compute partition for assigned Asynchronously requests creation of compute partition for assigned
parameters parameters
...@@ -627,7 +637,8 @@ class SlapTool(BaseTool): ...@@ -627,7 +637,8 @@ class SlapTool(BaseTool):
""" """
return self._requestComputePartition(computer_id, computer_partition_id, return self._requestComputePartition(computer_id, computer_partition_id,
software_release, software_type, partition_reference, software_release, software_type, partition_reference,
shared_xml, partition_parameter_xml, filter_xml, state) shared_xml, partition_parameter_xml, filter_xml, state,
project_reference)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'useComputer') 'useComputer')
...@@ -924,7 +935,8 @@ class SlapTool(BaseTool): ...@@ -924,7 +935,8 @@ class SlapTool(BaseTool):
@convertToREST @convertToREST
def _requestComputePartition(self, compute_node_id, compute_partition_id, def _requestComputePartition(self, compute_node_id, compute_partition_id,
software_release, software_type, partition_reference, software_release, software_type, partition_reference,
shared_xml, partition_parameter_xml, filter_xml, state): shared_xml, partition_parameter_xml, filter_xml, state,
project_reference):
""" """
Asynchronously requests creation of compute partition for assigned Asynchronously requests creation of compute partition for assigned
parameters parameters
...@@ -962,7 +974,8 @@ class SlapTool(BaseTool): ...@@ -962,7 +974,8 @@ class SlapTool(BaseTool):
instance_xml=castToStr(partition_parameter_kw), instance_xml=castToStr(partition_parameter_kw),
shared=shared, shared=shared,
sla_xml=castToStr(filter_kw), sla_xml=castToStr(filter_kw),
state=state) state=state,
project_reference=project_reference)
portal = self.getPortalObject() portal = self.getPortalObject()
if compute_node_id and compute_partition_id: if compute_node_id and compute_partition_id:
......
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