File: ipam.py

package info (click to toggle)
python-podman 5.4.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,140 kB
  • sloc: python: 7,532; makefile: 82; sh: 75
file content (62 lines) | stat: -rw-r--r-- 1,722 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"""Classes to support Internet Protocol Address Management.

Provided for compatibility
"""

from typing import Any, Optional
from collections.abc import Mapping


class IPAMPool(dict):
    """Collect IP Network configuration."""

    def __init__(
        self,
        subnet: Optional[str] = None,
        iprange: Optional[str] = None,
        gateway: Optional[str] = None,
        aux_addresses: Optional[Mapping[str, str]] = None,
    ):
        """Create IPAMPool.

        Args:
            subnet: IP subnet in CIDR format for this network.
            iprange: IP range in CIDR format for endpoints on this network.
            gateway: IP gateway address for this network.
            aux_addresses: Ignored.
        """
        super().__init__()
        self.update(
            {
                "AuxiliaryAddresses": aux_addresses,
                "Gateway": gateway,
                "IPRange": iprange,
                "Subnet": subnet,
            }
        )


class IPAMConfig(dict):
    """Collect IP Address configuration."""

    def __init__(
        self,
        driver: Optional[str] = "host-local",
        pool_configs: Optional[list[IPAMPool]] = None,
        options: Optional[Mapping[str, Any]] = None,
    ):
        """Create IPAMConfig.

        Args:
            driver: Network driver to use with this network.
            pool_configs: Network and endpoint information. Podman only supports one pool.
            options: Options to provide to the Network driver.
        """
        super().__init__()
        self.update(
            {
                "Config": pool_configs or [],
                "Driver": driver,
                "Options": options or {},
            }
        )