-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontainerEvent.py
43 lines (31 loc) · 915 Bytes
/
containerEvent.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from dataclasses import dataclass
import util
@dataclass
class ContEvent:
status: str
type: str
action: str
image: str
exitCode: int
name: str
def getEvent(ev):
event = ContEvent(None, None, None, None, None, None)
if "status" in ev:
event.status = ev["status"]
event.type = ev["Type"]
event.action = ev["Action"]
try:
event.image = ev["Actor"]["Attributes"]["image"]
event.exitCode = int(ev["Actor"]["Attributes"]["exitCode"])
except KeyError:
pass
try:
event.name = util.safeCast(ev["Actor"]["Attributes"]["name"], str)
except KeyError:
print("Warn: Event doesn't have name!")
pass
if event.type == "container":
return event
return None
def checkIfEventDie(event):
return event.action == "die" or event.status == "die" or event.action == "oom" or event.status == "oom"