lib/virt_autotest/virtual_network_utils.pm

config_domain_resolver

Create domain resolver and prevent it from being overwritten automatically. Other arguments include domain resolver configuration file resolvconf, resolver address resolvip and domain name domainname.

write_network_bridge_device_config

write_network_bridge_device_config(name => $name [, ipaddr => $ipaddr,
    bootproto => $bootproto, startmode => $startmode, zone => $zone,
    bridge_type => $bridge_type, _bridge_ports => $bridge_ports,
    bridge_stp => $bridge_stp, bridge_forwarddelay => $bridge_forwarddelay,
    backup_folder => $backup_folder])

Write network device settings to conventional /etc/sysconfig/network/ifcfg-* or /etc/NetworkManager/system-connections/*.nmconnection depends on whether system network is managed by NetworkManager or not. The supported arguments are listed out as below: $ipaddr: IP address/mask length pair of the interface $name: Identifier of the interface $bootproto: DHCP automatic or manual configuration, 'static', 'dhcp' or 'none' $startmode: Auto start up or connection: 'auto', 'manual' or 'off' $zone: The trust level of this network connection $bridge_type: 'master' or 'slave' to indicate master or slave interface $bridge_port: Specify interface's master or slave interface name $bridge_stp: 'on' or 'off' to turn stp on or off $bridge_forwarddelay: The stp forwarding delay in seconds If $ipaddr given is empty, it means there is no associated specific ip address to this interface which might be attached to another bridge interface or will not be assigned one ip address from dhcp, so set $ipaddr to '0.0.0.0'.If $ipaddr given is non-empty but not in ip address format,for example, 'host',it means the interface will not use a ip address from pre-defined subnet and will automically accept dhcp ip address from public facing host network.

write_network_bridge_device_ifcfg

write_network_bridge_device_ifcfg(name => $name [, ipaddr => $ipaddr,
    name => $name, bootproto => $bootproto, startmode => $startmode,
    zone => $zone, bridge_type => $bridge_type, bridge_ports => $bridge_ports,
    bridge_stp => $bridge_stp, bridge_forwarddelay => $bridge_forwarddelay,
    backup_folder => $backup_folder])

Write bridge device config file to /etc/sysconfig/network/ifcfg-*. Please refer to https://github.com/openSUSE/sysconfig/blob/master/config/ifcfg.template for config file content. This subroutine is supposed to be used by calling subroutine write_network_bridge_device_config.

write_network_bridge_device_nmconnection

write_network_bridge_device_nmconnection(name => $name [, ipaddr => $ipaddr,
    name => $name, bootproto => $bootproto, startmode => $startmode,
    zone => $zone, bridge_type => $bridge_type, bridge_ports => $bridge_ports,
    bridge_stp => $bridge_stp, bridge_forwarddelay => $bridge_forwarddelay,
    backup_folder => $backup_folder])

Write bridge device config file to /etc/NetworkManager/system-connections/*. NM settings are a little bit different from ifcfg settings, but there are definite mapping between them. So translation from well-known and default ifcfg settings to NM settings is necessary. Please refer to nm-settings explanation as below: https://developer-old.gnome.org/NetworkManager/stable/nm-settings-keyfile.html. This subroutine is supposed to be used by calling write_network_bridge_device_config.

activate_network_bridge_device

activate_network_bridge_device(host_device => $host_device,
    bridge_device => $bridge_device, network_mode => $network_mode)

Activate guest network bridge device by using wicked or NetworkManager depends on system configuration. And also validate whether activation is successful or not.

config_virtual_network_device

config_virtual_network_device(driver => 'driver', transport => 'transport',
    user => 'user', host => 'host', port => 'port', path => 'path',
    extra => 'extra', fwdmode => 'fwdmode', name => 'name', device => 'device',
    ipaddr => 'ip', netmask => 'mask', startaddr => 'start', endaddr => 'end',
    domainname => 'domainname', confdir => 'confdir')

Create virtual network to be used. This subroutine also calls construct_uri to determine the desired URI to be connected if the interested party is not localhost. Please refer to subroutine construct_uri for the arguments related. The network to be created based on arguments fwdmode, name, device, ipaddr, netmask, startaddr , endaddr and domainname. The configuration file is constructed from arguments name and confdir.

check_guest_network_config

Check and obtain guest network configuration. Guest xml config contains enough information about network to which guest connects on boot, for example: <interface type="network"> <mac address="00:16:3e:4f:5a:35"/> <source network="vn_nat_vbrXXX"/> </interface> or <interface type='bridge'> <mac address='52:54:00:70:9d:b2'/> <source bridge='br123'/> <model type='virtio'/> <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/> </interface> Interface type, source network/bridge name and model type are those useful ones determine the network, they will be stored in guest_matrix{guest}{nettype}, guest_matrix{guest}{netname} and guest_matrix{guest}{netmode}. In order to obtain netmode conveniently and consistently, netname should take the form of "vn_" + "nat/route/host" + "_other_strings" if virtual network to be used. Addtionally, guest_matrix{guest}{macaddr} is also upated by querying domiflist and ip address guest_matrix{guest}{ipaddr} can also be obtained from lib/virt_autotest/common.pm if static ip address is being used. The main arguments are guest to be checked and directory in which guest xml config is stored. This subroutine also calls construct_uri to determine the desired URI to be connected if the interested party is not localhost. Please refer to subroutine construct_uri for the arguments related. Argument guest specifies list of guests separated by space to be handled, matrix specifies address of guest matrix to be filled up after obtainsing information about a guest. If matrix is not specified, a local matrix address will be used and returned.

check_guest_network_address

Check and obtain guest ip address. If static ip address is being used, there is no need to check it anymore. If guest uses bridge device directly, its ip address can be obtained by querying journal log or scanning subnet by using nmap (if host bridge device br0 is being used directly) with mac address. If guest uses virtual network created by virsh, its ip address can be obtained by querying dhcp leases of the virtual network or scanning subnet by using nmap (if host bridge device is being used in the virtual network directly) with mac address. The main arguments is guest to be checked. This subroutine also calls construct_uri to determine the desired URI to be connected if the interested party is not localhost. Please refer to subroutine construct_uri for the arguments related. Argument guest specifies list of guests separated by space to be handled, matrix specifies address of guest matrix to be filled up after obtainsing information about a guest. If matrix is not specified, a local matrix address will be used and returned.

config_network_device_policy

config_network_device_policy(logdir => 'folder path', name => 'distiguish name',
    netdev => 'network device')

Stop firewall/apparmor, loosen iptables rules and enable forwarding globally and on all default route devices and netdev. Please specify logdir in which applied rules will be stored, name which will be appened to form distinguish scirpt name and netdev to be concerned.