vantage6.common.docker.network_manager.NetworkManager#
- class NetworkManager(network_name)#
Bases:
object
Handle a Docker network
- __init__(network_name)#
Initialize the NetworkManager
- Parameters:
network_name (str) – Name of the network
Methods
__init__
(network_name)Initialize the NetworkManager
connect
(container_name[, aliases, ipv4])Connect a container to the network.
contains
(container)Whether or not this network contains a certain container
create_network
([is_internal])Creates an internal (docker) network
delete
([kill_containers])Delete network
disconnect
(container_name)Disconnect a container from the network.
get_container_ip
(container_name)Get IP address of a container in the network
Attributes
log
- connect(container_name, aliases=None, ipv4=None)#
Connect a container to the network.
- Parameters:
container_name (str) – Name of the container that should be connected to the network
aliases (list[str]) – A list of aliases for the container in the network
ipv4 (str | None) – An IP address to assign to the container in the network
- Return type:
None
- contains(container)#
Whether or not this network contains a certain container
- Parameters:
container (Container) – container to look for in network
- Returns:
Whether or not container is in the network
- Return type:
bool
- create_network(is_internal=True)#
Creates an internal (docker) network
Used by algorithm containers to communicate with the node API.
- Parameters:
is_internal (bool) – True if network should only be able to communicate internally
- Return type:
None
- delete(kill_containers=True)#
Delete network
- Parameters:
kill_containers (bool) – If true, kill and remove any containers in the network
- Return type:
None
- disconnect(container_name)#
Disconnect a container from the network.
- Parameters:
container – Name of the container to disconnect
- Return type:
None
- get_container_ip(container_name)#
Get IP address of a container in the network
- Parameters:
container_name (str) – Name of the container whose IP address is sought
- Returns:
IP address of the container in the network
- Return type:
str