Commit e220b6f0 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Titouan Soulard

slapos_jio_api_style: use SlapOSCatalogToolCacheMixin to get Compute Node

parent 02d954b4
portal_type = data_dict["portal_type"] portal_type = data_dict["portal_type"]
portal = context.getPortalObject() portal = context.getPortalObject()
### Start of Duplicated code for getting documents the SlapOS way"
from Products.ERP5Type.Cache import CachingMethod
def _getNonCachedComputeNodeDocumentUrl(compute_node_reference):
return context.Base_getUnrestrictedDocumentUrl(
portal_type='Compute Node',
# XXX Hardcoded validation state
validation_state="validated",
reference=compute_node_reference)
def _getComputeNodeDocument(compute_node_reference):
"""
Get the validated compute_node with this reference.
"""
result = CachingMethod(_getNonCachedComputeNodeDocumentUrl,
id='_getComputeNodeDocument',
cache_factory='slap_cache_factory')(compute_node_reference)
if result:
return portal.restrictedTraverse(result)
return None
if portal_type == "Software Installation": if portal_type == "Software Installation":
if "compute_node_id" in data_dict and "software_release_uri" in data_dict: if "compute_node_id" in data_dict and "software_release_uri" in data_dict:
compute_node = _getComputeNodeDocument(data_dict["compute_node_id"]) compute_node = portal.portal_catalog.getComputeNodeObject(
data_dict["compute_node_id"],
raise_not_found=False,
)
if compute_node: if compute_node:
return compute_node.getSoftwareInstallationFromUrl(data_dict["software_release_uri"]) return compute_node.getSoftwareInstallationFromUrl(data_dict["software_release_uri"])
......
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