Carthage Networking Module
- class carthage.Network(name, vlan_id=None, **kwargs)
Represents a network that VMs and containers can connect to. In Carthage, networks are identified by a name and a VLAN identifier.
How networks are accessed depends on the underlying technology. The base Network class maintains an
Injectorso that only one instance of a technology-specific network is made for each logical network.
- class carthage.network.NetworkConfig
Represents a network configuration for a
Machine. A network config maps interface names to a network alink. A network link contains a MAC address, a network, and other information. Eventually a MAC is represented as a string and a network as a Network object. However indirection is possible in two ways. First, an injection key can be passed in; this dependency will be resolved in the context of an environment-specific injector. Secondly, a callable can be passed in. This callable will be called in the context of an injector and is expected to return the appropriate object.
- class carthage.network.NetworkLink(connection, interface, args)
- class carthage.network.BridgeNetwork(net, *, bridge_name=None, delete_bridge=None, delete_interfaces=None, **kwargs)
- class carthage.network.V4Config(dns_servers: list = None, domains: str = None, network: ipaddress.IPv4Network = None, dhcp: bool = None, dhcp_ranges: list = None, secondary_addresses: list[ipaddress.IPv4Address] = <factory>, address: ipaddress.IPv4Address = None, gateway: ipaddress.IPv4Address = None, masquerade: bool = False, pool: tuple = None, public_address: ipaddress.IPv4Address = None)
Network Events
The following events may be generated by the networking system resolved
Emitted toward
InjectionKey(NetworkConfig)when acarthage.network.NetworkConfigis resolved. The target is the network config that has resolved;
- param other_futures:
When both sides of a link are configured at the same time, the other side of the link cannot be resolved until its
carthage.Machineis ready.In this case a future is recorded and included in the event.This event is typically used to collect the set of futures for other_links. When all these futures are done, then all effects from resolution of the
NetworkConfighave been realized.
- public_address
Emitted toward
InjectionKey(NetworkLink)andInjectionKey(NetworkLink, host=model.name)when some part of the system becomes aware of the public address of a link behind a NAT. A public_address property is set on the link’s merged_v4_config prior to emitting the event.