Merge "Clean up network resources after tempest tests"

This commit is contained in:
Jenkins 2017-07-07 16:12:17 +00:00 committed by Gerrit Code Review
commit d0bd3a418f
2 changed files with 14 additions and 0 deletions

View File

@ -224,3 +224,11 @@ class DockerClient(object):
def delete_image(self, name):
with docker_utils.docker_client() as docker:
return docker.remove_image(name)
def list_networks(self, name):
with docker_utils.docker_client() as docker:
return docker.networks(names=[name])
def remove_network(self, name):
with docker_utils.docker_client() as docker:
return docker.remove_network(name)

View File

@ -47,6 +47,12 @@ class TestContainer(base.BaseZunTest):
self.container_client.delete_container(c['uuid'],
params={'force': True})
# cleanup the network resources
project_id = self.container_client.tenant_id
networks = self.docker_client.list_networks(project_id)
for network in networks:
self.docker_client.remove_network(network['Id'])
super(TestContainer, self).tearDown()
@decorators.idempotent_id('b8946b8c-57d5-4fdc-a09a-001d6b552725')