[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:
parent
f7d80d8f27
commit
a579f32879
2 changed files with 4 additions and 2 deletions
|
@ -5,7 +5,7 @@
|
|||
[](https://codeclimate.com/github/tobi-wan-kenobi/bumblebee-status/coverage)
|
||||
[](https://codeclimate.com/github/tobi-wan-kenobi/bumblebee-status)
|
||||
|
||||
**Many, many thanks to all contributors! As of now, 32 of the modules are from various contributors (!), and only 16 from myself.**
|
||||
**Many, many thanks to all contributors! As of now, 33 of the modules are from various contributors (!), and only 16 from myself.**
|
||||
|
||||

|
||||
|
||||
|
|
|
@ -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"})))
|
||||
|
|
Loading…
Add table
Reference in a new issue