Commit 2c1ef7f3 authored by Daniele Venzano's avatar Daniele Venzano

Fix pylint errors

parent 12557efd
...@@ -120,19 +120,19 @@ class Execution(BaseRecord): ...@@ -120,19 +120,19 @@ class Execution(BaseRecord):
# The idea is to use Træfik to do the reverse proxying, configured to use zookeeper to store dynamic configuration # The idea is to use Træfik to do the reverse proxying, configured to use zookeeper to store dynamic configuration
# Zoe updates ZooKeeper whenever an execution runs or is terminated and Træfik craetes or deletes the route automatically # Zoe updates ZooKeeper whenever an execution runs or is terminated and Træfik craetes or deletes the route automatically
if zoe_lib.config.get_conf().traefik_zk_ips is not None: if zoe_lib.config.get_conf().traefik_zk_ips is not None:
zk = KazooClient(hosts=zoe_lib.config.get_conf().traefik_zk_ips) zk_cli = KazooClient(hosts=zoe_lib.config.get_conf().traefik_zk_ips)
zk.start() zk_cli.start()
for service in self.services: for service in self.services:
for port in service.ports: for port in service.ports:
if port.enable_proxy: if port.enable_proxy:
endpoint = port.url_template.format(**{"ip_port": port.external_ip + ":" + str(port.external_port)}).encode('utf-8') endpoint = port.url_template.format(**{"ip_port": port.external_ip + ":" + str(port.external_port)}).encode('utf-8')
traefik_name = 'zoe_exec_{}_{}'.format(self.id, port.id) traefik_name = 'zoe_exec_{}_{}'.format(self.id, port.id)
zk.create('/traefik/backends/{}/servers/server/url'.format(traefik_name), endpoint, makepath=True) zk_cli.create('/traefik/backends/{}/servers/server/url'.format(traefik_name), endpoint, makepath=True)
zk.create('/traefik/frontends/{}/routes/path/rule'.format(traefik_name), 'PathPrefix:{}/{}'.format(zoe_lib.config.get_conf().traefik_base_url, port.proxy_key()).encode('utf-8'), makepath=True) zk_cli.create('/traefik/frontends/{}/routes/path/rule'.format(traefik_name), 'PathPrefix:{}/{}'.format(zoe_lib.config.get_conf().traefik_base_url, port.proxy_key()).encode('utf-8'), makepath=True)
zk.create('/traefik/frontends/{}/backend'.format(traefik_name), traefik_name.encode('utf-8'), makepath=True) zk_cli.create('/traefik/frontends/{}/backend'.format(traefik_name), traefik_name.encode('utf-8'), makepath=True)
zk.create('/traefik/alias') zk_cli.create('/traefik/alias')
zk.delete('/traefik/alias') zk_cli.delete('/traefik/alias')
zk.stop() zk_cli.stop()
def set_cleaning_up(self): def set_cleaning_up(self):
"""The services of the execution are being terminated.""" """The services of the execution are being terminated."""
...@@ -140,17 +140,17 @@ class Execution(BaseRecord): ...@@ -140,17 +140,17 @@ class Execution(BaseRecord):
self.sql_manager.executions.update(self.id, status=self._status) self.sql_manager.executions.update(self.id, status=self._status)
# See comment in method above # See comment in method above
if zoe_lib.config.get_conf().traefik_zk_ips is not None: if zoe_lib.config.get_conf().traefik_zk_ips is not None:
zk = KazooClient(hosts=zoe_lib.config.get_conf().traefik_zk_ips) zk_cli = KazooClient(hosts=zoe_lib.config.get_conf().traefik_zk_ips)
zk.start() zk_cli.start()
for service in self.services: for service in self.services:
for port in service.ports: for port in service.ports:
if port.enable_proxy: if port.enable_proxy:
traefik_name = 'zoe_exec_{}_{}'.format(self.id, port.id) traefik_name = 'zoe_exec_{}_{}'.format(self.id, port.id)
zk.delete('/traefik/backends/{}'.format(traefik_name), recursive=True) zk_cli.delete('/traefik/backends/{}'.format(traefik_name), recursive=True)
zk.delete('/traefik/frontends/{}'.format(traefik_name), recursive=True) zk_cli.delete('/traefik/frontends/{}'.format(traefik_name), recursive=True)
zk.create('/traefik/alias') zk_cli.create('/traefik/alias')
zk.delete('/traefik/alias') zk_cli.delete('/traefik/alias')
zk.stop() zk_cli.stop()
def set_terminated(self, reason=None): def set_terminated(self, reason=None):
"""The execution is not running.""" """The execution is not running."""
......
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