Mike Kolesnik has uploaded a new change for review. Change subject: [WIP] hooks: Add OVS support to Quantum vNIC hook ......................................................................
[WIP] hooks: Add OVS support to Quantum vNIC hook The hook will now support connecting a vNIC both to a standard linux bridge, and an OVS bridge. The hook should work in tandem with the corresponding Quantum plugin: Linux Bridge or OVS plugin. Change-Id: Ieded0281b8c5b89ad9380881a93d408e09624f38 Signed-off-by: Mike Kolesnik <[email protected]> --- M vdsm_hooks/quantumvnic/before_vm_start.py 1 file changed, 28 insertions(+), 8 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/10/15410/1 diff --git a/vdsm_hooks/quantumvnic/before_vm_start.py b/vdsm_hooks/quantumvnic/before_vm_start.py index acf4fcf..bd110a6 100755 --- a/vdsm_hooks/quantumvnic/before_vm_start.py +++ b/vdsm_hooks/quantumvnic/before_vm_start.py @@ -5,6 +5,7 @@ import hooking import traceback +from vdsm.config import config from xml.dom import minidom from vdsm.netinfo import DUMMY_BRIDGE @@ -30,6 +31,29 @@ connected to Quantum.''' +def configureLinuxBridgeVnic(domxml, iface, portId): + target = domxml.createElement('target') + tapName = ('tap' + portId)[:DEV_MAX_LENGTH] + target.setAttribute('dev', tapName) + iface.appendChild(target) + + source = iface.getElementsByTagName('source')[0] + source.setAttribute('bridge', DUMMY_BRIDGE) + + +def configureOvsVnic(domxml, iface, portId): + INTEGRATION_BRIDGE = config.get('quantumvnic_hook', 'integration_bridge') + source = iface.getElementsByTagName('source')[0] + source.setAttribute('bridge', INTEGRATION_BRIDGE) + + virtualPort = domxml.createElement('virtualport') + virtualPort.setAttribute('type', 'openvswitch') + virtualPortParameters = domxml.createElement('parameters') + virtualPortParameters.setAttribute('interfaceid', portId) + virtualPort.appendChild(virtualPortParameters) + iface.appendChild(virtualPort) + + def addQuantumVnics(domxml, mac, portId): mac = mac.lower() for iface in domxml.getElementsByTagName('interface'): @@ -37,14 +61,10 @@ domMacAddr = domMac.getAttribute('address').lower() if domMacAddr == mac: - tapName = ('tap' + portId)[:DEV_MAX_LENGTH] - - target = domxml.createElement('target') - target.setAttribute('dev', tapName) - iface.appendChild(target) - - source = iface.getElementsByTagName('source')[0] - source.setAttribute('bridge', DUMMY_BRIDGE) + if config.get('quantumvnic_hook', 'plugin').lower() == "ovs": + configureOvsVnic(domxml, iface, portId) + else: + configureLinuxBridgeVnic(domxml, iface, portId) def main(): -- To view, visit http://gerrit.ovirt.org/15410 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ieded0281b8c5b89ad9380881a93d408e09624f38 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Mike Kolesnik <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
