<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p>Hello, <br>
    </p>
    <p>I finally solved my problem adding this function in wsgiwps.py:</p>
    <p><br>
      <tt>def dynUpdateConfigurationURLs(new_url):</tt><tt><br>
      </tt><tt>    '''</tt><tt><br>
      </tt><tt>    Update dynamically PyWPS configuration to match
        public IP:port of this server into the cluster.</tt><tt><br>
      </tt><tt><br>
      </tt><tt>    PyWPS servers are meant to be deployed into a dynamic
        Mesos Cluster. Their IP:port are therefore auto-assigned by
        Marathon,</tt><tt><br>
      </tt><tt>    and are not deterministic.</tt><tt><br>
      </tt><tt>    The values of 'serveraddress' and 'outputURL' in
        wpsserver.conf can't be forecasted in advance.</tt><tt><br>
      </tt><tt><br>
      </tt><tt>    This function is meant to be called the client emit a
        request.</tt><tt><br>
      </tt><tt>    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.</tt><tt><br>
      </tt><tt>    '''</tt><tt><br>
      </tt><tt>    confFile = os.environ.get('PYWPS_CFG',
        '/var/www/wps/pywps.cfg')</tt><tt><br>
      </tt><tt>    configpar = ConfigParser.ConfigParser()</tt><tt><br>
      </tt><tt>    configpar.read('/var/www/wps/pywps.cfg')</tt><tt><br>
      </tt><tt>    # Old values</tt><tt><br>
      </tt><tt>    oldServerAddress = configpar.get('wps',
        'serveraddress')</tt><tt><br>
      </tt><tt>    oldOutputURL = configpar.get('server', 'outputUrl')</tt><tt><br>
      </tt><tt><br>
      </tt><tt>    # New values</tt><tt><br>
      </tt><tt>    new_url = re.sub('^https?://', '', new_url)  # Remove
        http[s] if present</tt><tt><br>
      </tt><tt>    newServerAddress = '<a class="moz-txt-link-freetext" href="http://">http://</a>' + new_url</tt><tt><br>
      </tt><tt>    newOutputURL = newServerAddress + '/wps/wpsoutputs/'</tt><tt><br>
      </tt><tt><br>
      </tt><tt>    # Update the config is URLs are not the same as the
        one used for this HTTP requet.</tt><tt><br>
      </tt><tt>    if (oldServerAddress != newServerAddress) or
        (oldOutputURL != newOutputURL):</tt><tt><br>
      </tt><tt>        configpar.set('wps', 'serveraddress',
        newServerAddress)</tt><tt><br>
      </tt><tt>        configpar.set('server', 'outputUrl',
        newOutputURL)</tt><tt><br>
      </tt><tt><br>
      </tt><tt>        with open(confFile, 'wb') as configfilePtr:</tt><tt><br>
      </tt><tt>            configpar.write(configfilePtr)</tt><tt><br>
      </tt><tt><br>
      </tt><tt>       
print('--------------------------------------------------------------------------------------------------------------------------')</tt><tt><br>
      </tt><tt>        print('Dynamically update PyWPS config
        \'serveraddress\' to \'%s\' and \'outputUrl\' to \'%s\'' %
        (newServerAddress, newOutputURL))</tt><tt><br>
      </tt><tt><br>
      </tt><tt>def application(environ, start_response):</tt><tt><br>
      </tt><tt>    dynUpdateConfigurationURLs(environ['HTTP_HOST'])   #
        Ex: 'HTTP_HOST': '172.16.10.21',    <br>
      </tt></p>
    <p><tt>    ......<br>
      </tt></p>
    <p><tt><br>
      </tt></p>
    <p><br>
    </p>
    <p>Regards,</p>
    <p>Matthieu<br>
    </p>
    <p><br>
    </p>
    <br>
    <div class="moz-cite-prefix">On 10/17/2016 12:55 PM, Matthieu Melcot
      wrote:<br>
    </div>
    <blockquote
      cite="mid:e5dcb736-fe33-eb24-f58e-f3e1d209c3ff@spaceapplications.com"
      type="cite">
      <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
      <p>Hi Luis, <br>
      </p>
      <p>Thanks for this answer.</p>
      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.<br>
      <br>
      I wonder if PyWPS 4 would provide a better support for that kind
      of questions...<br>
      <br>
      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...<br>
      But I didn't succeed to get this information in the messages
      coming into the WSGI application...<br>
      <br>
      Regards,<br>
      <br>
      Matthieu<br>
      <br>
      <br>
      <br>
      <div class="moz-cite-prefix">On 10/17/2016 12:04 PM, Luí­s de
        Sousa wrote:<br>
      </div>
      <blockquote
