Change in vdsm[master]: hook: add one more dummy device
danken at redhat.com
danken at redhat.com
Thu Jun 19 07:02:03 UTC 2014
Dan Kenigsberg has uploaded a new change for review.
Change subject: hook: add one more dummy device
......................................................................
hook: add one more dummy device
A common hack (cf. [1]) that allows defining a host-only network in Engine
requires the relevant host to have a free dummy device per host-only
network.
This hook makes sure that at least one free dummy device exists on the
host when Engine polls its network connectivity.
[1] http://lists.ovirt.org/pipermail/users/2013-August/015901.html
Change-Id: I52e10e0176235737549c6bfd57a7dc174f4f4c07
Signed-off-by: Dan Kenigsberg <danken at redhat.com>
---
M configure.ac
M debian/Makefile.am
M debian/control
A debian/vdsm-hook-onemoredummy.docs
A debian/vdsm-hook-onemoredummy.install
M vdsm.spec.in
M vdsm_hooks/Makefile.am
A vdsm_hooks/onemoredummy/Makefile.am
A vdsm_hooks/onemoredummy/before_get_caps.py
A vdsm_hooks/onemoredummy/sudoers
10 files changed, 150 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/21/28921/1
diff --git a/configure.ac b/configure.ac
index 885572e..0ce068e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -298,6 +298,7 @@
vdsm_hooks/nestedvt/Makefile
vdsm_hooks/numa/Makefile
vdsm_hooks/openstacknet/Makefile
+ vdsm_hooks/onemoredummy/Makefile
vdsm_hooks/pincpu/Makefile
vdsm_hooks/promisc/Makefile
vdsm_hooks/qemucmdline/Makefile
diff --git a/debian/Makefile.am b/debian/Makefile.am
index 00b0d33..cc7d67e 100644
--- a/debian/Makefile.am
+++ b/debian/Makefile.am
@@ -65,6 +65,8 @@
vdsm-hook-numa.install \
vdsm-hook-openstacknet.docs \
vdsm-hook-openstacknet.install \
+ vdsm-hook-onemoredummy.docs \
+ vdsm-hook-onemoredummy.install \
vdsm-hook-pincpu.docs \
vdsm-hook-pincpu.install \
vdsm-hook-promisc.docs \
diff --git a/debian/control b/debian/control
index 3a1154a..2436c6d 100644
--- a/debian/control
+++ b/debian/control
@@ -176,6 +176,13 @@
To enable this hook on your host, set vars.fake_kvm_support=True in your
/etc/vdsm/vdsm.conf before adding the host to ovirt-Engine.
+Package: vdsm-hook-onemoredummy
+Architecture: all
+Depends: ${shlibs:Depends}, ${misc:Depends}, python (>=2.7.3), vdsm (>= ${source:Version})
+Description: Create and report a free dummy network device
+ VDSM hook used to create and report a free dummy network device, so that
+ Engine users can define host-only networks on top of it.
+
Package: vdsm-hook-directlun
Architecture: all
Depends: ${shlibs:Depends}, ${misc:Depends}, python (>=2.7.3), vdsm (>= ${source:Version})
diff --git a/debian/vdsm-hook-onemoredummy.docs b/debian/vdsm-hook-onemoredummy.docs
new file mode 100644
index 0000000..5ecd9c6
--- /dev/null
+++ b/debian/vdsm-hook-onemoredummy.docs
@@ -0,0 +1 @@
+COPYING
diff --git a/debian/vdsm-hook-onemoredummy.install b/debian/vdsm-hook-onemoredummy.install
new file mode 100644
index 0000000..43df55b
--- /dev/null
+++ b/debian/vdsm-hook-onemoredummy.install
@@ -0,0 +1 @@
+usr/libexec/vdsm/hooks/before_get_caps/50_onemoredummy
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 2e9f668..cfaa5f9 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -374,6 +374,15 @@
VDSM hook to use vhostmd per VM according to Virtualization Manager requests.
%endif
+%package hook-onemoredummy
+Summary: Create and report a free dummy network device
+BuildArch: noarch
+Requires: %{name}
+
+%description hook-onemoredummy
+VDSM hook used to create and report a free dummy network device, so that Engine
+users can define host-only networks on top of it.
+
%package hook-faqemu
Summary: Fake qemu process for VDSM quality assurance
BuildArch: noarch
@@ -1454,6 +1463,12 @@
%doc COPYING
%{_libexecdir}/%{vdsm_name}/hooks/before_vm_start/10_faqemu
+%files hook-onemoredummy
+%defattr(-, root, root, -)
+%doc COPYING
+%{_libexecdir}/%{vdsm_name}/hooks/before_get_caps/50_onemoredummy
+%{_sysconfdir}/sudoers.d/50_vdsm_hook_onemoredummy
+
%if 0%{?with_gluster}
%files gluster
%defattr(-, root, root, -)
diff --git a/vdsm_hooks/Makefile.am b/vdsm_hooks/Makefile.am
index 5e4d731..bd6c883 100644
--- a/vdsm_hooks/Makefile.am
+++ b/vdsm_hooks/Makefile.am
@@ -18,7 +18,7 @@
# Refer to the README and COPYING files for full details of the license
#
-SUBDIRS = ethtool_options faqemu vhostmd qemucmdline openstacknet
+SUBDIRS = ethtool_options faqemu onemoredummy vhostmd qemucmdline openstacknet
include $(top_srcdir)/build-aux/Makefile.subs
diff --git a/vdsm_hooks/onemoredummy/Makefile.am b/vdsm_hooks/onemoredummy/Makefile.am
new file mode 100644
index 0000000..eb452da
--- /dev/null
+++ b/vdsm_hooks/onemoredummy/Makefile.am
@@ -0,0 +1,45 @@
+#
+# Copyright 2014 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
+#
+
+include $(top_srcdir)/build-aux/Makefile.subs
+
+CLEANFILES = \
+ config.log
+
+EXTRA_DIST = \
+ before_get_caps.py \
+ sudoers \
+ $(NULL)
+
+install-data-local: install-data-sudoers
+ $(MKDIR_P) $(DESTDIR)$(vdsmhooksdir)/before_get_caps
+ $(INSTALL_SCRIPT) $(srcdir)/before_get_caps.py \
+ $(DESTDIR)$(vdsmhooksdir)/before_get_caps/50_onemoredummy
+
+uninstall-local: uninstall-data-sudoers
+ $(RM) $(DESTDIR)$(vdsmhooksdir)/before_get_caps/50_onemoredummy
+
+install-data-sudoers:
+ $(MKDIR_P) $(DESTDIR)$(sysconfdir)/sudoers.d
+ $(INSTALL_DATA) $(srcdir)/sudoers \
+ $(DESTDIR)$(sysconfdir)/sudoers.d/50_vdsm_hook_onemoredummy
+
+uninstall-data-sudoers:
+ $(RM) $(DESTDIR)$(sysconfdir)/sudoers.d/50_vdsm_hook_onemoredummy
diff --git a/vdsm_hooks/onemoredummy/before_get_caps.py b/vdsm_hooks/onemoredummy/before_get_caps.py
new file mode 100755
index 0000000..9b9a13b
--- /dev/null
+++ b/vdsm_hooks/onemoredummy/before_get_caps.py
@@ -0,0 +1,76 @@
+#!/usr/bin/python
+#
+# Copyright 2014 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
+#
+
+"""
+This hook creates an extra dummy network device and reports it back to Engine.
+This allows Engine to define a confined (host-only) network on top of it.
+"""
+
+import sys
+import traceback
+
+import hooking
+
+from vdsm.ipwrapper import getLinks
+from vdsm import netinfo
+
+_DUMMY_PREFIX = 'dummy_'
+_DUMMY_PREFIX_LEN = len(_DUMMY_PREFIX)
+
+
+def add_dummy(dry_run=False):
+ dummies = frozenset(
+ link for link in getLinks()
+ if link.isDUMMY() and link.name.startswith(_DUMMY_PREFIX)
+ and link.name[_DUMMY_PREFIX_LEN:].isdigit()
+ )
+ if all(netinfo.ifaceUsed(link.name) for link in dummies):
+ dummy_nums = [
+ int(link.name[_DUMMY_PREFIX_LEN:])
+ for link in dummies
+ ] + [0]
+
+ next_dummy = _DUMMY_PREFIX + str(1 + max(dummy_nums))
+
+ if not dry_run:
+ hooking.execCmd((
+ 'ip', 'link', 'add', next_dummy,
+ 'type', 'dummy'), sudo=True)
+ else:
+ print "would add", next_dummy
+
+
+def test():
+ add_dummy(dry_run=True)
+
+
+def main():
+ add_dummy()
+
+if __name__ == '__main__':
+ if '--test' in sys.argv:
+ test()
+ else:
+ try:
+ main()
+ except:
+ hooking.exit_hook('[unexpected error]: %s\n'
+ % traceback.format_exc())
diff --git a/vdsm_hooks/onemoredummy/sudoers b/vdsm_hooks/onemoredummy/sudoers
new file mode 100644
index 0000000..b9aafc7
--- /dev/null
+++ b/vdsm_hooks/onemoredummy/sudoers
@@ -0,0 +1 @@
+vdsm ALL=(ALL) NOPASSWD: /sbin/ip link add dummy* type dummy
--
To view, visit http://gerrit.ovirt.org/28921
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I52e10e0176235737549c6bfd57a7dc174f4f4c07
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken at redhat.com>
More information about the vdsm-patches
mailing list