Change in vdsm[master]: [WIP] hooks: Add Quantum vNIC hook
mkolesni at redhat.com
mkolesni at redhat.com
Wed Jan 16 15:11:53 UTC 2013
Mike Kolesnik has uploaded a new change for review.
Change subject: [WIP] hooks: Add Quantum vNIC hook
......................................................................
[WIP] hooks: Add Quantum vNIC hook
This hook is used to enable Quantum agent to connect a vNIC as it wants,
instead of trying to connect to the bridge that is sent by engine (which
doesn't exist, as the vNIC should be managed by quantum).
Change-Id: I744b83d9c6027bd817e5d4171a77a005611b9818
Signed-off-by: Mike Kolesnik <mkolesni at redhat.com>
---
M configure.ac
M vdsm.spec.in
M vdsm_hooks/Makefile.am
A vdsm_hooks/quantumvnic/Makefile.am
A vdsm_hooks/quantumvnic/before_vm_start.py
5 files changed, 110 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/08/11108/1
diff --git a/configure.ac b/configure.ac
index d48de70..ae447a3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -210,6 +210,7 @@
vdsm_hooks/promisc/Makefile
vdsm_hooks/qos/Makefile
vdsm_hooks/qemucmdline/Makefile
+ vdsm_hooks/quantumvnic/Makefile
vdsm_hooks/scratchpad/Makefile
vdsm_hooks/smbios/Makefile
vdsm_hooks/sriov/Makefile
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 632d315..7560e65 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -356,6 +356,13 @@
%description hook-qos
Hook adds QoS in/out traffic to VMs interfaces
+%package hook-quantumvnic
+Summary: Quantum vNICs support for VDSM
+BuildArch: noarch
+
+%description hook-quantumvnic
+Hook for Quantum vNICs.
+
%package hook-scratchpad
Summary: One time disk creation for VDSM
BuildArch: noarch
@@ -893,6 +900,10 @@
%defattr(-, root, root, -)
%{_libexecdir}/%{vdsm_name}/hooks/before_vm_start/50_qos
+%files hook-quantumvnic
+%defattr(-, root, root, -)
+%{_libexecdir}/%{vdsm_name}/hooks/before_vm_start/50_quantumvnic
+
%files hook-scratchpad
%defattr(-, root, root, -)
%{_libexecdir}/%{vdsm_name}/hooks/before_vm_start/50_scratchpad
diff --git a/vdsm_hooks/Makefile.am b/vdsm_hooks/Makefile.am
index 0e27a98..10869c1 100644
--- a/vdsm_hooks/Makefile.am
+++ b/vdsm_hooks/Makefile.am
@@ -36,6 +36,7 @@
pincpu \
promisc \
qos \
+ quantumvnic \
scratchpad \
smbios \
sriov \
diff --git a/vdsm_hooks/quantumvnic/Makefile.am b/vdsm_hooks/quantumvnic/Makefile.am
new file mode 100644
index 0000000..3364f80
--- /dev/null
+++ b/vdsm_hooks/quantumvnic/Makefile.am
@@ -0,0 +1,31 @@
+#
+# Copyright 2011-2012 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+EXTRA_DIST = \
+ before_vm_start.py
+
+install-data-local:
+ $(MKDIR_P) $(DESTDIR)$(vdsmhooksdir)/before_vm_start
+ $(INSTALL_SCRIPT) $(srcdir)/before_vm_start.py \
+ $(DESTDIR)$(vdsmhooksdir)/before_vm_start/50_quantumvnic
+
+uninstall-local:
+ $(RM) $(DESTDIR)$(vdsmhooksdir)/before_vm_start/50_quantumvnic
+
diff --git a/vdsm_hooks/quantumvnic/before_vm_start.py b/vdsm_hooks/quantumvnic/before_vm_start.py
new file mode 100755
index 0000000..d9391dd
--- /dev/null
+++ b/vdsm_hooks/quantumvnic/before_vm_start.py
@@ -0,0 +1,66 @@
+#!/usr/bin/python
+
+import os
+import sys
+import hooking
+import traceback
+from xml.dom import minidom
+
+def addQuantumVnics(domxml, mac, portid):
+ mac = mac.lower()
+ for iface in domxml.getElementsByTagName('interface'):
+ domMac = iface.getElementsByTagName('mac')[0]
+ domMacAddr = domMac.getAttribute('address').lower()
+
+ if domMacAddr == mac:
+ tapname = 'tap' + portid[:11]
+
+ target = domxml.createElement('target')
+ target.setAttribute('dev', tapname)
+ iface.appendChild(target)
+
+ source = iface.getElementsByTagName('source')[0]
+ source.setAttribute('bridge', ';vdsmdummy;');
+
+def main():
+ QVNIC = 'quantumvnic_'
+
+ domxml = hooking.read_domxml()
+
+ for k, v in os.environ.iteritems():
+ try:
+ if k.startswith(QVNIC):
+ mac = k[len(QVNIC):]
+ sys.stderr.write('%s: %s\n' % (k, v))
+ addQuantumVnics(domxml, mac, v)
+
+ except:
+ sys.stderr.write('ERROR %s\n' % traceback.format_exc())
+ sys.exit(2)
+
+ hooking.write_domxml(domxml)
+
+def test():
+ import xml
+
+ domxml = xml.dom.minidom.parseString("""<?xml version="1.0" encoding="utf-8"?>
+<interfaces>
+ <interface type="bridge">
+ <mac address="00:1a:4a:16:01:51"/>
+ <model type="virtio"/>
+ <source bridge="sample_network"/>
+ </interface>
+ <interface type="bridge">
+ <mac address="00:1a:4a:16:01:b0"/>
+ <model type="virtio"/>
+ <source bridge="ovirtmgmt"/>
+ </interface>
+</interfaces>
+ """)
+ addQuantumVnics(domxml, '00:1a:4a:16:01:51', 'sdfsdfsdf')
+ print domxml.toxml(encoding='utf-8')
+
+if __name__ == '__main__':
+ main()
+# test()
+
--
To view, visit http://gerrit.ovirt.org/11108
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I744b83d9c6027bd817e5d4171a77a005611b9818
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Mike Kolesnik <mkolesni at redhat.com>
More information about the vdsm-patches
mailing list