Commit 9b200321 by François C.

Connector Runner : permit other than localhost address connection

parent 036306df
......@@ -49,7 +49,12 @@ class ConnectorRunnerThread(Thread):
Thread.__init__(self)
self.daemon = True
port = os.environ.get('ODOO_CONNECTOR_PORT') or config['xmlrpc_port']
self.runner = ConnectorRunner(port or 8069)
host = config['xmlrpc_interface'] or 'localhost'
# host parameter has been introduced to consider
# case when Odoo is listening on VPN address
# the runner _async_http_get function called in run_jobs()
# was written with 'localhost' in urlopen() url string
self.runner = ConnectorRunner(host, port or 8069)
def run(self):
# sleep a bit to let the workers start at ease
......
......@@ -161,7 +161,7 @@ def _openerp_now():
return _datetime_to_epoch(dt)
def _async_http_get(port, db_name, job_uuid):
def _async_http_get(host, port, db_name, job_uuid):
# Method to set failed job (due to timeout, etc) as pending,
# to avoid keeping it as enqueued.
def set_job_pending():
......@@ -178,10 +178,9 @@ def _async_http_get(port, db_name, job_uuid):
# TODO: better way to HTTP GET asynchronously (grequest, ...)?
# if this was python3 I would be doing this with
# asyncio, aiohttp and aiopg
# TODO: Make any local address to be available (instead of localhost only)
def urlopen():
url = ('http://localhost:%s/connector/runjob?db=%s&job_uuid=%s' %
(port, db_name, job_uuid))
url = ('http://%s:%s/connector/runjob?db=%s&job_uuid=%s' %
(host, port, db_name, job_uuid))
try:
# we are not interested in the result, so we set a short timeout
# but not too short so we trap and log hard configuration errors
......@@ -275,7 +274,8 @@ class Database(object):
class ConnectorRunner(object):
def __init__(self, port=8069, channel_config_string=None):
def __init__(self, host, port=8069, channel_config_string=None):
self.host = host
self.port = port
self.channel_manager = ChannelManager()
if channel_config_string is None:
......@@ -322,7 +322,7 @@ class ConnectorRunner(object):
_logger.info("asking Odoo to run job %s on db %s",
job.uuid, job.db_name)
self.db_by_name[job.db_name].set_job_enqueued(job.uuid)
_async_http_get(self.port, job.db_name, job.uuid)
_async_http_get(self.host, self.port, job.db_name, job.uuid)
def process_notifications(self):
for db in self.db_by_name.values():
......
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