[modules/docker] Return n/a when docker is not available

When the docker python module is not available, return n/a
instead of error'ing out.
This commit is contained in:
Tobias Witek 2018-10-18 19:34:27 +02:00
parent f7d80d8f27
commit a579f32879
2 changed files with 4 additions and 2 deletions

View file

@ -29,9 +29,11 @@ class Module(bumblebee.engine.Module):
self._status = self.status
def status(self, _):
cli = docker.DockerClient(base_url='unix://var/run/docker.sock')
try:
cli = docker.DockerClient(base_url='unix://var/run/docker.sock')
cli.ping()
except ConnectionError:
return "Daemon off"
except Exception:
return "n/a"
return "OK - {}".format(len(cli.containers.list(filters={'status': "running"})))