Check container_id when disconnecting its network

The field 'container_id' is not always available (i.e. it is None
if the container failed to create in Docker). We need to check
it before disconnecting this container.

Change-Id: I497a171548b5382abdde29160c43c9f4b10972c6
This commit is contained in:
Hongbin LU
2018-01-10 18:37:32 +00:00
parent 6dc61b74d1
commit f72b678315

View File

@@ -299,8 +299,9 @@ class KuryrNetwork(network.Network):
neutron_ports.add(port_id)
try:
self.docker.disconnect_container_from_network(container_id,
network_name)
if container_id:
self.docker.disconnect_container_from_network(container_id,
network_name)
finally:
for port_id in all_ports:
try: