コード例 #1
0
 def _source_ovs_bridge(self, iface, ovs_bridge):
     iface.appendChildWithArgs('source', bridge=ovs_bridge)
     iface.appendChildWithArgs('virtualport', type='openvswitch')
     vlan_tag = net_api.net2vlan(self.network)
     if vlan_tag:
         vlan = iface.appendChildWithArgs('vlan')
         vlan.appendChildWithArgs('tag', id=str(vlan_tag))
コード例 #2
0
 def _source_ovs_bridge(self, iface, ovs_bridge):
     iface.appendChildWithArgs('source', bridge=ovs_bridge)
     iface.appendChildWithArgs('virtualport', type='openvswitch')
     vlan_tag = net_api.net2vlan(self.network)
     if vlan_tag:
         vlan = iface.appendChildWithArgs('vlan')
         vlan.appendChildWithArgs('tag', id=str(vlan_tag))
コード例 #3
0
def _bind_iface_to_ovs_bridge(interface, target_ovs_bridge, target_vm_net):
    _set_source_bridge(interface, target_ovs_bridge)
    _set_virtualport(interface)

    vlan_tag = net_api.net2vlan(target_vm_net)
    if vlan_tag:
        _set_vlan(interface, vlan_tag)
コード例 #4
0
def _bind_iface_to_ovs_bridge(interface, target_ovs_bridge, target_vm_net):
    _set_source_bridge(interface, target_ovs_bridge)
    _set_virtualport(interface)

    vlan_tag = net_api.net2vlan(target_vm_net)
    if vlan_tag:
        _set_vlan(interface, vlan_tag)
コード例 #5
0
def fixNetworks(xml_str):
    networks = set(re.findall('(?<=NIC-BRIDGE:)[\w:-]+', xml_str))
    for network in networks:
        ovs_bridge = supervdsm.getProxy().ovs_bridge(network)
        if ovs_bridge:
            new_str = "<source bridge='{bridge}'/>" +  \
                "<virtualport type='openvswitch'/>" \
                .format(bridge=ovs_bridge)
            vlan_tag = net_api.net2vlan(network)
            if vlan_tag:
                new_str = new_str + \
                    "<vlan><tag id='{tag_id}'/></vlan>" \
                    .format(tag_id=str(vlan_tag))
            xml_str = xml_str.replace(
                '<source bridge="NIC-BRIDGE:' + network + '"/>', new_str)
        else:
            xml_str = xml_str.replace('NIC-BRIDGE:' + network, network)
    return xml_str