Edward Haas has uploaded a new change for review. Change subject: net: Adding the netswitch module ......................................................................
net: Adding the netswitch module netswitch is placed between the network api and the switches (legacy and future ovs), acting as an interface to the underlying switches and taking shared responsabilities. Change-Id: I869e634e9f97cf279d4df83fca2b8f8d73bcea47 TODO: Add unit tests. Signed-off-by: Edward Haas <[email protected]> --- M debian/vdsm.install M lib/vdsm/network/Makefile.am M lib/vdsm/network/api.py A lib/vdsm/network/netswitch.py M vdsm.spec.in 5 files changed, 66 insertions(+), 22 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/31/55131/1 diff --git a/debian/vdsm.install b/debian/vdsm.install index 9671eed..e8f9b12 100644 --- a/debian/vdsm.install +++ b/debian/vdsm.install @@ -55,6 +55,7 @@ ./usr/share/vdsm/network/canonicalize.py ./usr/share/vdsm/network/legacy_switch.py ./usr/share/vdsm/network/models.py +./usr/share/vdsm/network/netswitch.py ./usr/share/vdsm/network/sourceroute.py ./usr/share/vdsm/network/sourceroutethread.py ./usr/share/vdsm/network/configurators/__init__.py diff --git a/lib/vdsm/network/Makefile.am b/lib/vdsm/network/Makefile.am index 11b76cd..4ea4f0f 100644 --- a/lib/vdsm/network/Makefile.am +++ b/lib/vdsm/network/Makefile.am @@ -29,6 +29,7 @@ canonicalize.py \ legacy_switch.py \ models.py \ + netswitch.py \ sourceroute.py \ sourceroutethread.py \ utils.py \ diff --git a/lib/vdsm/network/api.py b/lib/vdsm/network/api.py index 74557fa..2f4ab31 100644 --- a/lib/vdsm/network/api.py +++ b/lib/vdsm/network/api.py @@ -33,16 +33,13 @@ from vdsm import constants from vdsm import hooks from vdsm import netconfpersistence -from vdsm.netinfo.cache import (libvirtNets2vdsm, get as netinfo_get, - CachingNetInfo) -from vdsm.netinfo import networks as netinfo_networks from vdsm import udevadm from vdsm import utils from vdsm import ipwrapper from . canonicalize import canonicalize_networks -from . import legacy_switch from . import errors as ne +from . import netswitch from .configurators import RollbackIncomplete from .errors import ConfigNetworkError @@ -243,30 +240,15 @@ # TODO: Add canonicalize_bondings(bondings) logging.debug('Validating configuration') - legacy_switch.validate_network_setup(networks, bondings) + netswitch.validate(networks, bondings) bondings, networks, options = _apply_hook(bondings, networks, options) - - libvirt_nets = netinfo_networks() - _netinfo = CachingNetInfo(_netinfo=netinfo_get( - libvirtNets2vdsm(libvirt_nets))) logging.debug('Applying...') in_rollback = options.get('_inRollback', False) with _rollback(): - with legacy_switch.ConfiguratorClass(in_rollback) as configurator: - # from this point forward, any exception thrown will be handled by - # Configurator.__exit__. - - legacy_switch.remove_networks(networks, bondings, configurator, - _netinfo, libvirt_nets) - - legacy_switch.bonds_setup(bondings, configurator, _netinfo, - in_rollback) - - legacy_switch.add_missing_networks(configurator, networks, - bondings, _netinfo) - + for switch in netswitch.switches(): + netswitch.setup(switch, networks, bondings, in_rollback) _check_connectivity(networks, bondings, options) diff --git a/lib/vdsm/network/netswitch.py b/lib/vdsm/network/netswitch.py new file mode 100644 index 0000000..3da586d --- /dev/null +++ b/lib/vdsm/network/netswitch.py @@ -0,0 +1,59 @@ +# 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 vdsm.netinfo.cache import (libvirtNets2vdsm, get as netinfo_get, + CachingNetInfo) +from vdsm.netinfo import networks as libvirt_nets + +from . import legacy_switch + + +def validate(networks, bondings): + legacy_switch.validate_network_setup(networks, bondings) + + +def switches(): + return [legacy_switch] + + +def setup(switch, networks, bondings, in_rollback): + if switch == legacy_switch: + _setup_legacy(networks, bondings, in_rollback) + else: + raise Exception("Unsupported switch") + + +def _setup_legacy(networks, bondings, in_rollback): + + _libvirt_nets = libvirt_nets() + _netinfo = CachingNetInfo(netinfo_get(libvirtNets2vdsm(_libvirt_nets))) + + with legacy_switch.ConfiguratorClass(in_rollback) as configurator: + # from this point forward, any exception thrown will be handled by + # Configurator.__exit__. + + legacy_switch.remove_networks(networks, bondings, configurator, + _netinfo, _libvirt_nets) + + legacy_switch.bonds_setup(bondings, configurator, _netinfo, + in_rollback) + + legacy_switch.add_missing_networks(configurator, networks, + bondings, _netinfo) diff --git a/vdsm.spec.in b/vdsm.spec.in index 13918f3..17c9915 100644 --- a/vdsm.spec.in +++ b/vdsm.spec.in @@ -1132,6 +1132,7 @@ %{python_sitelib}/%{vdsm_name}/network/canonicalize.py* %{python_sitelib}/%{vdsm_name}/network/legacy_switch.py* %{python_sitelib}/%{vdsm_name}/network/models.py* +%{python_sitelib}/%{vdsm_name}/network/netswitch.py* %{python_sitelib}/%{vdsm_name}/network/sourceroute.py* %{python_sitelib}/%{vdsm_name}/network/sourceroutethread.py* %{python_sitelib}/%{vdsm_name}/network/utils.py* -- To view, visit https://gerrit.ovirt.org/55131 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I869e634e9f97cf279d4df83fca2b8f8d73bcea47 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Edward Haas <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
