[Pywps-dev] Dynamic IPs for polling and results requests.
Matthieu Melcot
matthieu.melcot at spaceapplications.com
Mon Oct 17 06:12:18 PDT 2016
Hello,
I finally solved my problem adding this function in wsgiwps.py:
def dynUpdateConfigurationURLs(new_url):
'''
Update dynamically PyWPS configuration to match public IP:port of
this server into the cluster.
PyWPS servers are meant to be deployed into a dynamic Mesos
Cluster. Their IP:port are therefore auto-assigned by Marathon,
and are not deterministic.
The values of 'serveraddress' and 'outputURL' in wpsserver.conf
can't be forecasted in advance.
This function is meant to be called the client emit a request.
The base URL requested by the client is retrieved and reinjected in
PyWPS configuration, so that the client can poll and get the result
seamlessly.
'''
confFile = os.environ.get('PYWPS_CFG', '/var/www/wps/pywps.cfg')
configpar = ConfigParser.ConfigParser()
configpar.read('/var/www/wps/pywps.cfg')
# Old values
oldServerAddress = configpar.get('wps', 'serveraddress')
oldOutputURL = configpar.get('server', 'outputUrl')
# New values
new_url = re.sub('^https?://', '', new_url) # Remove http[s] if
present
newServerAddress = 'http://' + new_url
newOutputURL = newServerAddress + '/wps/wpsoutputs/'
# Update the config is URLs are not the same as the one used for
this HTTP requet.
if (oldServerAddress != newServerAddress) or (oldOutputURL !=
newOutputURL):
configpar.set('wps', 'serveraddress', newServerAddress)
configpar.set('server', 'outputUrl', newOutputURL)
with open(confFile, 'wb') as configfilePtr:
configpar.write(configfilePtr)
print('--------------------------------------------------------------------------------------------------------------------------')
print('Dynamically update PyWPS config \'serveraddress\' to
\'%s\' and \'outputUrl\' to \'%s\'' % (newServerAddress, newOutputURL))
def application(environ, start_response):
dynUpdateConfigurationURLs(environ['HTTP_HOST']) # Ex:
'HTTP_HOST': '172.16.10.21',
......
Regards,
Matthieu
On 10/17/2016 12:55 PM, Matthieu Melcot wrote:
>
> Hi Luis,
>
> Thanks for this answer.
>
> It is indeed not easy to keep trace of the ports/IP in our
> architecture since the cluster and the up and down of the WPS Servers
> is quite dynamic (managed by Mesos) and undeterministic.
>
> I wonder if PyWPS 4 would provide a better support for that kind of
> questions...
>
> Another way was to 'hook' at the WSGI level, in order to catch the
> calling messages, and update the wpsserver.conf with a 'sed'
> accordingly...
> But I didn't succeed to get this information in the messages coming
> into the WSGI application...
>
> Regards,
>
> Matthieu
>
>
>
> On 10/17/2016 12:04 PM, Luís de Sousa wrote:
>> Hi Matthieu,
>>
>> Unfortunately, this is not possible with the configuration files. It
>> is possible to tweak the PyWPS code to behave in that way, but this
>> might not be the simplest way.
>>
>> My advice is to give a name to that server and keep the entry up to
>> date in your DNS. That is likely the simplest way of running a PyWPS
>> server with a dynamic IP.
>>
>> Regards,
>>
>> Luís
>>
>>
>>
>>> -------- Original Message --------
>>> Subject: [Pywps-dev] Dynamic IPs for polling and results requests.
>>> Local Time: 17 October 2016 11:22 AM
>>> UTC Time: 17 October 2016 09:22
>>> From: matthieu.melcot at spaceapplications.com
>>> To: pywps-dev at lists.osgeo.org
>>>
>>> Hello,
>>>
>>> I'm using PyWPS 3.2.4 that I containerized into Docker Containers to
>>> run
>>> into Mesos Marathon.
>>>
>>> The external IP's and ports of my WPS Servers are therefore dynamic for
>>> being assigned by the Marathon framework.
>>>
>>> I am able to send a GetCapabilities or Execute requests to these
>>> distributed WPS Servers in the Cluster since I know the 'public' IPs
>>> and
>>> ports. However the XML documents sent back to the client by the PyWPS
>>> servers contain 'polling' and 'results' IPs refering to the values set
>>> in 'pywps.cfg' (and not the IP and port used by the client to
>>> communicate with the server).
>>>
>>> For example:
>>> [wps]
>>>
>>> ...
>>> serveraddress=http://172.16.10.40
>>> ...
>>>
>>> [wps]
>>> ...
>>> serveraddress=http://172.16.10.40/wps/wpsoutputs/
>>> ...
>>>
>>> Thus, the problem arise once it gets to poll for the end of the
>>> execution.
>>>
>>> How can I configure PyWPS to force it to provides polling and results
>>> URLs on the same public URLs that the client request?
>>>
>>> Matthieu
>>> _______________________________________________
>>> pywps-dev mailing list
>>> pywps-dev at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/pywps-dev
>>
>
> --
> Matthieu Melcot
> Software Engineer
>
> Space Applications Services NV/SA
> Leuvensesteenweg 325, 1932 Zaventem, Belgium
> Direct: +32-(0)2-416.05.35
> Main: +32-(0)2-721.54.84 Fax: +32-(0)2-721.54.44
> www.spaceapplications.com
--
Matthieu Melcot
Software Engineer
Space Applications Services NV/SA
Leuvensesteenweg 325, 1932 Zaventem, Belgium
Direct: +32-(0)2-416.05.35
Main: +32-(0)2-721.54.84 Fax: +32-(0)2-721.54.44
www.spaceapplications.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/pywps-dev/attachments/20161017/28529c97/attachment-0001.html>
More information about the pywps-dev
mailing list