Marcin Mirecki has uploaded a new change for review. Change subject: draft: migration plugin proposal - draft 102 ......................................................................
draft: migration plugin proposal - draft 102 Just a draft to show the idea, not verified Change-Id: Ia0fb056c4b4732505d567385546e78048c37d140 Signed-off-by: mirecki <mmire...@redhat.com> --- M vdsm/virt/vm_migrate_hook.py A vdsm/virt/vm_migrate_plugins/__init__.py A vdsm/virt/vm_migrate_plugins/external_network_plugin.py A vdsm/virt/vm_migrate_plugins/openstack_network_plugin.py A vdsm/virt/vm_migrate_plugins/vm_fex_plugin.py 5 files changed, 161 insertions(+), 11 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/86/64186/1 diff --git a/vdsm/virt/vm_migrate_hook.py b/vdsm/virt/vm_migrate_hook.py index 633e4f0..dd276f5 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,28 @@ 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 not vm_migrate_plugins.skip_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) 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..6c81eee --- /dev/null +++ b/vdsm/virt/vm_migrate_plugins/__init__.py @@ -0,0 +1,43 @@ +# 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 skip_processing(domxml, device_conf): + for driver in _DRIVERS: + driver.create().skip_processing(domxml, device_conf) + + +class VmMigratePlugin(): + + @abc.abstractmethod + def skip_processing(self, domxml, device_conf): + return False + + +for _, module, _ in iter_modules([__path__[0]]): + _DRIVERS.append(import_module('{}.{}'.format(__name__, module))) diff --git a/vdsm/virt/vm_migrate_plugins/external_network_plugin.py b/vdsm/virt/vm_migrate_plugins/external_network_plugin.py new file mode 100644 index 0000000..6beb0b2 --- /dev/null +++ b/vdsm/virt/vm_migrate_plugins/external_network_plugin.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python +# 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 . import VmMigratePlugin + + +class ExternalNetworkPlugin(VmMigratePlugin): + + EXTERNAL_NETWORK = 'EXTERNAL_NETWORK' + + def skip_processing(self, domxml, conf): + custom = conf.get('custom') + return custom.get('provider_type') == self.EXTERNAL_NETWORK \ + if custom else False + + +def create(): + return ExternalNetworkPlugin() diff --git a/vdsm/virt/vm_migrate_plugins/openstack_network_plugin.py b/vdsm/virt/vm_migrate_plugins/openstack_network_plugin.py new file mode 100644 index 0000000..50bd3d2 --- /dev/null +++ b/vdsm/virt/vm_migrate_plugins/openstack_network_plugin.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python +# 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 . import VmMigratePlugin + + +class OpenstackNetworkPlugin(VmMigratePlugin): + + OPENSTACK_NETWORK = 'OPENSTACK_NETWORK' + + def skip_processing(self, domxml, conf): + custom = conf.get('custom') + return custom.get('provider_type') == self.OPENSTACK_NETWORK \ + if custom else False + + +def create(): + return OpenstackNetworkPlugin() diff --git a/vdsm/virt/vm_migrate_plugins/vm_fex_plugin.py b/vdsm/virt/vm_migrate_plugins/vm_fex_plugin.py new file mode 100644 index 0000000..3661290 --- /dev/null +++ b/vdsm/virt/vm_migrate_plugins/vm_fex_plugin.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python +# 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 . import VmMigratePlugin + + +class VmFexPlugin(VmMigratePlugin): + + def skip_processing(self, domxml, conf): + return conf.get('vmfex') is not None + + +def create(): + return VmFexPlugin() -- To view, visit https://gerrit.ovirt.org/64186 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia0fb056c4b4732505d567385546e78048c37d140 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 To unsubscribe send an email to vdsm-patches-le...@lists.fedorahosted.org