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)[source]¶
Bases:
Manager
Specialized Manager for Network resources.
Initialize Manager() object.
- Parameters:
client – APIClient() configured to connect to Podman service.
- 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: [<class 'podman.domain.networks.Network'>, <class '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]