diff --git a/content/administration/odoo_sh/advanced/frequent_technical_questions.rst b/content/administration/odoo_sh/advanced/frequent_technical_questions.rst index e21343634..eac88f1a8 100644 --- a/content/administration/odoo_sh/advanced/frequent_technical_questions.rst +++ b/content/administration/odoo_sh/advanced/frequent_technical_questions.rst @@ -29,3 +29,32 @@ We advise that: - Your scheduled actions should be `idempotent `_: they must not cause side-effects if they are started more often than expected. + +.. _ip-address-change: + +How can I automate tasks when an IP address change occurs? +---------------------------------------------------------- + +**Odoo.sh notifies project administrators of IP address changes.** +Additionally, when the IP address of a production instance changes, an HTTP `GET` request is made +to the path `/_odoo.sh/ip-change` with the new IP address included as a query string parameter +(`new`), along with the previous IP address as an additional parameter (`old`). + +This mechanism allows custom actions to be applied in response to the IP address change +(e.g., sending an email, contacting a firewall API, configuring database objects, etc.) + +For security reasons, the `/_odoo.sh/ip-change` route is accessible only internally by the platform +itself and returns a `403` response if accessed through any other means. + +Here is a pseudo-implementation example: + +.. code-block:: python + + class IPChangeController(http.Controller): + + @http.route('/_odoo.sh/ip-change', auth='public') + def ip_change(self, old=None, new=None): + _logger.info("IP address changed from %s to %s", old, new) + # Then perform whatever action required for your use case, e.g., update an + # ir.config_parameter, send an email, contact an external firewall service's API, ... + return 'ok'