Commit dee40c68 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_erp5: Update contraints to rely on default information after removal erp5_promise

parent 6bfde5ab
portal_memcached = context portal_memcached = context
portal = context.getPortalObject() portal = context.getPortalObject()
promise_url = portal.getPromiseParameter('external_service', 'kumofs_url')
if promise_url is None: # erp5-memcached-persistent is provided by SlapOS, so here we are
return # ensuring the site uses real DNS Configuration provided by SlapOS.
# Port and name is hardcoded (unfortunally).
expected_url = "erp5-memcached-persistent:2003"
plugin = portal_memcached.restrictedTraverse("persistent_memcached_plugin", None) plugin = portal_memcached.restrictedTraverse("persistent_memcached_plugin", None)
if plugin is None: if plugin is None:
return [] return ["portal_memcached/persistent_memcached_plugin wasn't found!"]
url = "memcached://%s/" % plugin.getUrlString() url = plugin.getUrlString()
if promise_url != url: if url != expected_url:
fixing = '' fixing = ''
if fixit: if fixit:
_, promise_url = promise_url.split('://', 1) portal_memcached.persistent_memcached_plugin.edit(url_string=expected_url)
domain_port = promise_url.split('/', 1)[0]
port = domain_port.split(':')[-1]
domain = domain_port[:-(len(port)+1)]
portal_memcached.persistent_memcached_plugin.edit(url_string="%s:%s" % (domain, port))
fixing = ' (fixed)' fixing = ' (fixed)'
return ["Kumofs not configured as expected%s: %s" % return ["Kumofs not configured as expected%s: %s" %
(fixing, "Expect %s\nGot %s" % (promise_url, url))] (fixing, "Expect %s\nGot %s" % (expected_url, url))]
return [] return []
portal_memcached = context portal_memcached = context
portal = context.getPortalObject() portal = context.getPortalObject()
promise_url = portal.getPromiseParameter('external_service', 'memcached_url')
if promise_url is None:
return
plugin = portal_memcached.default_memcached_plugin # erp5-memcached-persistent is provided by SlapOS, so here we are
# ensuring the site uses real DNS Configuration provided by SlapOS.
# Port and name is hardcoded (unfortunally).
expected_url = "erp5-memcached-volatile:2013"
plugin = portal_memcached.restrictedTraverse("default_memcached_plugin", None)
if plugin is None:
return ["portal_memcached/default_memcached_plugin wasn't found!"]
url = "memcached://%s/" % plugin.getUrlString() url = plugin.getUrlString()
if promise_url != url: if url != expected_url:
fixing = '' fixing = ''
if fixit: if fixit:
portal_memcached.default_memcached_plugin.edit(url_string=expected_url)
fixing = ' (fixed)' fixing = ' (fixed)'
_, promise_url = promise_url.split('://', 1)
domain_port = promise_url.split('/', 1)[0]
port = domain_port.split(':')[-1]
domain = domain_port[:-(len(port)+1)]
portal_memcached.default_memcached_plugin.edit(url_string="%s:%s" % (domain, port))
return ["Memcached not configured as expected%s: %s" % return ["Memcached not configured as expected%s: %s" %
(fixing, "Expect %s\nGot %s" % (promise_url, url))] (fixing, "Expect %s\nGot %s" % (expected_url, url))]
else:
return [] return []
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