cite="mid:V33FAXvmHS0p_iPEFWc_Rxq2bmgetNpkhk-Wahj1f2NiyHzLU7nA3-vUQwV36LAs1Oec3kfCjHT8q1DdMKcj0g==@protonmail.ch"
        type="cite">
        <div>Hi Matthieu,<br>
        </div>
        <div><br>
        </div>
        <div>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.<br>
        </div>
        <div><br>
        </div>
        <div>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.<br>
        </div>
        <div><br>
        </div>
        <div>Regards,<br>
        </div>
        <div><br>
        </div>
        <div>Luís<br>
        </div>
        <div class="protonmail_signature_block ">
          <div class="protonmail_signature_block-user "><br>
          </div>
          <div class="protonmail_signature_block-proton
            protonmail_signature_block-empty"><br>
          </div>
        </div>
        <div><br>
        </div>
        <blockquote type="cite" class="protonmail_quote">
          <div>-------- Original Message --------<br>
          </div>
          <div>Subject: [Pywps-dev] Dynamic IPs for polling and results
            requests.<br>
          </div>
          <div>Local Time: 17 October 2016 11:22 AM<br>
          </div>
          <div>UTC Time: 17 October 2016 09:22<br>
          </div>
          <div>From: <a moz-do-not-send="true"
              class="moz-txt-link-abbreviated"
              href="mailto:matthieu.melcot@spaceapplications.com">matthieu.melcot@spaceapplications.com</a><br>
          </div>
          <div>To: <a moz-do-not-send="true"
              class="moz-txt-link-abbreviated"
              href="mailto:pywps-dev@lists.osgeo.org">pywps-dev@lists.osgeo.org</a><br>
          </div>
          <div><br>
          </div>
          <div>Hello,<br>
          </div>
          <div> <br>
          </div>
          <div> I'm using PyWPS 3.2.4 that I containerized into Docker
            Containers to run <br>
          </div>
          <div> into Mesos Marathon.<br>
          </div>
          <div> <br>
          </div>
          <div> The external IP's and ports of my WPS Servers are
            therefore dynamic for <br>
          </div>
          <div> being assigned by the Marathon framework.<br>
          </div>
          <div> <br>
          </div>
          <div> I am able to send a GetCapabilities or Execute requests
            to these <br>
          </div>
          <div> distributed WPS Servers in the Cluster since I know the
            'public' IPs and <br>
          </div>
          <div> ports. However the XML documents sent back to the client
            by the PyWPS <br>
          </div>
          <div> servers contain 'polling' and 'results' IPs refering to
            the values set <br>
          </div>
          <div> in 'pywps.cfg' (and not the IP and port used by the
            client to <br>
          </div>
          <div> communicate with the server).<br>
          </div>
          <div> <br>
          </div>
          <div> For example:<br>
          </div>
          <div> [wps]<br>
          </div>
          <div> <br>
          </div>
          <div> ...<br>
          </div>
          <div> serveraddress=<a moz-do-not-send="true"
              class="moz-txt-link-freetext" href="http://172.16.10.40">http://172.16.10.40</a><br>
          </div>
          <div> ...<br>
          </div>
          <div> <br>
          </div>
          <div> [wps]<br>
          </div>
          <div> ...<br>
          </div>
          <div> serveraddress=<a moz-do-not-send="true"
              class="moz-txt-link-freetext"
              href="http://172.16.10.40/wps/wpsoutputs/">http://172.16.10.40/wps/wpsoutputs/</a><br>
          </div>
          <div> ...<br>
          </div>
          <div> <br>
          </div>
          <div> Thus, the problem arise once it gets to poll for the end
            of the execution.<br>
          </div>
          <div> <br>
          </div>
          <div> How can I configure PyWPS to force it to provides
            polling and results <br>
          </div>
          <div> URLs on the same public URLs that the client request?<br>
          </div>
          <div> <br>
          </div>
          <div> Matthieu<br>
          </div>
          <div> _______________________________________________<br>
          </div>
          <div> pywps-dev mailing list<br>
          </div>
          <div> <a moz-do-not-send="true"
              class="moz-txt-link-abbreviated"
              href="mailto:pywps-dev@lists.osgeo.org">pywps-dev@lists.osgeo.org</a><br>
          </div>
          <div> <a moz-do-not-send="true" class="moz-txt-link-freetext"
              href="http://lists.osgeo.org/mailman/listinfo/pywps-dev">http://lists.osgeo.org/mailman/listinfo/pywps-dev</a><br>
          </div>
        </blockquote>
        <div><br>
        </div>
      </blockquote>
      <br>
      <pre class="moz-signature" cols="72">-- 
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
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="http://www.spaceapplications.com">www.spaceapplications.com</a></pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
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
<a class="moz-txt-link-abbreviated" href="http://www.spaceapplications.com">www.spaceapplications.com</a></pre>
  </body>
</html>