Commit 15d5f603 authored by Daniele Venzano's avatar Daniele Venzano

Fix errors generated by new pylint version

parent 0cf2614b
......@@ -76,6 +76,7 @@ class APIManager:
return False, 'Master is unreachable, abandoning API request'
log.warning('Reconnecting and retrying request...')
self._connect()
return False, 'Master is unreachable, abandoning API request'
def execution_start(self, exec_id: int) -> APIReturnType:
"""Start an execution."""
......
......@@ -39,7 +39,8 @@ class ExecutionStartWeb(ZoeRequestHandler):
"""Start an execution."""
uid, role = get_auth(self)
if uid is None:
return self.redirect(self.get_argument('next', u'/login'))
self.redirect(self.get_argument('next', u'/login'))
return
app_descr_json = self.request.files['file'][0]['body'].decode('utf-8')
app_descr = json.loads(app_descr_json)
......@@ -62,7 +63,8 @@ class ExecutionListWeb(ZoeRequestHandler):
"""Home page with authentication."""
uid, role = get_auth(self)
if uid is None:
return self.redirect(self.get_argument('next', u'/login'))
self.redirect(self.get_argument('next', u'/login'))
return
executions = self.api_endpoint.execution_list(uid, role)
......@@ -86,7 +88,8 @@ class ExecutionRestartWeb(ZoeRequestHandler):
"""Restart an already defined (and not running) execution."""
uid, role = get_auth(self)
if uid is None:
return self.redirect(self.get_argument('next', u'/login'))
self.redirect(self.get_argument('next', u'/login'))
return
e = self.api_endpoint.execution_by_id(uid, role, execution_id)
new_id = self.api_endpoint.execution_start(uid, role, e.name, e.description)
......@@ -106,7 +109,8 @@ class ExecutionTerminateWeb(ZoeRequestHandler):
"""Terminate an execution."""
uid, role = get_auth(self)
if uid is None:
return self.redirect(self.get_argument('next', u'/login'))
self.redirect(self.get_argument('next', u'/login'))
return
success, message = self.api_endpoint.execution_terminate(uid, role, execution_id)
if not success:
......@@ -127,7 +131,8 @@ class ExecutionInspectWeb(ZoeRequestHandler):
"""Gather details about an execution."""
uid, role = get_auth(self)
if uid is None:
return self.redirect(self.get_argument('next', u'/login'))
self.redirect(self.get_argument('next', u'/login'))
return
e = self.api_endpoint.execution_by_id(uid, role, execution_id)
......@@ -167,7 +172,8 @@ class ServiceLogsWeb(ZoeRequestHandler):
"""Gather details about an execution."""
uid, role = get_auth(self)
if uid is None:
return self.redirect(self.get_argument('next', u'/login'))
self.redirect(self.get_argument('next', u'/login'))
return
service = self.api_endpoint.service_by_id(uid, role, service_id)
......
......@@ -84,7 +84,8 @@ class HomeWeb(ZoeRequestHandler):
"""Home page with authentication."""
uid, role = get_auth(self)
if uid is None:
return self.redirect(self.get_argument('next', u'/login'))
self.redirect(self.get_argument('next', u'/login'))
return
filters = {
"user_id": uid,
......
......@@ -33,7 +33,8 @@ class StatusEndpointWeb(ZoeRequestHandler):
"""Status and statistics page."""
uid, role = get_auth(self)
if uid is None or role != 'admin':
return self.redirect(self.get_argument('next', u'/login'))
self.redirect(self.get_argument('next', u'/login'))
return
stats = self.api_endpoint.statistics_scheduler(uid, role)
if stats is None:
......
......@@ -40,7 +40,8 @@ class ZAppShopHomeWeb(ZoeRequestHandler):
"""Home page with authentication."""
uid, role = get_auth(self)
if uid is None:
return self.redirect(self.get_argument('next', u'/login'))
self.redirect(self.get_argument('next', u'/login'))
return
zapps = zapp_shop.zshop_list_apps(role)
......@@ -64,7 +65,8 @@ class ZAppLogoWeb(ZoeRequestHandler):
"""Home page with authentication."""
uid, role_ = get_auth(self)
if uid is None:
return self.redirect(self.get_argument('next', u'/login'))
self.redirect(self.get_argument('next', u'/login'))
return
self.set_header("Content-type", "image/png")
......@@ -87,7 +89,8 @@ class ZAppStartWeb(ZoeRequestHandler):
"""Home page with authentication."""
uid, role = get_auth(self)
if uid is None:
return self.redirect(self.get_argument('next', u'/login'))
self.redirect(self.get_argument('next', u'/login'))
return
manifest_index = int(zapp_id.split('-')[-1])
zapp_id = "-".join(zapp_id.split('-')[:-1])
......@@ -110,7 +113,8 @@ class ZAppStartWeb(ZoeRequestHandler):
"""Write the parameters in the description and start the ZApp."""
uid, role = get_auth(self)
if uid is None:
return self.redirect(self.get_argument('next', u'/login'))
self.redirect(self.get_argument('next', u'/login'))
return
manifest_index = int(zapp_id.split('-')[-1])
zapp_id = "-".join(zapp_id.split('-')[:-1])
......
......@@ -18,6 +18,7 @@
import logging
import re
import time
from typing import Union
from zoe_lib.config import get_conf
from zoe_lib.state import Service
......@@ -42,10 +43,11 @@ class DockerEngineBackend(zoe_master.backends.base.BaseBackend):
super().__init__(opts)
self.docker_config = DockerConfig(get_conf().backend_docker_config_file).read_config()
def _get_config(self, host) -> DockerHostConfig:
def _get_config(self, host) -> Union[DockerHostConfig, None]:
for conf in self.docker_config:
if conf.name == host:
return conf
return None
@classmethod
def init(cls, state):
......
......@@ -17,7 +17,7 @@
import logging
import time
from typing import List
from typing import List, Union
from zoe_lib.config import get_conf
from zoe_lib.state import Execution, Service # pylint: disable=unused-import
......@@ -45,9 +45,10 @@ except ImportError:
log = logging.getLogger(__name__)
def _get_backend() -> BaseBackend:
def _get_backend() -> Union[BaseBackend, None]:
"""Return the right backend instance by reading the global configuration."""
backend_name = get_conf().backend
assert backend_name in ['Kubernetes', 'Swarm', 'DockerEngine']
if backend_name == 'Kubernetes':
if KubernetesBackend is None:
raise ZoeException('The Kubernetes backend requires the pykube module')
......@@ -62,7 +63,7 @@ def _get_backend() -> BaseBackend:
return DockerEngineBackend(get_conf())
else:
log.error('Unknown backend selected')
assert False
return None
def initialize_backend(state):
......
......@@ -99,3 +99,4 @@ def main(test_conf=None):
metrics.quit()
if gelf_listener is not None:
gelf_listener.quit()
return 0
......@@ -167,7 +167,7 @@ class ZoeElasticScheduler:
return out_list
@catch_exceptions_and_retry
def loop_start_th(self):
def loop_start_th(self): # pylint: disable=too-many-locals
"""The Scheduler thread loop."""
auto_trigger = SELF_TRIGGER_TIMEOUT
while True:
......
......@@ -45,6 +45,8 @@ class SimulatedNode:
return 'service required labels {} to be defined on the node'.format(service.labels)
elif not self._image_is_available(service.image_name):
return 'image {} is not available on this node'.format(service.image_name)
else:
return 'unknown reason'
def _image_is_available(self, image_name) -> bool:
for image in self.images:
......
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