Esempio n. 1
0
def addOvsHybridVnic(domxml, iface, portId):
    brName = devName("qbr", portId)

    # TODO: Remove this check after bz 1045626 is fixed
    if not deviceExists(brName):
        executeOrExit([EXT_BRCTL, 'addbr', brName])
        executeOrExit([EXT_BRCTL, 'setfd', brName, '0'])
        executeOrExit([EXT_BRCTL, 'stp', brName, 'off'])

    vethBr = devName("qvb", portId)
    vethOvs = devName("qvo", portId)

    # TODO: Remove this check after bz 1045626 is fixed
    if not deviceExists(vethOvs):
        executeOrExit([EXT_IP, 'link', 'add', vethBr, 'type', 'veth', 'peer',
                      'name', vethOvs])
        for dev in [vethBr, vethOvs]:
            executeOrExit([EXT_IP, 'link', 'set', dev, 'up'])
            executeOrExit([EXT_IP, 'link', 'set', dev, 'promisc', 'on'])

        executeOrExit([EXT_IP, 'link', 'set', brName, 'up'])
        executeOrExit([EXT_BRCTL, 'addif', brName, vethBr])

        mac = iface.getElementsByTagName('mac')[0].getAttribute('address')
        executeOrExit([ovs_vsctl.cmd, '--', '--may-exist', 'add-port',
                       INTEGRATION_BRIDGE, vethOvs,
                       '--', 'set', 'Interface', vethOvs,
                       'external-ids:iface-id=%s' % portId,
                       'external-ids:iface-status=active',
                       'external-ids:attached-mac=%s' % mac])

    defineLinuxBridge(domxml, iface, portId, brName)
Esempio n. 2
0
def addOvsHybridVnic(domxml, iface, portId):
    brName = devName("qbr", portId)

    # TODO: Remove this check after bz 1045626 is fixed
    if not deviceExists(brName):
        executeOrExit([EXT_BRCTL, 'addbr', brName])
        executeOrExit([EXT_BRCTL, 'setfd', brName, '0'])
        executeOrExit([EXT_BRCTL, 'stp', brName, 'off'])

    vethBr = devName("qvb", portId)
    vethOvs = devName("qvo", portId)

    # TODO: Remove this check after bz 1045626 is fixed
    if not deviceExists(vethOvs):
        executeOrExit([
            EXT_IP, 'link', 'add', vethBr, 'type', 'veth', 'peer', 'name',
            vethOvs
        ])
        for dev in [vethBr, vethOvs]:
            executeOrExit([EXT_IP, 'link', 'set', dev, 'up'])
            executeOrExit([EXT_IP, 'link', 'set', dev, 'promisc', 'on'])

        executeOrExit([EXT_IP, 'link', 'set', brName, 'up'])
        executeOrExit([EXT_BRCTL, 'addif', brName, vethBr])

        mac = iface.getElementsByTagName('mac')[0].getAttribute('address')
        executeOrExit([
            ovs_vsctl.cmd, '--', '--may-exist', 'add-port', INTEGRATION_BRIDGE,
            vethOvs, '--', 'set', 'Interface', vethOvs,
            'external-ids:iface-id=%s' % portId,
            'external-ids:iface-status=active',
            'external-ids:attached-mac=%s' % mac
        ])

    defineLinuxBridge(domxml, iface, portId, brName)
Esempio n. 3
0
def disconnectVnic(portId):
    brName = devName("qbr", portId)
    vethBr = devName("qvb", portId)
    vethOvs = devName("qvo", portId)

    if deviceExists(brName):
        executeOrExit([EXT_BRCTL, 'delif', brName, vethBr])
        executeOrExit([EXT_IP, 'link', 'set', brName, 'down'])
        executeOrExit([EXT_BRCTL, 'delbr', brName])
        executeOrExit([EXT_OVS_VSCTL, 'del-port', INTEGRATION_BRIDGE, vethOvs])
        executeOrExit([EXT_IP, 'link', 'delete', vethOvs])
Esempio n. 4
0
def disconnectVnic(portId):
    brName = devName("qbr", portId)
    vethBr = devName("qvb", portId)
    vethOvs = devName("qvo", portId)

    if deviceExists(brName):
        executeOrExit([EXT_BRCTL, 'delif', brName, vethBr])
        executeOrExit([EXT_IP, 'link', 'set', brName, 'down'])
        executeOrExit([EXT_BRCTL, 'delbr', brName])
        executeOrExit([ovs_vsctl.cmd, 'del-port', INTEGRATION_BRIDGE, vethOvs])
        executeOrExit([EXT_IP, 'link', 'delete', vethOvs])
Esempio n. 5
0
def addOvsHybridVnic(domxml, iface, portId):
    setUpSecurityGroupVnic(
        iface.getElementsByTagName('mac')[0].getAttribute('address'),
        portId)

    brName = devName("qbr", portId)
    defineLinuxBridge(domxml, iface, portId, brName)
Esempio n. 6
0
def defineLinuxBridge(domxml, iface, portId, brName):
    target = domxml.createElement('target')
    target.setAttribute('dev', devName('tap', portId))
    iface.appendChild(target)

    source = iface.getElementsByTagName('source')[0]
    source.setAttribute('bridge', brName)
Esempio n. 7
0
def defineLinuxBridge(domxml, iface, portId, brName):
    target = domxml.createElement('target')
    target.setAttribute('dev', devName('tap', portId))
    iface.appendChild(target)

    source = iface.getElementsByTagName('source')[0]
    source.setAttribute('bridge', brName)
Esempio n. 8
0
def addOvsHybridVnic(domxml, iface, portId):
    setUpSecurityGroupVnic(
        iface.getElementsByTagName('mac')[0].getAttribute('address'),
        portId)

    brName = devName("qbr", portId)
    defineLinuxBridge(domxml, iface, portId, brName)
Esempio n. 9
0
def disconnectVnic(portId):
    executeOrExit(
        ['/usr/sbin/ip', 'link', 'set',
         devName('tap', portId), 'nomaster'])
Esempio n. 10
0
def disconnectVnic(portId):
    executeOrExit([EXT_BRCTL, 'delif', DUMMY_BRIDGE, devName('tap', portId)])
Esempio n. 11
0
def disconnectVnic(portId):
    executeOrExit([EXT_BRCTL, 'delif', DUMMY_BRIDGE, devName('tap', portId)])
Esempio n. 12
0
def disconnectVnic(portId):
    executeOrExit([
        '/usr/sbin/ip', 'link', 'set', devName('tap', portId), 'nomaster'])
Esempio n. 13
0
def disconnectVnic(portId):
    executeOrExit([EXT_BRCTL, "delif", DUMMY_BRIDGE, devName("tap", portId)])