avocado_i2n.vmnet.netconfig module¶
Network configuration object for the VM network.
SUMMARY¶
Copyright: Intra2net AG
CONTENTS¶
It contains the network configuration, offers network services like IP address allocation, translation, and validation, and consists of Interface objects that share this network configuration.
INTERFACE¶
- class avocado_i2n.vmnet.netconfig.VMNetconfig[source]¶
Bases:
objectGet the netconfig class - a collection of interfaces sharing the same network configuration.
- property interfaces: dict[Any, VMInterface]¶
Get a collection of interfaces the netconfig represents.
- ..todo:: The key type should be str but using the same method and property name confuses
our automation in some places and not in others.
- property netdst: str | None¶
Get the bridge where Qemu will redirect the packets.
Plays the role of the network connectivity skeleton.
- property netmask: str | None¶
Get the netmask used by the participating network interfaces.
- property mask_bit: str | None¶
Get the netmask bit used by the participating network interfaces.
- property gateway: str | None¶
Get the gateway ip used by the participating network interfaces.
- property net_ip: str | None¶
Get the network ip used by the participating network interfaces.
- property host_ip: str | None¶
IP of the host for the virtual machine if it participates in the local network (and therefore in the netcofig).
- property range: dict[int, bool]¶
IP range of addresses that can be allocated to joining vms (new interfaces that join the netconfig).
To set a different ip_start and ip_end, i.e. different boundaries, use the setter of this property.
Note
Used for any DHCP configuration.
- property ip_start: str¶
Beginning of the IP range.
- property ip_end: str¶
End of the IP range.
- property domain: str | None¶
DNS domain name for the local network.
Note
Used for host-based DNS configuration.
- property forwarder: str | None¶
DNS forwarder address for the local network.
Note
Used for host-based DNS configuration.
- property rev: str | None¶
DNS reverse lookup table name for the local network.
Note
Used for host-based DNS configuration.
- property view: str | None¶
DNS view name for the local network.
Note
Used for host-based DNS configuration.
- property ext_netdst: str | None¶
External network destination to which we route after network translation.
Note
Used for host-based NAT configuration.
- from_interface(interface: VMInterface) None[source]¶
Construct all netconfig parameters from the provided interface.
Alternatively reset them with respect to that interface if they were already set.
- Parameters:
interface – reference interface for the configuration
- add_interface(interface: VMInterface) None[source]¶
Add an interface to the netconfig.
Perform the necessary registrations and finishing with validation of the interface configuration.
- Parameters:
interface – interface to add to the netconfig
- has_interface(interface: VMInterface) bool[source]¶
Check whether an interface already belongs to the netconfig.
Checking is done through both IP and actual attachment (to counter same IP range netconfigs).
- Parameters:
interface – interface to check in the netconfig
- Returns:
whether the interface is already present in the netconfig
- can_add_interface(interface: VMInterface) bool[source]¶
Check if an interface can be added to the netconfig based on its desired IP address.
Throw exceptions if it is already present or the netmask does not coincide (misconfiguration errors).
- Parameters:
interface – interface to add to the netconfig
- Returns:
whether the interface can be added
- Raises:
exceptions.IndexErrorif interface is already present or incompatible
- validate() None[source]¶
Check for sanity of the netconfigs parameters.
- Raises:
exceptions.TestErrorif the validation fails
- translate_address(ip: str, nat_ip: str) str[source]¶
Return the NAT translated IP of an interface.
Alternatively return the NAT translated IP of an interface masked by a desired network address. :param interface: interface to translate :param nat_ip: NATed IP to use for reference :returns: the translated IP of the interface