1
0
Fork 0
This commit is contained in:
Joao Gilberto 2022-11-09 23:57:12 -03:00
parent 79819aeacb
commit 9535413a10
3 changed files with 7 additions and 4 deletions

View file

@ -129,7 +129,10 @@ class Docker(ProcessorInterface):
def inspect_network(self):
self.parsed_object = {}
for container in self.client.containers.list():
self.parsed_object[container.name] = container.labels
ip_address = container.attrs["NetworkSettings"]["IPAddress"]
if not ip_address:
ip_address = list(container.attrs["NetworkSettings"]["Networks"].values())[0]["IPAddress"]
self.parsed_object[ip_address] = container.labels
class Swarm(ProcessorInterface):
@ -140,7 +143,7 @@ class Swarm(ProcessorInterface):
def inspect_network(self):
self.parsed_object = {}
for container in self.client.services.list():
self.parsed_object[container.attrs["Spec"]["Name"]] = container.attrs["Spec"]["Labels"]
self.parsed_object[container.attrs["Endpoint"]["VirtualIPs"][0]["Addr"].split("/")[0]] = container.attrs["Spec"]["Labels"]
class Kubernetes(ProcessorInterface):