def _bind_iface_to_bridge(interface, target_vm_nets_by_vnic_mac): elem_macaddr = interface.find('mac') mac_addr = elem_macaddr.get('address') target_vm_net = target_vm_nets_by_vnic_mac[mac_addr] target_ovs_bridge = net_api.ovs_bridge(target_vm_net) if target_ovs_bridge: _bind_iface_to_ovs_bridge(interface, target_ovs_bridge, target_vm_net) else: _bind_iface_to_linux_bridge(interface, target_vm_net)
def _bind_iface_to_bridge(interface, target_vm_conf_by_mac): elem_macaddr = interface.find('mac') mac_addr = elem_macaddr.get('address') target_conf = target_vm_conf_by_mac[mac_addr] if _protected_customized_interface(target_conf): return target_vm_net = target_conf['network'] target_ovs_bridge = net_api.ovs_bridge(target_vm_net) if target_ovs_bridge: _bind_iface_to_ovs_bridge(interface, target_ovs_bridge, target_vm_net) else: _bind_iface_to_linux_bridge(interface, target_vm_net)
def _set_graphics(devices, target_vm_conf): # TODO: Support VMs with multiple <graphics> sections. graphics = devices.find('graphics') if graphics is None: return graphics_listen = graphics.find('listen') target_display_network, target_display_ip = _vmconf_display(target_vm_conf) if net_api.ovs_bridge(target_display_network): graphics_listen.attrib.pop('network', None) graphics_listen.set('type', 'address') graphics_listen.set('address', target_display_ip) else: libvirt_network = net_api.netname_o2l(target_display_network) graphics_listen.attrib.pop('address', None) graphics_listen.set('type', 'network') graphics_listen.set('network', libvirt_network)