Commit d62f3aff authored by Daniele Venzano's avatar Daniele Venzano

Fix getting address for terminated containers

parent 8d676e88
......@@ -32,7 +32,11 @@
<li class="container_name" id="{{ s['id'] }}">{{ s['name'] }}</li>
<ul>
{% for p in s['description']['ports'] %}
{% if s['ip_address'] == None %}
<li>Inactive</li>
{% else %}
<li><a href="{{ p['protocol'] }}://{{ s['ip_address'] }}:{{ p['port_number'] }}{{ p['path'] }}">{{ p['name'] }}</a></li>
{% endif %}
{% endfor %}
</ul>
{% endfor %}
......
......@@ -241,7 +241,10 @@ class SwarmClient:
"ip_address": {}
} # type: Dict[str, Any]
for net in docker_info["NetworkSettings"]["Networks"]:
info["ip_address"][net] = docker_info["NetworkSettings"]["Networks"][net]['IPAddress']
if len(docker_info["NetworkSettings"]["Networks"][net]['IPAddress']) > 0:
info["ip_address"][net] = docker_info["NetworkSettings"]["Networks"][net]['IPAddress']
else:
info["ip_address"][net] = None
if docker_info["State"]["Running"]:
info["state"] = "running"
......@@ -263,7 +266,7 @@ class SwarmClient:
info["running"] = False
info['ports'] = {}
if docker_info['NetworkSettings'] is not None:
if docker_info['NetworkSettings']['Ports'] is not None:
for port in docker_info['NetworkSettings']['Ports']:
if docker_info['NetworkSettings']['Ports'][port] is not None:
mapping = (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment