| 3 | |
| 4 | |
| 5 | class EndpointConfig(dict): |
| 6 | def __init__(self, version, aliases=None, links=None, ipv4_address=None, |
| 7 | ipv6_address=None, link_local_ips=None, driver_opt=None, |
| 8 | mac_address=None): |
| 9 | if version_lt(version, '1.22'): |
| 10 | raise errors.InvalidVersion( |
| 11 | 'Endpoint config is not supported for API version < 1.22' |
| 12 | ) |
| 13 | |
| 14 | if aliases: |
| 15 | self["Aliases"] = aliases |
| 16 | |
| 17 | if links: |
| 18 | self["Links"] = normalize_links(links) |
| 19 | |
| 20 | ipam_config = {} |
| 21 | if ipv4_address: |
| 22 | ipam_config['IPv4Address'] = ipv4_address |
| 23 | |
| 24 | if ipv6_address: |
| 25 | ipam_config['IPv6Address'] = ipv6_address |
| 26 | |
| 27 | if mac_address: |
| 28 | if version_lt(version, '1.25'): |
| 29 | raise errors.InvalidVersion( |
| 30 | 'mac_address is not supported for API version < 1.25' |
| 31 | ) |
| 32 | self['MacAddress'] = mac_address |
| 33 | |
| 34 | if link_local_ips is not None: |
| 35 | if version_lt(version, '1.24'): |
| 36 | raise errors.InvalidVersion( |
| 37 | 'link_local_ips is not supported for API version < 1.24' |
| 38 | ) |
| 39 | ipam_config['LinkLocalIPs'] = link_local_ips |
| 40 | |
| 41 | if ipam_config: |
| 42 | self['IPAMConfig'] = ipam_config |
| 43 | |
| 44 | if driver_opt: |
| 45 | if version_lt(version, '1.32'): |
| 46 | raise errors.InvalidVersion( |
| 47 | 'DriverOpts is not supported for API version < 1.32' |
| 48 | ) |
| 49 | if not isinstance(driver_opt, dict): |
| 50 | raise TypeError('driver_opt must be a dictionary') |
| 51 | self['DriverOpts'] = driver_opt |
| 52 | |
| 53 | |
| 54 | class NetworkingConfig(dict): |
no outgoing calls