mirror of
https://github.com/valitydev/salt.git
synced 2024-11-09 01:36:48 +00:00
engine.docker_events: Add filter
This commit is contained in:
parent
7f326c0c17
commit
7ba79eaadc
@ -41,7 +41,8 @@ def __virtual__():
|
||||
|
||||
def start(docker_url='unix://var/run/docker.sock',
|
||||
timeout=CLIENT_TIMEOUT,
|
||||
tag='salt/engines/docker_events'):
|
||||
tag='salt/engines/docker_events',
|
||||
filters=None):
|
||||
'''
|
||||
Scan for Docker events and fire events
|
||||
|
||||
@ -52,10 +53,18 @@ def start(docker_url='unix://var/run/docker.sock',
|
||||
engines:
|
||||
- docker_events:
|
||||
docker_url: unix://var/run/docker.sock
|
||||
filters:
|
||||
containers:
|
||||
- start
|
||||
- stop
|
||||
- die
|
||||
- oom
|
||||
|
||||
The config above sets up engines to listen
|
||||
for events from the Docker daemon and publish
|
||||
them to the Salt event bus.
|
||||
|
||||
For filter reference, see https://docs.docker.com/engine/reference/commandline/events/
|
||||
'''
|
||||
|
||||
if __opts__.get('__role') == 'master':
|
||||
@ -81,7 +90,7 @@ def start(docker_url='unix://var/run/docker.sock',
|
||||
client = docker.Client(base_url=docker_url, timeout=timeout)
|
||||
|
||||
try:
|
||||
events = client.events()
|
||||
events = client.events(filters=filters)
|
||||
for event in events:
|
||||
data = salt.utils.json.loads(event.decode(__salt_system_encoding__, errors='replace'))
|
||||
# https://github.com/docker/cli/blob/master/cli/command/system/events.go#L109
|
||||
|
Loading…
Reference in New Issue
Block a user