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

XXX slapos_slap_tool: fixup rebase

TODO: drop original change. Do not add yet another call which slow down more slapgrid
parent 20698c3a
from lxml import etree
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from AccessControl.SecurityManagement import getSecurityManager, \
setSecurityManager, newSecurityManager
......@@ -58,12 +56,3 @@ def reindexPartition(item):
def Instance_reindexComputePartition(state_change):
item = state_change['object']
reindexPartition(item)
def castDictToXMLString(dict_kw):
instance = etree.Element('instance')
for _id, _value in dict_kw.iteritems():
# cast everything to string
etree.SubElement(instance, "parameter",
attrib={'id':_id}).text = str(_value)
return etree.tostring(instance, pretty_print=True,
xml_declaration=True, encoding='utf-8')
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>mode</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/string</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Stores API server URL</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>preferred_jio_api_url_property</string> </value>
</item>
<item>
<key> <string>mode</string> </key>
<value> <string>w</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
<item>
<key> <string>preference</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>property_default</string> </key>
<value> <string>python: \'\'</string> </value>
</item>
<item>
<key> <string>read_permission</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>write_permission</string> </key>
<value> <string>Manage properties</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_function</string> </key>
<value> <string>castDictToXMLString</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>SlapOSSlapTool</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_castDictToXMLString</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -352,7 +352,7 @@ class SlapTool(BaseTool):
# Be sure to prevent accessing information to disallowed users
compute_node = _assertACI(compute_node)
try:
software_installation = compute_node.getSoftwareInstallationFromUrl(url)
software_installation = compute_node._getSoftwareInstallationFromUrl(url)
except NotFound:
data_dict = self._getAccessStatus(None)
else:
......@@ -434,33 +434,6 @@ class SlapTool(BaseTool):
[software_release.getUrlString()
for software_release in software_release_list])
security.declareProtected(Permissions.AccessContentsInformation,
'getJIOAPIUrl')
def getJIOAPIUrl(self):
"""
Return preferred jIO API URL.
"""
preference_tool = self.getPortalObject().portal_preferences
try:
url = CachingMethod(preference_tool.getPreferredJioApiUrl,
id='getJIOAPIUrl',
cache_factory='slap_cache_factory')()
except AttributeError:
raise NotFound
if not url:
raise NotFound
# Keep in cache server for 1 hour
self.REQUEST.response.setStatus(200)
self.REQUEST.response.setHeader('Cache-Control',
'public, max-age=3600, stale-if-error=604800')
self.REQUEST.response.setHeader('Vary',
'REMOTE_USER')
self.REQUEST.response.setHeader('content-type', 'text; charset=utf-8')
self.REQUEST.response.setHeader('Etag',
calculate_dict_hash({"etag": url}))
self.REQUEST.response.setBody(url)
return self.REQUEST.response
security.declareProtected(Permissions.AccessContentsInformation,
'getHateoasUrl')
def getHateoasUrl(self):
......@@ -831,7 +804,7 @@ class SlapTool(BaseTool):
Log the software release status
"""
compute_node = self.getPortalObject().portal_catalog.getComputeNodeObject(compute_node_id)
software_installation = compute_node.getSoftwareInstallationFromUrl(url)
software_installation = compute_node._getSoftwareInstallationFromUrl(url)
software_installation.setBuildingStatus(
'software release %s' % url, "building")
......@@ -841,7 +814,7 @@ class SlapTool(BaseTool):
Log the software release status
"""
compute_node = self.getPortalObject().portal_catalog.getComputeNodeObject(compute_node_id)
software_installation = compute_node.getSoftwareInstallationFromUrl(url)
software_installation = compute_node._getSoftwareInstallationFromUrl(url)
software_installation.setAccessStatus(
'software release %s available' % url, "available")
......@@ -851,7 +824,7 @@ class SlapTool(BaseTool):
Reports that Software Release is destroyed
"""
compute_node = self.getPortalObject().portal_catalog.getComputeNodeObject(compute_node_id)
software_installation = compute_node.getSoftwareInstallationFromUrl(url)
software_installation = compute_node._getSoftwareInstallationFromUrl(url)
if software_installation.getSlapState() != 'destroy_requested':
raise NotFound
if self.getPortalObject().portal_workflow.isTransitionPossible(software_installation,
......@@ -1142,7 +1115,7 @@ class SlapTool(BaseTool):
compute_partition_id, slave_reference=None):
compute_partition_document = self.getPortalObject().portal_catalog.getComputePartitionObject(
compute_node_id, compute_partition_id)
return compute_partition_document.getSoftwareInstance(slave_reference)
return compute_partition_document._getSoftwareInstance(slave_reference)
@convertToREST
def _softwareReleaseError(self, url, compute_node_id, error_log):
......@@ -1150,7 +1123,7 @@ class SlapTool(BaseTool):
Log the compute_node status
"""
compute_node = self.getPortalObject().portal_catalog.getComputeNodeObject(compute_node_id)
software_installation = compute_node.getSoftwareInstallationFromUrl(url)
software_installation = compute_node._getSoftwareInstallationFromUrl(url)
software_installation.setErrorStatus('while installing %s' % url)
InitializeClass(SlapTool)
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