Change in vdsm[master]: [WIP] hooks: Add Quantum vNIC hook

mkolesni at redhat.com mkolesni at redhat.com
Thu May 23 12:20:44 UTC 2013


Mike Kolesnik has posted comments on this change.

Change subject: [WIP] hooks: Add Quantum vNIC hook
......................................................................


Patch Set 2: (6 inline comments)

....................................................
File vdsm/hooking.py
Line 62:     error stream. A newline will be printed at the end.
Line 63:     The default return code is 2 for signaling that an error occurred.
Line 64:     """
Line 65:     sys.stderr.write(message)
Line 66:     sys.stderr.write("\n")
Done


....................................................
File vdsm_hooks/quantumvnic/before_vm_start.py
Line 7: 
Line 8: from xml.dom import minidom
Line 9: 
Line 10: QVNIC_PREFIX = 'quantumvnic_'
Line 11: DUMMY_BRIDGE = ';vdsmdummy;'
Done
Line 12: DEV_MAX_LENGTH = 15
Line 13: 
Line 14: '''
Line 15: Openstack Quantum Hook


Line 21: vNIC to a dummy bridge, and it is the agent's responsibility to swap it to the
Line 22: Quantum bridge.
Line 23: 
Line 24: Syntax:
Line 25:     { 'quantumvnic_MAC1': 'port id', 'quantumvnic_MAC2': 'port_id', ... }
I am waiting for per-device custom properties, so I will stick to this design as for now..

Final design will use the per-device properties and not this awful API.
Line 26: Where:
Line 27:     MACn should be replaced with the MAC addresses of the virtual NICs to be
Line 28:     connected to Quantum.'''
Line 29: 


Line 34:         domMac = iface.getElementsByTagName('mac')[0]
Line 35:         domMacAddr = domMac.getAttribute('address').lower()
Line 36: 
Line 37:         if domMacAddr == mac:
Line 38:             tapName = ('tap' + portId)[:DEV_MAX_LENGTH]
Done
Line 39: 
Line 40:             target = domxml.createElement('target')
Line 41:             target.setAttribute('dev', tapName)
Line 42:             iface.appendChild(target)


Line 41:             target.setAttribute('dev', tapName)
Line 42:             iface.appendChild(target)
Line 43: 
Line 44:             source = iface.getElementsByTagName('source')[0]
Line 45:             source.setAttribute('bridge', DUMMY_BRIDGE)
This is from the 'ethernet' type description:

"Provides a means for the administrator to execute an arbitrary script to connect the guest's network to the LAN. The guest will have a tun device created with a name of vnetN, which can also be overridden with the <target> element. After creating the tun device a shell script will be run which is expected to do whatever host network integration is required. By default this script is called /etc/qemu-ifup but can be overridden."

This will unfortunately not work here, since libvirt expects this script and if not found the VM will fail to start.
We are waiting for a solution from libvirt, ATM a hack is needed in the Quantum Linux Bridge agent for it indeed to work, otherwise it would fail since the tap is already connected to a bridge.

If you have a better solution than this in mind, I would be happy to hear it.
What we need is an ability to create a tap device not connected to anything (also necessary in other features, and in Nova).
Line 46: 
Line 47: 
Line 48: def main():
Line 49:     domxml = hooking.read_domxml()


Line 82: 
Line 83: if __name__ == '__main__':
Line 84:     try:
Line 85:         main()
Line 86: #         test()
Actually Dan asked me to write the main in such a way that the hook can be 'dry-run' for testing.
If you have a suggestion I would be happy to hear it.
Line 87:     except:
Line 88:         hooking.exit_hook('quantumvnic hook: [unexpected error]: %s\n' %


--
To view, visit http://gerrit.ovirt.org/11108
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I744b83d9c6027bd817e5d4171a77a005611b9818
Gerrit-PatchSet: 2
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Mike Kolesnik <mkolesni at redhat.com>
Gerrit-Reviewer: Alon Bar-Lev <alonbl at redhat.com>
Gerrit-Reviewer: Antoni Segura Puimedon <asegurap at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Livnat Peer <lpeer at redhat.com>
Gerrit-Reviewer: Mark Wu <wudxw at linux.vnet.ibm.com>
Gerrit-Reviewer: Mike Kolesnik <mkolesni at redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server


More information about the vdsm-patches mailing list