networks_manager¶
PodmanResource manager subclassed for Network resources.
Classes and methods for manipulating network resources via Podman API service.
Example
- with PodmanClient(base_url=”unix:///run/user/1000/podman/podman.sock”) as client:
- for net in client.networks.list():
print(net.id, “
“)
- class NetworksManager(client: APIClient | None = None, podman_client: PodmanClient | None = None)[source]¶
Bases:
ManagerSpecialized Manager for Network resources.
Initialize Manager() object.
- Parameters:
client – APIClient() configured to connect to Podman service.
podman_client – PodmanClient() configured to connect to Podman object.
- create(name: str, **kwargs) Network[source]¶
Create a Network resource.
- Parameters:
name – Name of network to be created
- Keyword Arguments:
attachable (bool) – Ignored, always False.
check_duplicate (bool) – Ignored, always False.
dns_enabled (bool) – When True, do not provision DNS for this network.
driver (str) – Which network driver to use when creating network.
enable_ipv6 (bool) – Enable IPv6 on the network.
ingress (bool) – Ignored, always False.
internal (bool) – Restrict external access to the network.
ipam (IPAMConfig) – Optional custom IP scheme for the network.
labels (dict[str, str]) – Map of labels to set on the network.
options (dict[str, Any]) – Driver options.
scope (str) – Ignored, always “local”.
- Raises:
APIError – when Podman service reports an error
- exists(key: str) bool[source]¶
Returns True if resource exists.
Podman only.
Notes
This method does _not_ provide any mutex mechanism.
- get(key: str) Network[source]¶
Return information for the network_id.
- Parameters:
key – Network name or id.
- Raises:
NotFound – when Network does not exist
APIError – when error returned by service
- list(**kwargs) list[Network][source]¶
Report on networks.
- Keyword Arguments:
names (list[str]) – List of names to filter by.
ids (list[str]) – List of identifiers to filter by.
filters (Mapping[str,str]) –
Criteria for listing networks. Available filters:
driver=”bridge”: Matches a network’s driver. Only “bridge” is supported.
label=(Union[str, list[str]]): format either “key”, “key=value” or a list of such.
type=(str): Filters networks by type, legal values are:
”custom”
”builtin”
plugin=(list[str]]): Matches CNI plugins included in a network, legal values are (Podman only):
bridge
portmap
firewall
tuning
dnsname
macvlan
greedy (bool) – Fetch more details for each network individually. You might want this to get the containers attached to them. Ignored.
- Raises:
APIError – when error returned by service
- prepare_model(attrs: PodmanResource | Mapping[str, Any]) PodmanResourceType¶
Create a model from a set of attributes.
- prune(filters: dict[str, Any] | None = None) dict[Literal['NetworksDeleted', 'SpaceReclaimed'], Any][source]¶
Delete unused Networks.
SpaceReclaimed always reported as 0
- Parameters:
filters – Criteria for selecting volumes to delete. Ignored.
- Raises:
APIError – when service reports error
- remove(name: Network | str, force: bool | None = None) None[source]¶
Remove Network resource.
- Parameters:
name – Identifier of Network to delete.
force – Remove network and any associated containers
- Raises:
APIError – when Podman service reports an error
- property resource¶
prepare_model() will create Network classes.
- Type:
Type[Network]