mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-28 13:21:25 -07:00
Block network access for unit tests in docker.
This commit is contained in:
parent
af40d8c2a5
commit
99cac99cbc
2 changed files with 28 additions and 0 deletions
|
@ -67,6 +67,17 @@ def get_docker_container_ip(args, container_id):
|
|||
return ipaddress
|
||||
|
||||
|
||||
def get_docker_networks(args, container_id):
|
||||
"""
|
||||
:param args: EnvironmentConfig
|
||||
:param container_id: str
|
||||
:rtype: list[str]
|
||||
"""
|
||||
results = docker_inspect(args, container_id)
|
||||
networks = sorted(results[0]['NetworkSettings']['Networks'])
|
||||
return networks
|
||||
|
||||
|
||||
def docker_pull(args, image):
|
||||
"""
|
||||
:type args: EnvironmentConfig
|
||||
|
@ -165,6 +176,15 @@ def docker_inspect(args, container_id):
|
|||
raise ex # pylint: disable=locally-disabled, raising-bad-type
|
||||
|
||||
|
||||
def docker_network_disconnect(args, container_id, network):
|
||||
"""
|
||||
:param args: EnvironmentConfig
|
||||
:param container_id: str
|
||||
:param network: str
|
||||
"""
|
||||
docker_command(args, ['network', 'disconnect', network, container_id], capture=True)
|
||||
|
||||
|
||||
def docker_network_inspect(args, network):
|
||||
"""
|
||||
:type args: EnvironmentConfig
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue