Change in vdsm[master]: net: native ovs [1]: ovs switch skeleton
phoracek at redhat.com
phoracek at redhat.com
Sun Mar 27 14:45:58 UTC 2016
Petr Horáček has uploaded a new change for review.
Change subject: net: native ovs [1]: ovs switch skeleton
......................................................................
net: native ovs [1]: ovs switch skeleton
Introduce skeleton of OVS switch.
Change-Id: Ic056fcf8c0d36625328a90a339d4a09658683056
Bug-Url: https://bugzilla.redhat.com/1195208
Signed-off-by: Petr Horáček <phoracek at redhat.com>
---
M configure.ac
M lib/vdsm/network/Makefile.am
M lib/vdsm/network/netswitch.py
A lib/vdsm/network/ovs/Makefile.am
A lib/vdsm/network/ovs/__init__.py
A lib/vdsm/network/ovs/switch.py
M vdsm.spec.in
7 files changed, 152 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/08/55308/1
diff --git a/configure.ac b/configure.ac
index 3307507..30ece7e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -360,6 +360,7 @@
lib/vdsm/network/Makefile
lib/vdsm/network/configurators/Makefile
lib/vdsm/network/ip/Makefile
+ lib/vdsm/network/ovs/Makefile
lib/vdsm/rpc/Makefile
lib/vdsm/storage/Makefile
lib/vdsm/tc/Makefile
diff --git a/lib/vdsm/network/Makefile.am b/lib/vdsm/network/Makefile.am
index 875ad2b..cc8ba64 100644
--- a/lib/vdsm/network/Makefile.am
+++ b/lib/vdsm/network/Makefile.am
@@ -17,7 +17,7 @@
# Refer to the README and COPYING files for full details of the license
#
-SUBDIRS = configurators ip
+SUBDIRS = configurators ip ovs
include $(top_srcdir)/build-aux/Makefile.subs
diff --git a/lib/vdsm/network/netswitch.py b/lib/vdsm/network/netswitch.py
index d560784..78d4b45 100644
--- a/lib/vdsm/network/netswitch.py
+++ b/lib/vdsm/network/netswitch.py
@@ -18,20 +18,67 @@
#
from __future__ import absolute_import
+import six
+
from vdsm.netinfo.cache import (libvirtNets2vdsm, get as netinfo_get,
CachingNetInfo)
from vdsm.netinfo import networks as libvirt_nets
+from vdsm.netconfpersistence import RunningConfig
from . import connectivity
from . import legacy_switch
+from . import errors as ne
+from .errors import ConfigNetworkError
+from .ovs import switch as ovs_switch
+
+
+def _split_legacy_ovs(networks, bondings):
+ """TODO: Use something smarter."""
+ legacy_nets = {}
+ ovs_nets = {}
+ legacy_bonds = {}
+ ovs_bonds = {}
+
+ running_config = RunningConfig()
+
+ for net, attrs in six.iteritems(networks):
+ if (('remove' in attrs and net in running_config.networks and
+ ovs_switch.is_ovs_net(running_config.networks[net])) or
+ ovs_switch.is_ovs_net(attrs)):
+ ovs_nets[net] = attrs
+ else:
+ legacy_nets[net] = attrs
+ for bond, attrs in six.iteritems(bondings):
+ if (('remove' in attrs and bond in running_config.bonds and
+ ovs_switch.is_ovs_bond(running_config.bonds[bond])) or
+ ovs_switch.is_ovs_bond(attrs)):
+ ovs_bonds[bond] = attrs
+ else:
+ legacy_bonds[bond] = attrs
+ return legacy_nets, ovs_nets, legacy_bonds, ovs_bonds
def validate(networks, bondings):
- legacy_switch.validate_network_setup(networks, bondings)
+ legacy_nets, ovs_nets, legacy_bonds, ovs_bonds = \
+ _split_legacy_ovs(networks, bondings)
+
+ legacy = legacy_nets or legacy_bonds
+ ovs = ovs_nets or ovs_bonds
+ if legacy and ovs:
+ raise ConfigNetworkError(
+ ne.ERR_BAD_PARAMS,
+ 'Cannot mix OVS and legacy networks in one networkSetup.')
+
+ legacy_switch.validate_network_setup(legacy_nets, legacy_bonds)
+ ovs_switch.validate_network_setup(ovs_nets, legacy_bonds)
def setup(networks, bondings, options, in_rollback):
+ legacy_nets, ovs_nets, legacy_bonds, ovs_bonds = \
+ _split_legacy_ovs(networks, bondings)
+
_setup_legacy(networks, bondings, options, in_rollback)
+ _setup_ovs(networks, bondings, options, in_rollback)
def _setup_legacy(networks, bondings, options, in_rollback):
@@ -53,3 +100,9 @@
bondings, _netinfo)
connectivity.check(options)
+
+
+def _setup_ovs(networks, bondings, options, in_rollback):
+ with ovs_switch.rollback_manager(in_rollback) as running_config:
+ ovs_switch.setup(networks, bondings, running_config)
+ connectivity.check(options)
diff --git a/lib/vdsm/network/ovs/Makefile.am b/lib/vdsm/network/ovs/Makefile.am
new file mode 100644
index 0000000..b061e0c
--- /dev/null
+++ b/lib/vdsm/network/ovs/Makefile.am
@@ -0,0 +1,27 @@
+# Copyright 2016 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
+
+vdsmnetworkovsdir = $(vdsmpylibdir)/network/ovs
+
+dist_vdsmnetworkovs_PYTHON = \
+ __init__.py \
+ switch.py \
+ $(NULL)
diff --git a/lib/vdsm/network/ovs/__init__.py b/lib/vdsm/network/ovs/__init__.py
new file mode 100644
index 0000000..4a67f47
--- /dev/null
+++ b/lib/vdsm/network/ovs/__init__.py
@@ -0,0 +1,19 @@
+# Copyright 2016 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
+#
+from __future__ import absolute_import
diff --git a/lib/vdsm/network/ovs/switch.py b/lib/vdsm/network/ovs/switch.py
new file mode 100644
index 0000000..ee1f1fc
--- /dev/null
+++ b/lib/vdsm/network/ovs/switch.py
@@ -0,0 +1,47 @@
+# Copyright 2016 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
+#
+from __future__ import absolute_import
+
+from contextlib import contextmanager
+
+
+def is_ovs_net(attrs):
+ pass
+
+
+def is_ovs_bond(attrs):
+ pass
+
+
+def validate_network_setup(nets, bonds):
+ pass
+
+
+ at contextmanager
+def rollback_manager(in_rollback):
+ try:
+ yield
+ except:
+ pass
+ finally:
+ pass
+
+
+def setup(nets, bonds, running_config):
+ pass
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 87be9ca..299e7b9 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -1070,6 +1070,7 @@
%dir %{python_sitelib}/%{vdsm_name}/network
%dir %{python_sitelib}/%{vdsm_name}/network/configurators
%dir %{python_sitelib}/%{vdsm_name}/network/ip
+%dir %{python_sitelib}/%{vdsm_name}/network/ovs
%dir %{python_sitelib}/%{vdsm_name}/tool
%dir %{python_sitelib}/%{vdsm_name}/tool/configurators
%dir %{python_sitelib}/%{vdsm_name}/profiling
@@ -1137,6 +1138,8 @@
%{python_sitelib}/%{vdsm_name}/network/connectivity.py*
%{python_sitelib}/%{vdsm_name}/network/ip/*.py*
%{python_sitelib}/%{vdsm_name}/network/legacy_switch.py*
+%{python_sitelib}/%{vdsm_name}/network/ovs/__init__.py*
+%{python_sitelib}/%{vdsm_name}/network/ovs/switch.py*
%{python_sitelib}/%{vdsm_name}/network/models.py*
%{python_sitelib}/%{vdsm_name}/network/netswitch.py*
%{python_sitelib}/%{vdsm_name}/network/sourceroute.py*
--
To view, visit https://gerrit.ovirt.org/55308
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic056fcf8c0d36625328a90a339d4a09658683056
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Petr Horáček <phoracek at redhat.com>
More information about the vdsm-patches
mailing list