Change in vdsm[master]: hooks: Add a hook to configure IPv6 networking through custo...

osvoboda at redhat.com osvoboda at redhat.com
Tue Oct 28 19:06:52 UTC 2014


Ondřej Svoboda has uploaded a new change for review.

Change subject: hooks: Add a hook to configure IPv6 networking through custom properties
......................................................................

hooks: Add a hook to configure IPv6 networking through custom properties

The hook currently forwards 'ipv6addr' and 'ipv6gateway' properties
the API. More options will probably follow ('ipv6autoconf' and 'dhcpv6').

Change-Id: Ia0e427b182a1742999eeb14e004209b511668ba2
Signed-off-by: Ondřej Svoboda <osvoboda at redhat.com>
---
M debian/Makefile.am
A debian/vdsm-hook-ipv6.docs
A debian/vdsm-hook-ipv6.install
M vdsm.spec.in
M vdsm_hooks/Makefile.am
A vdsm_hooks/ipv6/Makefile.am
A vdsm_hooks/ipv6/README
A vdsm_hooks/ipv6/ipv6.py
8 files changed, 110 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/71/34571/1

diff --git a/debian/Makefile.am b/debian/Makefile.am
index 00b0d33..770a4c4 100644
--- a/debian/Makefile.am
+++ b/debian/Makefile.am
@@ -55,6 +55,8 @@
     vdsm-hook-hostusb.install \
     vdsm-hook-hugepages.docs \
     vdsm-hook-hugepages.install \
+    vdsm-hook-ipv6.docs \
+    vdsm-hook-ipv6.install \
     vdsm-hook-isolatedprivatevlan.docs \
     vdsm-hook-isolatedprivatevlan.install \
     vdsm-hook-macspoof.docs \
diff --git a/debian/vdsm-hook-ipv6.docs b/debian/vdsm-hook-ipv6.docs
new file mode 100644
index 0000000..5ecd9c6
--- /dev/null
+++ b/debian/vdsm-hook-ipv6.docs
@@ -0,0 +1 @@
+COPYING
diff --git a/debian/vdsm-hook-ipv6.install b/debian/vdsm-hook-ipv6.install
new file mode 100644
index 0000000..8df9886
--- /dev/null
+++ b/debian/vdsm-hook-ipv6.install
@@ -0,0 +1 @@
+usr/libexec/vdsm/hooks/before_network_setup/10_ipv6
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 4b49a8e..f4c7772 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -631,6 +631,15 @@
 %description hook-vmdisk
 Hook adds additional disk image for a VM (raw or qcow2)
 
+%package hook-ipv6
+Summary:        Set IPv6 configuration through custom network properties
+BuildArch:      noarch
+Requires:       %{name} = %{version}-%{release}
+
+%description hook-ipv6
+VDSM hook used for applying IPv6 configuration through custom network
+properties
+
 %if 0%{?with_gluster}
 %package gluster
 Summary:        Gluster Plugin for VDSM
@@ -1384,6 +1393,10 @@
 %{_libexecdir}/%{vdsm_name}/hooks/before_vm_migrate_destination/50_hugepages
 %{_libexecdir}/%{vdsm_name}/hooks/after_vm_destroy/50_hugepages
 
+%files hook-ipv6
+%defattr(-, root, root, -)
+%{_libexecdir}/%{vdsm_name}/hooks/before_network_setup/10_ipv6
+
 %files hook-isolatedprivatevlan
 %defattr(-, root, root, -)
 %{_libexecdir}/%{vdsm_name}/hooks/before_vm_start/50_isolatedprivatevlan
diff --git a/vdsm_hooks/Makefile.am b/vdsm_hooks/Makefile.am
index c68076e..0add342 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 macspoof
+SUBDIRS = ethtool_options faqemu ipv6 macspoof openstacknet qemucmdline vhostmd
 
 include $(top_srcdir)/build-aux/Makefile.subs
 
diff --git a/vdsm_hooks/ipv6/Makefile.am b/vdsm_hooks/ipv6/Makefile.am
new file mode 100644
index 0000000..53d5c65
--- /dev/null
+++ b/vdsm_hooks/ipv6/Makefile.am
@@ -0,0 +1,30 @@
+#
+# 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
+#
+
+EXTRA_DIST = \
+	ipv6.py
+
+install-data-local:
+	$(MKDIR_P) $(DESTDIR)$(vdsmhooksdir)/before_network_setup
+	$(INSTALL_SCRIPT) $(srcdir)/ipv6.py \
+		$(DESTDIR)$(vdsmhooksdir)/before_network_setup/10_ipv6
+
+uninstall-local:
+	$(RM) $(DESTDIR)$(vdsmhooksdir)/before_network_setup/10_ipv6
diff --git a/vdsm_hooks/ipv6/README b/vdsm_hooks/ipv6/README
new file mode 100644
index 0000000..67d23cc
--- /dev/null
+++ b/vdsm_hooks/ipv6/README
@@ -0,0 +1,12 @@
+ipv6 vdsm hook
+=================================
+This hook allows the user to pass IPv6 configuration for networks to VDSM.
+
+Requirements:
+* oVirt-3.5 (?started supporting custom properties?)
+
+Usage:
+In the oVirt UI edit custom network properties and, for the keys 'ipv6addr'
+and 'ipv6gateway'
+set the command line parameters that one would pass to the *** command
+line application.
diff --git a/vdsm_hooks/ipv6/ipv6.py b/vdsm_hooks/ipv6/ipv6.py
new file mode 100644
index 0000000..82af008
--- /dev/null
+++ b/vdsm_hooks/ipv6/ipv6.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env 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
+#
+import hooking
+import traceback
+
+
+def main():
+    """Forward IPv6 configuration from the network 'custom' properties
+       to VDSM API."""
+    setup_nets_config = hooking.read_json()
+    for network, attrs in setup_nets_config['request']['networks'].items():
+        if 'remove' in attrs:
+            continue
+        elif 'custom' in attrs:
+            _process_network(network, attrs)
+
+
+def _process_network(network, attrs):
+    """Add an IPv6 address and a gateway to the network."""
+    ipv6addr = attrs['custom'].get('ipv6addr')
+    if ipv6addr is not None:
+        attrs['ipv6addr'] = ipv6addr
+    ipv6gateway = attrs['custom'].get('ipv6gateway')
+    if ipv6gateway is not None:
+        attrs['ipv6gateway'] = ipv6gateway
+
+
+if __name__ == '__main__':
+    try:
+        main()
+    except:
+        hooking.exit_hook('ipv6 hook: [unexpected error]: %s\n' %
+                          traceback.format_exc())


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia0e427b182a1742999eeb14e004209b511668ba2
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ondřej Svoboda <osvoboda at redhat.com>


More information about the vdsm-patches mailing list