Marcin Mirecki has uploaded a new change for review. Change subject: draft: vm_migration_libvirt_hook_plugins ......................................................................
draft: vm_migration_libvirt_hook_plugins Quick draft for vm migration libvirt hook plugins Change-Id: I7e13a94fa28968e37cd2d4d99fe540c8b762f7cc Signed-off-by: mirecki <mmire...@redhat.com> --- M vdsm/virt/vm_migrate_hook.py A vdsm/virt/vm_migrate_plugins/__init__.py 2 files changed, 72 insertions(+), 11 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/01/64001/1 diff --git a/vdsm/virt/vm_migrate_hook.py b/vdsm/virt/vm_migrate_hook.py index 633e4f0..063fdd0 100755 --- a/vdsm/virt/vm_migrate_hook.py +++ b/vdsm/virt/vm_migrate_hook.py @@ -28,6 +28,8 @@ from vdsm.config import config from vdsm.network import api as net_api +import vm_migrate_plugins + _DEBUG_MODE = False LOG_FILE = '/tmp/libvirthook_ovs_migrate.log' @@ -82,24 +84,29 @@ def _set_bridge_interfaces(devices, target_vm_conf): - target_vm_nets_by_vnic_mac = {dev['macAddr']: dev['network'] - for dev in target_vm_conf['devices'] - if dev.get('type') == 'interface'} + target_vm_conf_by_mac = {dev['macAddr']: dev + for dev in target_vm_conf['devices'] + if dev.get('type') == 'interface'} + for interface in devices.findall('interface'): if interface.get('type') == 'bridge': - _bind_iface_to_bridge(interface, target_vm_nets_by_vnic_mac) + _bind_iface_to_bridge(interface, target_vm_conf_by_mac) -def _bind_iface_to_bridge(interface, target_vm_nets_by_vnic_mac): +def _bind_iface_to_bridge(interface, target_vm_conf_by_mac): elem_macaddr = interface.find('mac') mac_addr = elem_macaddr.get('address') - target_vm_net = target_vm_nets_by_vnic_mac[mac_addr] - target_ovs_bridge = net_api.ovs_bridge(target_vm_net) - if target_ovs_bridge: - _bind_iface_to_ovs_bridge(interface, target_ovs_bridge, target_vm_net) - else: - _bind_iface_to_linux_bridge(interface, target_vm_net) + interface_conf = target_vm_conf_by_mac[mac_addr] + target_vm_net = interface_conf['network'] + if vm_migrate_plugins.do_default_processing(interface, interface_conf): + target_ovs_bridge = net_api.ovs_bridge(target_vm_net) + if target_ovs_bridge: + _bind_iface_to_ovs_bridge(interface, target_ovs_bridge, + target_vm_net) + else: + _bind_iface_to_linux_bridge(interface, target_vm_net) + vm_migrate_plugins.process(interface, interface_conf) def _bind_iface_to_ovs_bridge(interface, target_ovs_bridge, target_vm_net): diff --git a/vdsm/virt/vm_migrate_plugins/__init__.py b/vdsm/virt/vm_migrate_plugins/__init__.py new file mode 100644 index 0000000..3e4b090 --- /dev/null +++ b/vdsm/virt/vm_migrate_plugins/__init__.py @@ -0,0 +1,54 @@ +# 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 +# + +import abc +from importlib import import_module +from pkgutil import iter_modules + +import six + + +_DRIVERS = [] + + +def do_default_processing(domxml, device_conf): + result = True + for driver in _DRIVERS: + result = result and driver.create().do_default_processing(domxml, + device_conf) + return result + + +def process(domxml, device_conf): + for driver in _DRIVERS: + driver.create().process(domxml, device_conf) + + +class VmMigrateDriver(): + + @abc.abstractmethod + def do_default_processing(self, domxml, device_conf): + pass + + @abc.abstractmethod + def process(self, domxml, device_conf): + pass + +for _, module, _ in iter_modules([__path__[0]]): + _DRIVERS.append(import_module('{}.{}'.format(__name__, module))) -- To view, visit https://gerrit.ovirt.org/64001 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7e13a94fa28968e37cd2d4d99fe540c8b762f7cc Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Marcin Mirecki <mmire...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org