Change in vdsm[ovirt-3.5]: spec: fix requirement version
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: spec: fix requirement version
......................................................................
spec: fix requirement version
Fixes this build error:
rpmbuild -ba --define \"_topdir \$(pwd)/rpm\" rpm/SPECS/vdsm.spec"
=================================================================================================
Standard output
=================================================================================================
error: line 235: Invalid version (double separator '-'):
selinux-policy-3.13.1-16.el7: Requires: selinux-policy-targeted >=
selinux-policy-3.13.1-16.el7
Change-Id: I9c30c0be4295e2c306496a1c7bd8d0eb34c076b9
Bug-Url: https://bugzilla.redhat.com/1267851
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm.spec.in
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/54/47554/1
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 6c31e9c..36e29da 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -232,7 +232,7 @@
Requires: kernel >= 3.10.0-229.17.1.el7
%endif
Requires: policycoreutils-python
-Requires: selinux-policy-targeted >= selinux-policy-3.13.1-16.el7
+Requires: selinux-policy-targeted >= 3.13.1-16.el7
%else
Requires: python
Requires: device-mapper-multipath >= 0.4.9-52
--
To view, visit https://gerrit.ovirt.org/47554
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9c30c0be4295e2c306496a1c7bd8d0eb34c076b9
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
8 years, 6 months
Change in vdsm[master]: hooks: ovs: use six.iteritems
by phoracek@redhat.com
Petr Horáček has uploaded a new change for review.
Change subject: hooks: ovs: use six.iteritems
......................................................................
hooks: ovs: use six.iteritems
Change-Id: I3d098a3142f61e927e047058424d2bd6f6955145
Signed-off-by: Petr Horáček <phoracek(a)redhat.com>
---
M vdsm_hooks/ovs/ovs_after_get_caps.py
M vdsm_hooks/ovs/ovs_after_get_stats.py
M vdsm_hooks/ovs/ovs_before_network_setup.py
M vdsm_hooks/ovs/ovs_before_network_setup_ip.py
M vdsm_hooks/ovs/ovs_before_network_setup_mtu.py
M vdsm_hooks/ovs/ovs_before_network_setup_ovs.py
M vdsm_hooks/ovs/ovs_utils.py
7 files changed, 30 insertions(+), 21 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/39/47139/1
diff --git a/vdsm_hooks/ovs/ovs_after_get_caps.py b/vdsm_hooks/ovs/ovs_after_get_caps.py
index 3ffc3e3..bb5e36d 100755
--- a/vdsm_hooks/ovs/ovs_after_get_caps.py
+++ b/vdsm_hooks/ovs/ovs_after_get_caps.py
@@ -18,6 +18,7 @@
# Refer to the README and COPYING files for full details of the license
#
import re
+import six
import sys
import traceback
@@ -70,7 +71,7 @@
ovs_networks_caps = {}
dhcpv4ifaces, dhcpv6ifaces = netinfo._get_dhclient_ifaces()
routes = netinfo._get_routes()
- for network, attrs in running_config.networks.items():
+ for network, attrs in six.iteritems(running_config.networks):
if is_ovs_network(attrs):
interface = network if 'vlan' in attrs else BRIDGE_NAME
net_info = _get_net_info(attrs, interface, dhcpv4ifaces,
@@ -87,7 +88,7 @@
ovs_bridges_caps = {}
dhcpv4ifaces, dhcpv6ifaces = netinfo._get_dhclient_ifaces()
routes = netinfo._get_routes()
- for network, attrs in running_config.networks.items():
+ for network, attrs in six.iteritems(running_config.networks):
if is_ovs_network(attrs):
interface = network if 'vlan' in attrs else BRIDGE_NAME
net_info = _get_net_info(attrs, interface, dhcpv4ifaces,
@@ -104,7 +105,7 @@
ovs_vlans_caps = {}
dhcpv4ifaces, dhcpv6ifaces = netinfo._get_dhclient_ifaces()
routes = netinfo._get_routes()
- for network, attrs in running_config.networks.items():
+ for network, attrs in six.iteritems(running_config.networks):
if is_ovs_network(attrs):
vlan = attrs.get('vlan')
if vlan is not None:
@@ -140,7 +141,7 @@
ovs_bonding_caps = {}
dhcpv4ifaces, dhcpv6ifaces = netinfo._get_dhclient_ifaces()
routes = netinfo._get_routes()
- for bonding, attrs in running_config.bonds.items():
+ for bonding, attrs in six.iteritems(running_config.bonds):
if is_ovs_bond(attrs):
options = get_bond_options(attrs.get('options'), keep_custom=True)
net_info = _get_net_info(attrs, bonding, dhcpv4ifaces,
diff --git a/vdsm_hooks/ovs/ovs_after_get_stats.py b/vdsm_hooks/ovs/ovs_after_get_stats.py
index b902f57..f4c6039 100755
--- a/vdsm_hooks/ovs/ovs_after_get_stats.py
+++ b/vdsm_hooks/ovs/ovs_after_get_stats.py
@@ -18,6 +18,7 @@
# Refer to the README and COPYING files for full details of the license
#
from functools import partial
+import six
import traceback
from vdsm.netconfpersistence import RunningConfig
@@ -38,7 +39,7 @@
ovs_networks_stats = {}
running_config = RunningConfig()
- for network, attrs in running_config.networks.items():
+ for network, attrs in six.iteritems(running_config.networks):
if is_ovs_network(attrs):
vlan = attrs.get('vlan')
iface = attrs.get('nic') or attrs.get('bonding')
diff --git a/vdsm_hooks/ovs/ovs_before_network_setup.py b/vdsm_hooks/ovs/ovs_before_network_setup.py
index 9bc73a5..5c7aa1d 100755
--- a/vdsm_hooks/ovs/ovs_before_network_setup.py
+++ b/vdsm_hooks/ovs/ovs_before_network_setup.py
@@ -19,6 +19,7 @@
#
from copy import deepcopy
from functools import partial
+import six
import sys
import traceback
@@ -54,14 +55,14 @@
non_ovs_nets = {}
ovs_bonds = {}
non_ovs_bonds = {}
- for net, attrs in nets.items():
+ for net, attrs in six.iteritems(nets):
if (('remove' in attrs and net in running_config.networks and
is_ovs_network(running_config.networks[net])) or
is_ovs_network(attrs)):
ovs_nets[net] = attrs
else:
non_ovs_nets[net] = attrs
- for bond, attrs in bonds.items():
+ for bond, attrs in six.iteritems(bonds):
if (('remove' in attrs and bond in running_config.bonds and
is_ovs_bond(running_config.bonds[bond])) or
is_ovs_bond(attrs)):
@@ -80,10 +81,10 @@
libvirt.removeNetwork(net)
destroy_ovs_bridge()
- for net, attrs in running_config.networks.items():
+ for net, attrs in six.iteritems(running_config.networks):
if is_ovs_network(attrs):
running_config.networks.pop(net)
- for bond, attrs in running_config.bonds.items():
+ for bond, attrs in six.iteritems(running_config.bonds):
if is_ovs_bond(attrs):
running_config.bonds.pop(bond)
running_config.save()
diff --git a/vdsm_hooks/ovs/ovs_before_network_setup_ip.py b/vdsm_hooks/ovs/ovs_before_network_setup_ip.py
index 2273cc6..6f8a6fd 100644
--- a/vdsm_hooks/ovs/ovs_before_network_setup_ip.py
+++ b/vdsm_hooks/ovs/ovs_before_network_setup_ip.py
@@ -18,6 +18,7 @@
# Refer to the README and COPYING files for full details of the license
#
from functools import partial
+import six
import sys
from vdsm import ipwrapper, sysctl
@@ -105,7 +106,7 @@
ip_config_to_set = {}
ip_config_to_remove = {}
- for net, attrs in nets.items():
+ for net, attrs in six.iteritems(nets):
if net in init_nets:
init_attrs = init_nets[net]
init_top_dev = net if 'vlan' in init_attrs else BRIDGE_NAME
@@ -123,7 +124,8 @@
log('Remove IP configuration of: %s' % ip_config_to_remove)
log('Set IP configuration: %s' % ip_config_to_set)
- for iface, (ipv4, ipv6) in ip_config_to_remove.iteritems():
+ for iface, (ipv4, ipv6) in six.iteritems(ip_config_to_remove):
_remove_ip_config(iface, ipv4, ipv6)
- for iface, (ipv4, ipv6, blockingdhcp, port) in ip_config_to_set.items():
+ for iface, (ipv4, ipv6, blockingdhcp, port) in six.iteritems(
+ ip_config_to_set):
_set_ip_config(iface, ipv4, ipv6, blockingdhcp, port)
diff --git a/vdsm_hooks/ovs/ovs_before_network_setup_mtu.py b/vdsm_hooks/ovs/ovs_before_network_setup_mtu.py
index ffe2c08..10cc23b 100644
--- a/vdsm_hooks/ovs/ovs_before_network_setup_mtu.py
+++ b/vdsm_hooks/ovs/ovs_before_network_setup_mtu.py
@@ -17,6 +17,8 @@
#
# Refer to the README and COPYING files for full details of the license
#
+import six
+
from vdsm import ipwrapper, netinfo
from ovs_utils import iter_ovs_nets, iter_ovs_bonds
@@ -88,5 +90,5 @@
changes_bonds = _mtus_bonds(running_config)
changes_vlans = _mtus_vlans(running_config)
for mtu_changes in (changes_nics, changes_bonds, changes_vlans):
- for iface, mtu in mtu_changes.iteritems():
+ for iface, mtu in six.iteritems(mtu_changes):
_set_iface_mtu(iface, mtu)
diff --git a/vdsm_hooks/ovs/ovs_before_network_setup_ovs.py b/vdsm_hooks/ovs/ovs_before_network_setup_ovs.py
index 72c1c23..7f3a076 100644
--- a/vdsm_hooks/ovs/ovs_before_network_setup_ovs.py
+++ b/vdsm_hooks/ovs/ovs_before_network_setup_ovs.py
@@ -18,6 +18,7 @@
# Refer to the README and COPYING files for full details of the license
#
from functools import partial
+import six
import sys
from vdsm.netinfo import NetInfo
@@ -52,7 +53,7 @@
def _get_nets_by_nic(running_config):
""" Transform running config into {nic: set(networks)}. """
nets_by_nic = {}
- for net, attrs in running_config.networks.iteritems():
+ for net, attrs in six.iteritems(running_config.networks):
nic = attrs.get('nic')
if nic is not None:
nets_by_nic.setdefault(nic, set()).add(net)
@@ -173,7 +174,7 @@
if vlan is not None and bonding is None and nic is None:
raise Exception('You can not create a nicless/bondless vlan')
- for existing_net, existing_attrs in running_config.networks.items():
+ for existing_net, existing_attrs in six.iteritems(running_config.networks):
if (existing_net != net and
existing_attrs.get('nic') == nic and
existing_attrs.get('bond') == bonding and
@@ -254,14 +255,14 @@
def _handle_setup(nets, bonds, running_config, nets_by_nic):
commands = []
netinfo = NetInfo()
- for bond, attrs in bonds.items():
+ for bond, attrs in six.iteritems(bonds):
if 'remove' not in attrs:
_validate_bond_configuration(attrs, netinfo)
if bond in running_config.bonds:
commands.extend(_edit_ovs_bond(bond, attrs, running_config))
else:
commands.extend(_setup_ovs_bond(bond, attrs, running_config))
- for net, attrs in nets.iteritems():
+ for net, attrs in six.iteritems(nets):
if 'remove' not in attrs:
_validate_net_configuration(net, attrs, running_config, netinfo)
if net in running_config.networks:
@@ -275,11 +276,11 @@
def _handle_removal(nets, bonds, running_config, nets_by_nic):
commands = []
- for net, attrs in nets.iteritems():
+ for net, attrs in six.iteritems(nets):
if 'remove' in attrs:
commands.extend(_remove_ovs_network(net, running_config,
nets_by_nic))
- for bond, attrs in bonds.items():
+ for bond, attrs in six.iteritems(bonds):
if 'remove' in attrs:
commands.extend(['--', 'del-port', BRIDGE_NAME, bond])
running_config.removeBonding(bond)
diff --git a/vdsm_hooks/ovs/ovs_utils.py b/vdsm_hooks/ovs/ovs_utils.py
index 916909c..60112ee 100644
--- a/vdsm_hooks/ovs/ovs_utils.py
+++ b/vdsm_hooks/ovs/ovs_utils.py
@@ -21,6 +21,7 @@
import errno
import os
import pickle
+import six
from hooking import execCmd
import hooking
@@ -90,14 +91,14 @@
def iter_ovs_nets(networks):
""" Yields OVS networks (network, attrs) from networks dictionary. """
- for network, attrs in networks.items():
+ for network, attrs in six.iteritems(networks):
if is_ovs_network(attrs):
yield network, attrs
def iter_ovs_bonds(bondings):
""" Yields OVS bondings (bonding, attrs) from bonds dictionary. """
- for bond, attrs in bondings.items():
+ for bond, attrs in six.iteritems(bondings):
if is_ovs_bond(attrs):
yield bond, attrs
--
To view, visit https://gerrit.ovirt.org/47139
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3d098a3142f61e927e047058424d2bd6f6955145
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Petr Horáček <phoracek(a)redhat.com>
8 years, 6 months
Change in vdsm[master]: hooks: ovs: add script name to log
by phoracek@redhat.com
Petr Horáček has uploaded a new change for review.
Change subject: hooks: ovs: add script name to log
......................................................................
hooks: ovs: add script name to log
Change-Id: I8e40406fb2dfce6099a2c288b5d3c37ceec839d1
Signed-off-by: Petr Horáček <phoracek(a)redhat.com>
---
M vdsm_hooks/ovs/ovs_after_get_stats.py
M vdsm_hooks/ovs/ovs_after_network_setup.py
M vdsm_hooks/ovs/ovs_after_network_setup_failture.py
M vdsm_hooks/ovs/ovs_before_network_setup.py
M vdsm_hooks/ovs/ovs_before_network_setup_ip.py
M vdsm_hooks/ovs/ovs_before_network_setup_ovs.py
M vdsm_hooks/ovs/ovs_utils.py
7 files changed, 31 insertions(+), 8 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/16/46916/1
diff --git a/vdsm_hooks/ovs/ovs_after_get_stats.py b/vdsm_hooks/ovs/ovs_after_get_stats.py
index fc04417..b902f57 100755
--- a/vdsm_hooks/ovs/ovs_after_get_stats.py
+++ b/vdsm_hooks/ovs/ovs_after_get_stats.py
@@ -17,13 +17,17 @@
#
# Refer to the README and COPYING files for full details of the license
#
+from functools import partial
import traceback
from vdsm.netconfpersistence import RunningConfig
import hooking
-from ovs_utils import is_ovs_network, log
+from ovs_utils import is_ovs_network
+import ovs_utils
+
+log = partial(ovs_utils.log, tag='ovs_after_get_stats: ')
def ovs_networks_stats(stats):
diff --git a/vdsm_hooks/ovs/ovs_after_network_setup.py b/vdsm_hooks/ovs/ovs_after_network_setup.py
index 7f99db1..b40e2e6 100644
--- a/vdsm_hooks/ovs/ovs_after_network_setup.py
+++ b/vdsm_hooks/ovs/ovs_after_network_setup.py
@@ -17,11 +17,15 @@
#
# Refer to the README and COPYING files for full details of the license
#
+from functools import partial
import traceback
import hooking
-from ovs_utils import remove_init_config, log
+from ovs_utils import remove_init_config
+import ovs_utils
+
+log = partial(ovs_utils.log, tag='ovs_after_network_setup: ')
def main():
diff --git a/vdsm_hooks/ovs/ovs_after_network_setup_failture.py b/vdsm_hooks/ovs/ovs_after_network_setup_failture.py
index 9935a13..d79ef84 100755
--- a/vdsm_hooks/ovs/ovs_after_network_setup_failture.py
+++ b/vdsm_hooks/ovs/ovs_after_network_setup_failture.py
@@ -17,13 +17,16 @@
#
# Refer to the README and COPYING files for full details of the license
#
+from functools import partial
import traceback
from vdsm import supervdsm
import hooking
-from ovs_utils import log
+import ovs_utils
+
+log = partial(ovs_utils.log, tag='ovs_after_network_setup_failture: ')
def main():
diff --git a/vdsm_hooks/ovs/ovs_before_network_setup.py b/vdsm_hooks/ovs/ovs_before_network_setup.py
index c02c438..9bc73a5 100755
--- a/vdsm_hooks/ovs/ovs_before_network_setup.py
+++ b/vdsm_hooks/ovs/ovs_before_network_setup.py
@@ -18,6 +18,7 @@
# Refer to the README and COPYING files for full details of the license
#
from copy import deepcopy
+from functools import partial
import sys
import traceback
@@ -28,7 +29,7 @@
from hooking import execCmd
import hooking
-from ovs_utils import (is_ovs_network, is_ovs_bond, load_init_config, log,
+from ovs_utils import (is_ovs_network, is_ovs_bond, load_init_config,
save_init_config, iter_ovs_nets, suppress,
destroy_ovs_bridge, EXT_IP, EXT_OVS_VSCTL)
from ovs_setup_ovs import configure_ovs, prepare_ovs
@@ -36,11 +37,14 @@
from ovs_setup_mtu import configure_mtu
from ovs_setup_libvirt import (create_libvirt_nets, remove_libvirt_nets,
prepare_libvirt)
+import ovs_utils
# TODO: move required modules into vdsm/lib
sys.path.append('/usr/share/vdsm')
from network.configurators import libvirt
+log = partial(ovs_utils.log, tag='ovs_before_network_setup: ')
+
def _separate_ovs_nets_bonds(nets, bonds, running_config):
""" Get a dictionaries of nets and bonds to be handled by OVS hook and
diff --git a/vdsm_hooks/ovs/ovs_before_network_setup_ip.py b/vdsm_hooks/ovs/ovs_before_network_setup_ip.py
index c87e6d6..2273cc6 100644
--- a/vdsm_hooks/ovs/ovs_before_network_setup_ip.py
+++ b/vdsm_hooks/ovs/ovs_before_network_setup_ip.py
@@ -17,11 +17,13 @@
#
# Refer to the README and COPYING files for full details of the license
#
+from functools import partial
import sys
from vdsm import ipwrapper, sysctl
-from ovs_utils import suppress, log, BRIDGE_NAME
+from ovs_utils import suppress, BRIDGE_NAME
+import ovs_utils
# TODO: move required modules into vdsm/lib
sys.path.append('/usr/share/vdsm')
@@ -30,6 +32,8 @@
from network.models import NetDevice, IPv4, IPv6
from network.sourceroute import DynamicSourceRoute
+log = partial(ovs_utils.log, tag='ovs_before_network_setup_ip: ')
+
iproute2 = Iproute2()
diff --git a/vdsm_hooks/ovs/ovs_before_network_setup_ovs.py b/vdsm_hooks/ovs/ovs_before_network_setup_ovs.py
index d22748a..72c1c23 100644
--- a/vdsm_hooks/ovs/ovs_before_network_setup_ovs.py
+++ b/vdsm_hooks/ovs/ovs_before_network_setup_ovs.py
@@ -17,20 +17,24 @@
#
# Refer to the README and COPYING files for full details of the license
#
+from functools import partial
import sys
from vdsm.netinfo import NetInfo
import hooking
-from ovs_utils import (get_bond_options, is_ovs_bond, iter_ovs_nets, log,
+from ovs_utils import (get_bond_options, is_ovs_bond, iter_ovs_nets,
iter_ovs_bonds, rget, suppress, destroy_ovs_bridge,
BRIDGE_NAME, EXT_OVS_VSCTL)
+import ovs_utils
# TODO: move required modules into vdsm/lib
sys.path.append('/usr/share/vdsm')
from network.configurators import libvirt
+log = partial(ovs_utils.log, tag='ovs_before_network_setup_ovs: ')
+
VALID_MODES = frozenset(['active-backup', 'balance-tcp', 'balance-slb'])
VALID_LACP = frozenset(['active', 'passive', 'off'])
diff --git a/vdsm_hooks/ovs/ovs_utils.py b/vdsm_hooks/ovs/ovs_utils.py
index d592b8f..916909c 100644
--- a/vdsm_hooks/ovs/ovs_utils.py
+++ b/vdsm_hooks/ovs/ovs_utils.py
@@ -120,8 +120,8 @@
raise Exception('\n'.join(err))
-def log(message):
- hooking.log('OVS: %s' % message)
+def log(message, tag='OVS: '):
+ hooking.log('%s%s' % (tag, message))
def load_init_config():
--
To view, visit https://gerrit.ovirt.org/46916
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8e40406fb2dfce6099a2c288b5d3c37ceec839d1
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Petr Horáček <phoracek(a)redhat.com>
8 years, 6 months
Change in vdsm[master]: net: ovs: draft of better rollback
by phoracek@redhat.com
Petr Horáček has uploaded a new change for review.
Change subject: net: ovs: draft of better rollback
......................................................................
net: ovs: draft of better rollback
now it's in a piggy state but working!
Change-Id: I8f6b63d03bb9579e260bfad1686047a431f69543
Signed-off-by: Petr Horáček <phoracek(a)redhat.com>
---
M debian/vdsm-hook-ovs.install
M tests/functional/networkTestsOVS.py
M vdsm.spec.in
M vdsm_hooks/ovs/Makefile.am
M vdsm_hooks/ovs/README
A vdsm_hooks/ovs/ovs_after_network_setup.py
A vdsm_hooks/ovs/ovs_after_network_setup_failture.py
M vdsm_hooks/ovs/ovs_before_network_setup.py
M vdsm_hooks/ovs/ovs_utils.py
9 files changed, 238 insertions(+), 60 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/07/46907/1
diff --git a/debian/vdsm-hook-ovs.install b/debian/vdsm-hook-ovs.install
index 36e1f0f..c7b6692 100644
--- a/debian/vdsm-hook-ovs.install
+++ b/debian/vdsm-hook-ovs.install
@@ -10,3 +10,7 @@
usr/libexec/vdsm/hooks/before_device_create/ovs_utils.py
usr/libexec/vdsm/hooks/before_network_setup/50_ovs
usr/libexec/vdsm/hooks/before_network_setup/ovs_utils.py
+usr/libexec/vdsm/hooks/after_network_setup/50_ovs
+usr/libexec/vdsm/hooks/after_network_setup/ovs_utils.py
+usr/libexec/vdsm/hooks/after_network_setup_failture/50_ovs
+usr/libexec/vdsm/hooks/after_network_setup_failture/ovs_utils.py
diff --git a/tests/functional/networkTestsOVS.py b/tests/functional/networkTestsOVS.py
index b26105d..d1fe95e 100644
--- a/tests/functional/networkTestsOVS.py
+++ b/tests/functional/networkTestsOVS.py
@@ -41,6 +41,7 @@
NetworkTest.__test__ = False
BRIDGE_NAME = 'ovsbr0'
+ERR_HOOK_ERROR = 78
# Tests which are not supported by OVS hook (because of OVS hook or because of
# tests themselves). Some of these tests should be inherited and 'repaired'
diff --git a/vdsm.spec.in b/vdsm.spec.in
index fe70e24..bdbd704 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -1180,6 +1180,10 @@
%{_libexecdir}/%{vdsm_name}/hooks/before_network_setup/ovs_setup_mtu.py*
%{_libexecdir}/%{vdsm_name}/hooks/before_network_setup/ovs_setup_ovs.py*
%{_libexecdir}/%{vdsm_name}/hooks/before_network_setup/ovs_utils.py*
+%{_libexecdir}/%{vdsm_name}/hooks/after_network_setup/50_ovs
+%{_libexecdir}/%{vdsm_name}/hooks/after_network_setup/ovs_utils.py*
+%{_libexecdir}/%{vdsm_name}/hooks/after_network_setup_failture/50_ovs
+%{_libexecdir}/%{vdsm_name}/hooks/after_network_setup_failture/ovs_utils.py*
%files hook-macspoof
%defattr(-, root, root, -)
diff --git a/vdsm_hooks/ovs/Makefile.am b/vdsm_hooks/ovs/Makefile.am
index 4699ef5..48f1820 100644
--- a/vdsm_hooks/ovs/Makefile.am
+++ b/vdsm_hooks/ovs/Makefile.am
@@ -36,6 +36,8 @@
ovs_before_network_setup_ovs.py \
ovs_before_network_setup_ip.py \
ovs_before_network_setup_mtu.py \
+ ovs_after_network_setup.py \
+ ovs_after_network_setup_failture.py \
$(utilsfile) \
sudoers.in
@@ -59,6 +61,12 @@
$(DESTDIR)$(vdsmhooksdir)/before_network_setup/ovs_setup_ip.py
$(INSTALL_SCRIPT) $(srcdir)/ovs_before_network_setup_mtu.py \
$(DESTDIR)$(vdsmhooksdir)/before_network_setup/ovs_setup_mtu.py
+ $(MKDIR_P) $(DESTDIR)$(vdsmhooksdir)/after_network_setup
+ $(INSTALL_SCRIPT) $(srcdir)/ovs_after_network_setup.py \
+ $(DESTDIR)$(vdsmhooksdir)/after_network_setup/50_ovs
+ $(MKDIR_P) $(DESTDIR)$(vdsmhooksdir)/after_network_setup_failture
+ $(INSTALL_SCRIPT) $(srcdir)/ovs_after_network_setup_failture.py \
+ $(DESTDIR)$(vdsmhooksdir)/after_network_setup_failture/50_ovs
uninstall-local: uninstall-data-utils uninstall-data-sudoers
$(RM) $(DESTDIR)$(vdsmhooksdir)/after_get_caps/50_ovs
@@ -68,6 +76,8 @@
$(RM) $(DESTDIR)$(vdsmhooksdir)/before_network_setup/ovs_setup_ovs.py
$(RM) $(DESTDIR)$(vdsmhooksdir)/before_network_setup/ovs_setup_ip.py
$(RM) $(DESTDIR)$(vdsmhooksdir)/before_network_setup/ovs_setup_mtu.py
+ $(RM) $(DESTDIR)$(vdsmhooksdir)/after_network_setup/50_ovs
+ $(RM) $(DESTDIR)$(vdsmhooksdir)/after_network_setup_failture/50_ovs
install-data-utils:
$(MKDIR_P) $(DESTDIR)$(vdsmhooksdir)/after_get_caps
@@ -82,12 +92,20 @@
$(MKDIR_P) $(DESTDIR)$(vdsmhooksdir)/before_network_setup
$(INSTALL_SCRIPT) $(srcdir)/$(utilsfile) \
$(DESTDIR)$(vdsmhooksdir)/before_network_setup/$(utilsfile)
+ $(MKDIR_P) $(DESTDIR)$(vdsmhooksdir)/after_network_setup
+ $(INSTALL_SCRIPT) $(srcdir)/$(utilsfile) \
+ $(DESTDIR)$(vdsmhooksdir)/after_network_setup/$(utilsfile)
+ $(MKDIR_P) $(DESTDIR)$(vdsmhooksdir)/after_network_setup_failture
+ $(INSTALL_SCRIPT) $(srcdir)/$(utilsfile) \
+ $(DESTDIR)$(vdsmhooksdir)/after_network_setup_failture/$(utilsfile)
uninstall-data-utils:
$(RM) $(DESTDIR)$(vdsmhooksdir)/after_get_caps/$(utilsfile)
$(RM) $(DESTDIR)$(vdsmhooksdir)/after_get_stats/$(utilsfile)
$(RM) $(DESTDIR)$(vdsmhooksdir)/before_device_create/$(utilsfile)
$(RM) $(DESTDIR)$(vdsmhooksdir)/before_network_setup/$(utilsfile)
+ $(RM) $(DESTDIR)$(vdsmhooksdir)/after_network_setup/$(utilsfile)
+ $(RM) $(DESTDIR)$(vdsmhooksdir)/after_network_setup_failture/$(utilsfile)
install-data-sudoers:
$(MKDIR_P) $(DESTDIR)$(sysconfdir)/sudoers.d
diff --git a/vdsm_hooks/ovs/README b/vdsm_hooks/ovs/README
index 78e4fcb..8b7bba0 100644
--- a/vdsm_hooks/ovs/README
+++ b/vdsm_hooks/ovs/README
@@ -53,6 +53,22 @@
- All networks are bridged
+Rollback
+--------
+
+OVS rollback is a bit complex and *zaslouzisi* some explanation:
+
+1) After ovs_before_network_setup.py:configure() calls prepare_ovs() (which
+ is the last safe moment before we touch any system configuration) we save
+ initial network configuration into a temporary file.
+2) If an error occurs during setupNetworks(),
+ ovs_after_network_setup_failture.py is executed. If there is an temporary
+ file containing initial network configuration, ovs_utils.py:rollback()
+ is called.
+3) If there was no error, ovs_after_network_setup.py is executed and just
+ removes temporary initial config file.
+
+
Backporting
-----------
diff --git a/vdsm_hooks/ovs/ovs_after_network_setup.py b/vdsm_hooks/ovs/ovs_after_network_setup.py
new file mode 100644
index 0000000..7f99db1
--- /dev/null
+++ b/vdsm_hooks/ovs/ovs_after_network_setup.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+# Copyright 2015 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 traceback
+
+import hooking
+
+from ovs_utils import remove_init_config, log
+
+
+def main():
+ setup_nets_config = hooking.read_json()
+
+ inRollback = setup_nets_config['request']['options'].get('_inRollback')
+ inOVSRollback = setup_nets_config['request']['options'].get(
+ '_inOVSRollback')
+
+ if inRollback and not inOVSRollback:
+ log('Non-OVS rollback is done. Leaving OVS init_config for OVS '
+ 'rollback.')
+ elif inRollback and inOVSRollback:
+ log('OVS rollback is done. Removing OVS init_config backup.')
+ remove_init_config()
+ else:
+ log('Network setup was successfull. Removing OVS init_config backup.')
+ remove_init_config()
+
+
+if __name__ == '__main__':
+ try:
+ main()
+ except:
+ hooking.exit_hook(traceback.format_exc())
diff --git a/vdsm_hooks/ovs/ovs_after_network_setup_failture.py b/vdsm_hooks/ovs/ovs_after_network_setup_failture.py
new file mode 100755
index 0000000..9935a13
--- /dev/null
+++ b/vdsm_hooks/ovs/ovs_after_network_setup_failture.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+# Copyright 2015 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 traceback
+
+from vdsm import supervdsm
+
+import hooking
+
+from ovs_utils import log
+
+
+def main():
+ setup_nets_config = hooking.read_json()
+ in_rollback = setup_nets_config['request']['options'].get('_inRollback',
+ False)
+ if in_rollback:
+ log('Failed while trying to rollback.')
+ else:
+ log('Configuration failed. In this point, non-OVS rollback should be '
+ 'done. Executing OVS rollback.')
+ supervdsm.getProxy().setupNetworks(
+ {}, {}, {'connectivityCheck': False, '_inRollback': True,
+ '_inOVSRollback': True})
+
+
+if __name__ == '__main__':
+ try:
+ main()
+ except:
+ hooking.exit_hook(traceback.format_exc())
diff --git a/vdsm_hooks/ovs/ovs_before_network_setup.py b/vdsm_hooks/ovs/ovs_before_network_setup.py
index 54a941e..64a52c1 100755
--- a/vdsm_hooks/ovs/ovs_before_network_setup.py
+++ b/vdsm_hooks/ovs/ovs_before_network_setup.py
@@ -17,21 +17,27 @@
#
# Refer to the README and COPYING files for full details of the license
#
-from contextlib import contextmanager
from copy import deepcopy
import sys
import traceback
+
+from libvirt import libvirtError
from vdsm.netconfpersistence import RunningConfig
from hooking import execCmd
import hooking
-from ovs_utils import (is_ovs_network, is_ovs_bond, rollback, log, EXT_IP,
- EXT_OVS_VSCTL)
+from ovs_utils import (is_ovs_network, is_ovs_bond, load_init_config, log,
+ save_init_config, iter_ovs_nets, suppress,
+ destroy_ovs_bridge, EXT_IP, EXT_OVS_VSCTL)
from ovs_setup_ovs import configure_ovs, prepare_ovs
from ovs_setup_ip import configure_ip
from ovs_setup_mtu import configure_mtu
+
+# TODO: move required modules into vdsm/lib
+sys.path.append('/usr/share/vdsm')
+from network.configurators import libvirt
def _separate_ovs_nets_bonds(nets, bonds, running_config):
@@ -59,29 +65,50 @@
return ovs_nets, non_ovs_nets, ovs_bonds, non_ovs_bonds
-@contextmanager
-def _rollback(running_config, initial_config, in_rollback):
- try:
- yield
- except:
- if in_rollback:
- log('Failed while trying to rollback:')
- else:
- log('Configuration failed. Entering rollback.')
- rollback(running_config, initial_config)
- log('Rollback finished. Initial error:')
- raise
+def _remove_ovs_nets(initial_config, running_config):
+ log('Remove OVS networks: %s %s' % (initial_config, running_config))
+ for libvirt_ovs_nets in (iter_ovs_nets(running_config.networks),
+ iter_ovs_nets(initial_config.networks)):
+ for net, attrs in libvirt_ovs_nets:
+ with suppress(libvirtError): # network not found
+ libvirt.removeNetwork(net)
+
+ destroy_ovs_bridge()
+ for net, attrs in running_config.networks.items():
+ if is_ovs_network(attrs):
+ running_config.networks.pop(net)
+ for bond, attrs in running_config.bonds.items():
+ if is_ovs_bond(attrs):
+ running_config.bonds.pop(bond)
+ running_config.save()
-def configure(nets, bonds, running_config, in_rollback):
+def _rollback(running_config):
+ initial_config = load_init_config()
+ if initial_config is None:
+ log('No needed OVS changes to be done.')
+ else:
+ log('Remove OVS networks.')
+ _remove_ovs_nets(initial_config, running_config)
+ log('Reconfigure OVS networks according to initial_config.')
+ _configure(initial_config.networks, initial_config.bonds,
+ running_config, save_init=False)
+
+
+def _configure(nets, bonds, running_config, save_init=True):
initial_config = deepcopy(running_config)
commands, libvirt_create, libvirt_remove = prepare_ovs(
nets, bonds, running_config)
- with _rollback(running_config, initial_config, in_rollback):
- configure_ovs(commands, libvirt_create, libvirt_remove, running_config)
- configure_mtu(running_config)
- configure_ip(nets, initial_config.networks)
+
+ if save_init:
+ log('Saving initial configuration for optional rollback: %s' %
+ initial_config)
+ save_init_config(initial_config)
+
+ configure_ovs(commands, libvirt_create, libvirt_remove, running_config)
+ configure_mtu(running_config)
+ configure_ip(nets, initial_config.networks)
log('Saving running configuration: %s %s' % (running_config.networks,
running_config.bonds))
@@ -95,16 +122,29 @@
running_config = RunningConfig()
networks = setup_nets_config['request']['networks']
bondings = setup_nets_config['request']['bondings']
- inRollback = setup_nets_config['request']['options'].get('_inRollback',
- False)
- ovs_nets, non_ovs_nets, ovs_bonds, non_ovs_bonds = \
- _separate_ovs_nets_bonds(networks, bondings, running_config)
- configure(ovs_nets, ovs_bonds, running_config, inRollback)
- setup_nets_config['request']['bondings'] = non_ovs_bonds
- setup_nets_config['request']['networks'] = non_ovs_nets
- log('Hook finished, returning non-OVS networks and bondings back '
- 'to VDSM: %s' % setup_nets_config)
+ inRollback = setup_nets_config['request']['options'].get('_inRollback')
+ inOVSRollback = setup_nets_config['request']['options'].get(
+ '_inOVSRollback')
+
+ if inRollback and not inOVSRollback:
+ log('Non-OVS rollback is to be done. Returning nets_config unchanged')
+ elif inOVSRollback:
+ log('OVS rollback is to be done.')
+ _rollback(running_config)
+ setup_nets_config['request']['bondings'] = {}
+ setup_nets_config['request']['networks'] = {}
+ log('OVS rollback finished, returning empty networks and bondings '
+ 'configuration back to VDSM.')
+ else:
+ ovs_nets, non_ovs_nets, ovs_bonds, non_ovs_bonds = \
+ _separate_ovs_nets_bonds(networks, bondings, running_config)
+ _configure(ovs_nets, ovs_bonds, running_config)
+ setup_nets_config['request']['bondings'] = non_ovs_bonds
+ setup_nets_config['request']['networks'] = non_ovs_nets
+ log('Hook finished, returning non-OVS networks and bondings back to '
+ 'VDSM: %s' % setup_nets_config)
+
hooking.write_json(setup_nets_config)
diff --git a/vdsm_hooks/ovs/ovs_utils.py b/vdsm_hooks/ovs/ovs_utils.py
index 7375d20..d592b8f 100644
--- a/vdsm_hooks/ovs/ovs_utils.py
+++ b/vdsm_hooks/ovs/ovs_utils.py
@@ -18,19 +18,14 @@
# Refer to the README and COPYING files for full details of the license
#
from contextlib import contextmanager
-import sys
-
-from libvirt import libvirtError
+import errno
+import os
+import pickle
from hooking import execCmd
import hooking
from vdsm.utils import CommandPath
-from vdsm import supervdsm
-
-# TODO: move required modules into vdsm/lib
-sys.path.append('/usr/share/vdsm')
-from network.configurators import libvirt
EXT_IP = CommandPath('ip', '/sbin/ip').cmd
EXT_OVS_VSCTL = CommandPath('ovs-vsctl',
@@ -40,6 +35,8 @@
'/usr/sbin/ovs-appctl',
'/usr/bin/ovs-appctl').cmd
BRIDGE_NAME = 'ovsbr0'
+
+INIT_CONFIG_FILE = '/tmp/ovs_init_config' # TODO: VDSM tmp folder
def rget(dict, keys, default=None):
@@ -123,28 +120,30 @@
raise Exception('\n'.join(err))
-def rollback(running_config, initial_config):
- diff = running_config.diffFrom(initial_config)
- if diff:
- for libvirt_ovs_nets in (iter_ovs_nets(running_config.networks),
- iter_ovs_nets(initial_config.networks)):
- for net, attrs in libvirt_ovs_nets:
- with suppress(libvirtError): # network not found
- libvirt.removeNetwork(net)
-
- destroy_ovs_bridge()
- for net, attrs in running_config.networks.items():
- if is_ovs_network(attrs):
- running_config.networks.pop(net)
- for bond, attrs in running_config.bonds.items():
- if is_ovs_bond(attrs):
- running_config.bonds.pop(bond)
- running_config.save()
-
- supervdsm.getProxy().setupNetworks(
- initial_config.networks, initial_config.bonds,
- {'connectivityCheck': False, '_inRollback': True})
-
-
def log(message):
hooking.log('OVS: %s' % message)
+
+
+def load_init_config():
+ try:
+ with open(INIT_CONFIG_FILE) as f:
+ init_config = pickle.load(f)
+ except IOError as e:
+ if e.errno != errno.ENOENT:
+ raise
+ return None
+ else:
+ return init_config
+
+
+def save_init_config(init_config):
+ with open(INIT_CONFIG_FILE, 'w') as f:
+ pickle.dump(init_config, f)
+
+
+def remove_init_config():
+ try:
+ os.remove(INIT_CONFIG_FILE)
+ except OSError as e:
+ if e.errno != errno.ENOENT:
+ raise
--
To view, visit https://gerrit.ovirt.org/46907
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8f6b63d03bb9579e260bfad1686047a431f69543
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Petr Horáček <phoracek(a)redhat.com>
8 years, 6 months
Change in vdsm[master]: utils: allow retry of multiple functions
by ykaplan@redhat.com
Yeela Kaplan has uploaded a new change for review.
Change subject: utils: allow retry of multiple functions
......................................................................
utils: allow retry of multiple functions
Change-Id: I6c805ef33b710fbbe674ac62ae96c3fdf47423e1
Signed-off-by: Yeela Kaplan <ykaplan(a)redhat.com>
---
M lib/vdsm/libvirtconnection.py
M lib/vdsm/utils.py
M tests/functional/vmRecoveryTests.py
M tests/miscTests.py
M tests/remoteFileHandlerTests.py
M tests/utilsTests.py
M vdsm/clientIF.py
M vdsm/storage/hsm.py
M vdsm/supervdsm.py
9 files changed, 18 insertions(+), 13 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/36/36336/1
diff --git a/lib/vdsm/libvirtconnection.py b/lib/vdsm/libvirtconnection.py
index 492a02e..55af991 100644
--- a/lib/vdsm/libvirtconnection.py
+++ b/lib/vdsm/libvirtconnection.py
@@ -99,7 +99,7 @@
libvirtOpen = functools.partial(
libvirt.openAuth, uri, auth, 0)
- return utils.retry(libvirtOpen, timeout=10, sleep=0.2)
+ return utils.retry((libvirtOpen,), timeout=10, sleep=0.2)
def get(target=None, killOnFailure=True):
diff --git a/lib/vdsm/utils.py b/lib/vdsm/utils.py
index db38e0c..ed4dec6 100644
--- a/lib/vdsm/utils.py
+++ b/lib/vdsm/utils.py
@@ -903,13 +903,13 @@
return unicode(self.cmd)
-def retry(func, expectedException=Exception, tries=None,
+def retry(funcs, expectedException=Exception, tries=None,
timeout=None, sleep=1, stopCallback=None):
"""
- Retry a function. Wraps the retry logic so you don't have to
+ Retry functions. Wraps the retry logic so you don't have to
implement it each time you need it.
- :param func: The callable to run.
+ :param funcs: a tuple of the callables to run.
:param expectedException: The exception you expect to receive when the
function fails.
:param tries: The number of times to try. None\0,-1 means infinite.
@@ -932,7 +932,9 @@
while True:
tries -= 1
try:
- return func()
+ for func in funcs:
+ res = func()
+ return res
except expectedException:
if tries == 0:
raise
diff --git a/tests/functional/vmRecoveryTests.py b/tests/functional/vmRecoveryTests.py
index 37a96f3..0028f62 100644
--- a/tests/functional/vmRecoveryTests.py
+++ b/tests/functional/vmRecoveryTests.py
@@ -96,7 +96,8 @@
def ensure_vdsm_started(self):
vdsm.utils.retry(
- self.setUp, expectedException=(socket.error, KeyError), tries=10)
+ (self.setUp,), expectedException=(socket.error, KeyError),
+ tries=10)
@ValidateRunningAsRoot
def test_vm_recovery(self):
diff --git a/tests/miscTests.py b/tests/miscTests.py
index a955979..eb8b11d 100644
--- a/tests/miscTests.py
+++ b/tests/miscTests.py
@@ -1047,7 +1047,7 @@
nice = utils.pidStat(proc.pid).nice
self.assertEquals(nice, 10)
- utils.retry(AssertionError, test, tries=10, sleep=0.1)
+ utils.retry((test,), AssertionError, tries=10, sleep=0.1)
proc.kill()
proc.wait()
diff --git a/tests/remoteFileHandlerTests.py b/tests/remoteFileHandlerTests.py
index 0c62f60..c093c2d 100644
--- a/tests/remoteFileHandlerTests.py
+++ b/tests/remoteFileHandlerTests.py
@@ -70,7 +70,7 @@
p.stop()
test = lambda: self.assertFalse(os.path.exists(procPath))
- utils.retry(test, AssertionError, timeout=4, sleep=0.1)
+ utils.retry((test,), AssertionError, timeout=4, sleep=0.1)
class RemoteFileHandlerTruncateTests(TestCaseBase):
diff --git a/tests/utilsTests.py b/tests/utilsTests.py
index cb3da85..75119e8 100644
--- a/tests/utilsTests.py
+++ b/tests/utilsTests.py
@@ -57,7 +57,8 @@
"fool about it.")
# W. C. Fields
- self.assertRaises(RuntimeError, utils.retry, foo, tries=(limit + 10),
+ self.assertRaises(RuntimeError, utils.retry, (foo,),
+ tries=(limit + 10),
sleep=0, stopCallback=stopCallback)
# Make sure we had the proper amount of iterations before failing
self.assertEquals(counter[0], limit)
@@ -111,7 +112,7 @@
try:
test = lambda: self.assertEquals(utils.getCmdArgs(sproc.pid),
tuple())
- utils.retry(AssertionError, test, tries=10, sleep=0.1)
+ utils.retry((test,), AssertionError, tries=10, sleep=0.1)
finally:
sproc.wait()
diff --git a/vdsm/clientIF.py b/vdsm/clientIF.py
index 971d5ff..673975a 100644
--- a/vdsm/clientIF.py
+++ b/vdsm/clientIF.py
@@ -393,7 +393,7 @@
# Trying to run recover process until it works. During that time vdsm
# stays in recovery mode (_recover=True), means all api requests
# returns with "vdsm is in initializing process" message.
- utils.retry(self._recoverExistingVms, sleep=5)
+ utils.retry((self._recoverExistingVms,), sleep=5)
def _recoverExistingVms(self):
try:
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index c8aaf93..fa6eb5a 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -3155,7 +3155,7 @@
supervdsm.getProxy().appropriateDevice(guid, thiefId)
supervdsm.getProxy().udevTrigger(guid)
devPath = os.path.join(devicemapper.DMPATH_PREFIX, guid)
- utils.retry(partial(fileUtils.validateQemuReadable, devPath),
+ utils.retry((partial(fileUtils.validateQemuReadable, devPath),),
expectedException=OSError,
timeout=QEMU_READABLE_TIMEOUT)
diff --git a/vdsm/supervdsm.py b/vdsm/supervdsm.py
index 8e42af2..c29a1f2 100644
--- a/vdsm/supervdsm.py
+++ b/vdsm/supervdsm.py
@@ -75,7 +75,8 @@
self._manager.register('open')
self._log.debug("Trying to connect to Super Vdsm")
try:
- utils.retry(self._manager.connect, Exception, timeout=60, tries=3)
+ utils.retry((self._manager.connect,), Exception,
+ timeout=60, tries=3)
except Exception as ex:
msg = "Connect to supervdsm service failed: %s" % ex
utils.panic(msg)
--
To view, visit http://gerrit.ovirt.org/36336
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6c805ef33b710fbbe674ac62ae96c3fdf47423e1
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yeela Kaplan <ykaplan(a)redhat.com>
8 years, 6 months
Change in vdsm[master]: lib: add support for utillinux commands
by Federico Simoncelli
Federico Simoncelli has uploaded a new change for review.
Change subject: lib: add support for utillinux commands
......................................................................
lib: add support for utillinux commands
Change-Id: I2ea7dd19fadc600b8fe78fb436ae430d35f52165
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
---
M lib/vdsm/Makefile.am
A lib/vdsm/utillinux.py
M tests/Makefile.am
A tests/utillinuxTests.py
M vdsm.spec.in
5 files changed, 132 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/29/35629/1
diff --git a/lib/vdsm/Makefile.am b/lib/vdsm/Makefile.am
index b862e71..4e0868a 100644
--- a/lib/vdsm/Makefile.am
+++ b/lib/vdsm/Makefile.am
@@ -33,6 +33,7 @@
profile.py \
qemuimg.py \
sslutils.py \
+ utillinux.py \
utils.py \
vdscli.py \
virtsparsify.py \
diff --git a/lib/vdsm/utillinux.py b/lib/vdsm/utillinux.py
new file mode 100644
index 0000000..7fb42cf
--- /dev/null
+++ b/lib/vdsm/utillinux.py
@@ -0,0 +1,47 @@
+#
+# 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 os
+import re
+import signal
+
+from . import utils
+
+_blkdiscard = utils.CommandPath("blkdiscard",
+ "/sbin/blkdiscard",) # Fedora, EL6
+
+
+def blkdiscard(device, offset=None, length=None, secure=False):
+ cmd = [_blkdiscard.cmd]
+
+ if offset:
+ cmd.extend(("-o", str(offset)))
+
+ if length:
+ cmd.extend(("-l", str(length)))
+
+ if secure:
+ cmd.append("-s")
+
+ cmd.append(device)
+ rc, out, err = utils.execCmd(cmd, deathSignal=signal.SIGKILL)
+
+ if rc != 0:
+ raise QImgError(rc, out, err)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b365921..5aa9fc3 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -79,6 +79,7 @@
testlibTests.py \
toolTests.py \
transportWrapperTests.py \
+ utillinuxTests.py \
utilsTests.py \
vdsClientTests.py \
vmApiTests.py \
diff --git a/tests/utillinuxTests.py b/tests/utillinuxTests.py
new file mode 100644
index 0000000..dbbb50e
--- /dev/null
+++ b/tests/utillinuxTests.py
@@ -0,0 +1,82 @@
+#
+# 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
+#
+
+from testlib import VdsmTestCase as TestCaseBase
+import monkeypatch
+from vdsm import utillinux
+from vdsm import utils
+
+BLKDISCARD = utillinux._blkdiscard.cmd
+
+
+class FakeCmd(object):
+
+ def __init__(self, module, name, *calls):
+ self.patch = monkeypatch.Patch([(module, name, self)])
+ self.calls = list(calls)
+
+ def __call__(self, cmd, **kw):
+ call = self.calls.pop(0)
+ return call(cmd, **kw)
+
+ def __enter__(self):
+ self.patch.apply()
+
+ def __exit__(self, t=None, v=None, tb=None):
+ self.patch.revert()
+
+
+class BlkDiscardTests(TestCaseBase):
+
+ def test_no_options(self):
+ def discard(cmd, **kw):
+ expected = [BLKDISCARD, 'device']
+ self.assertEqual(cmd, expected)
+ return 0, '', ''
+
+ with FakeCmd(utils, 'execCmd', discard):
+ utillinux.blkdiscard('device')
+
+ def test_offset(self):
+ def discard(cmd, **kw):
+ expected = [BLKDISCARD, '-o', '1024', 'device']
+ self.assertEqual(cmd, expected)
+ return 0, '', ''
+
+ with FakeCmd(utils, 'execCmd', discard):
+ utillinux.blkdiscard('device', offset=1024)
+
+ def test_length(self):
+ def discard(cmd, **kw):
+ expected = [BLKDISCARD, '-l', '2048', 'device']
+ self.assertEqual(cmd, expected)
+ return 0, '', ''
+
+ with FakeCmd(utils, 'execCmd', discard):
+ utillinux.blkdiscard('device', length=2048)
+
+ def test_offset_and_length(self):
+ def discard(cmd, **kw):
+ expected = [BLKDISCARD, '-o', '1024', '-l', '2048', 'device']
+ self.assertEqual(cmd, expected)
+ return 0, '', ''
+
+ with FakeCmd(utils, 'execCmd', discard):
+ utillinux.blkdiscard('device', offset=1024, length=2048)
diff --git a/vdsm.spec.in b/vdsm.spec.in
index d15f5c2..befe0e0 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -1252,6 +1252,7 @@
%{python_sitelib}/%{vdsm_name}/qemuimg.py*
%{python_sitelib}/%{vdsm_name}/netconfpersistence.py*
%{python_sitelib}/%{vdsm_name}/sslutils.py*
+%{python_sitelib}/%{vdsm_name}/utillinux.py*
%{python_sitelib}/%{vdsm_name}/utils.py*
%{python_sitelib}/%{vdsm_name}/vdscli.py*
%{python_sitelib}/%{vdsm_name}/virtsparsify.py*
--
To view, visit http://gerrit.ovirt.org/35629
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2ea7dd19fadc600b8fe78fb436ae430d35f52165
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce(a)redhat.com>
8 years, 6 months
Change in vdsm[master]: lvm: Decrease number of retries before failing
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: lvm: Decrease number of retries before failing
......................................................................
lvm: Decrease number of retries before failing
Previously we configured lvm to stop accessing a device during an lvm
opoeration after 3 errors. This can cause lvm to block 3 times when
trying to access inaccessible device. With current iscsi settings, each
block can be 120 seconds, total 360 seconds. We have seen lvm block for
couple of minutes in such cases.
The retries seems uneeded when working with multiple paths, as multipath
already retry all available paths after SCSI errors on one path. However
when working with single path, multipath should fail after one try.
According to lvm developer this may decrease the time lvm is blocked
when devices are not accesible.
(Not tested yet)
Change-Id: I5d11abaaff45ce86e88c6589264e162318ac1f1d
Relates-To: https://bugzilla.redhat.com/880738
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M vdsm/storage/lvm.py
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/56/32356/1
diff --git a/vdsm/storage/lvm.py b/vdsm/storage/lvm.py
index 86edf55..f760f7b 100644
--- a/vdsm/storage/lvm.py
+++ b/vdsm/storage/lvm.py
@@ -106,7 +106,7 @@
preferred_names = ["^/dev/mapper/"]
ignore_suspended_devices=1
write_cache_state=0
-disable_after_error_count=3
+disable_after_error_count=1
obtain_device_list_from_udev=0
%s
}
--
To view, visit http://gerrit.ovirt.org/32356
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5d11abaaff45ce86e88c6589264e162318ac1f1d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
8 years, 6 months
Change in vdsm[master]: clusterlock: Remove uneeded workaround
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: clusterlock: Remove uneeded workaround
......................................................................
clusterlock: Remove uneeded workaround
Sanlock version XXXX had a off-by-one bug when calling get_hosts with a
host id, returning info for the next host. This bug is fixed in version
XXX. Now we can use the hostId parameter, making the call more efficient
and simpligying clusterlock code.
Change-Id: Ide75e749fbc2916540c2b526b78fedc247b5c6f9
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M vdsm.spec.in
M vdsm/storage/clusterlock.py
2 files changed, 5 insertions(+), 16 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/62/31162/1
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 5ba6fc6..fc39eb9 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -167,7 +167,7 @@
Requires: iscsi-initiator-utils >= 6.2.0.873-21
%endif
-Requires: sanlock >= 2.8, sanlock-python
+Requires: sanlock >= XXX, sanlock-python
%if 0%{?rhel}
Requires: python-ethtool >= 0.6-3
diff --git a/vdsm/storage/clusterlock.py b/vdsm/storage/clusterlock.py
index 24a5d81..17cdd53 100644
--- a/vdsm/storage/clusterlock.py
+++ b/vdsm/storage/clusterlock.py
@@ -265,26 +265,15 @@
return False
def getHostStatus(self, hostId):
- # Note: get_hosts has off-by-one bug when asking for particular host
- # id, so get all hosts info and filter.
- # See https://bugzilla.redhat.com/1111210
try:
- hosts = sanlock.get_hosts(self._sdUUID)
+ hosts = sanlock.get_hosts(self._sdUUID, hostId)
except sanlock.SanlockException as e:
self.log.debug("Unable to get host %d status in lockspace %s: %s",
hostId, self._sdUUID, e)
return HOST_STATUS_UNAVAILABLE
-
- for info in hosts:
- if info['host_id'] == hostId:
- status = info['flags']
- return self.STATUS_NAME[status]
-
- # get_hosts with host_id=0 returns only hosts with timestamp != 0,
- # which means that no host is using this host id now. If there a
- # timestamp, sanlock will return HOST_UNKNOWN and then HOST_LIVE or
- # HOST_FAIL.
- return HOST_STATUS_FREE
+ else:
+ status = hosts[0]['flags']
+ return self.STATUS_NAME[status]
# The hostId parameter is maintained here only for compatibility with
# ClusterLock. We could consider to remove it in the future but keeping it
--
To view, visit http://gerrit.ovirt.org/31162
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ide75e749fbc2916540c2b526b78fedc247b5c6f9
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
8 years, 6 months
Change in vdsm[master]: migration: Add support for max migration bandwidth setting
by tjelinek@redhat.com
Tomas Jelinek has uploaded a new change for review.
Change subject: migration: Add support for max migration bandwidth setting
......................................................................
migration: Add support for max migration bandwidth setting
Enriched the migrate verb by maxBandwidth.
It is an optional argument and the fallback is to migration_max_bandwidth from
config.
Feature-Page: http://www.ovirt.org/Features/Migration_Enhancements
Change-Id: I9d99e488a9e8bb80b0c3c069628171c666f3bf4b
Signed-off-by: Tomas Jelinek <tjelinek(a)redhat.com>
---
M client/vdsClient.py
M vdsm/API.py
M vdsm/virt/migration.py
3 files changed, 6 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/46/46846/1
diff --git a/client/vdsClient.py b/client/vdsClient.py
index 71b559a..29f6ba4 100755
--- a/client/vdsClient.py
+++ b/client/vdsClient.py
@@ -2221,13 +2221,14 @@
'migrate': (serv.do_migrate,
('vmId=<id> method=<offline|online> src=<host[:port]> '
'dst=<host[:port]> dstqemu=<host> [consoleAddress:str] '
- '[autoConverge:bool] [compressed:bool]',
+ '[autoConverge:bool] [compressed:bool] [maxBandwidth:int]',
'Migrate a desktop from src machine to dst host using '
'the specified ports and an optional address for '
'migration data traffic.',
'o consoleAddress: destination host grapics address',
'o autoConverge: force convergence during migration',
'o compressed: compress repeated pages during migration'
+ 'o maxBandwidth: max bandwidth used by this migration'
)),
'migrateStatus': (serv.do_mStat,
('<vmId>',
diff --git a/vdsm/API.py b/vdsm/API.py
index e3b9241..8b5eb1b 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -532,6 +532,7 @@
*dstqemu* - remote host address dedicated for migration
*compressed* - compress repeated pages during live migration
*autoConverge* - force convergence during live migration
+ *maxBandwidth* - max bandwidth used by this specific migration
"""
params['vmId'] = self._UUID
self.log.debug(params)
diff --git a/vdsm/virt/migration.py b/vdsm/virt/migration.py
index 32caccb..46bbfee 100644
--- a/vdsm/virt/migration.py
+++ b/vdsm/virt/migration.py
@@ -93,6 +93,8 @@
self._dstqemu = dstqemu
self._downtime = kwargs.get('downtime') or \
config.get('vars', 'migration_downtime')
+ self._maxBandwidth = kwargs.get('maxBandwidth') or \
+ config.getint('vars', 'migration_max_bandwidth')
self._autoConverge = autoConverge
self._compressed = compressed
self.status = {
@@ -371,7 +373,6 @@
SPICE_MIGRATION_HANDOVER_TIME = 120
self._vm._reviveTicket(SPICE_MIGRATION_HANDOVER_TIME)
- maxBandwidth = config.getint('vars', 'migration_max_bandwidth')
# FIXME: there still a race here with libvirt,
# if we call stop() and libvirt migrateToURI3 didn't start
# we may return migration stop but it will start at libvirt
@@ -380,7 +381,7 @@
if not self._migrationCanceledEvt:
# TODO: use libvirt constants when bz#1222795 is fixed
params = {VIR_MIGRATE_PARAM_URI: str(muri),
- VIR_MIGRATE_PARAM_BANDWIDTH: maxBandwidth}
+ VIR_MIGRATE_PARAM_BANDWIDTH: int(self._maxBandwidth)}
if self._consoleAddress:
if self._vm.hasSpice:
graphics = 'spice'
--
To view, visit https://gerrit.ovirt.org/46846
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9d99e488a9e8bb80b0c3c069628171c666f3bf4b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Tomas Jelinek <tjelinek(a)redhat.com>
8 years, 6 months
Change in vdsm[master]: migration added migrateChangeParams verb
by tjelinek@redhat.com
Tomas Jelinek has uploaded a new change for review.
Change subject: migration added migrateChangeParams verb
......................................................................
migration added migrateChangeParams verb
Currently it contains only the bandwidth but it will be used also for
convergenceSchedule in future.
Feature-Page: http://www.ovirt.org/Features/Migration_Enhancements
Change-Id: I52219c0e1f7d619dd30441dd4c70bd401f91e56d
Signed-off-by: Tomas Jelinek <tjelinek(a)redhat.com>
---
M vdsm/API.py
M vdsm/rpc/bindingxmlrpc.py
M vdsm/rpc/vdsmapi-schema.json
M vdsm/virt/migration.py
M vdsm/virt/vm.py
5 files changed, 60 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/34/46934/1
diff --git a/vdsm/API.py b/vdsm/API.py
index e3b9241..ffca8d3 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -551,6 +551,19 @@
params['mode'] = 'remote'
return v.migrate(params)
+ def migrateChangeParams(self, params):
+ """
+ Change parameters of an ongoing migration
+
+ :param params: a dictionary containing:
+ *maxBandwidth* - new max bandwidth
+ """
+ try:
+ v = self._cif.vmContainer[self._UUID]
+ except KeyError:
+ return errCode['noVM']
+ return v.migrateChangeParams(params)
+
def migrateCancel(self):
"""
Cancel a currently outgoing migration process.
diff --git a/vdsm/rpc/bindingxmlrpc.py b/vdsm/rpc/bindingxmlrpc.py
index 4c69b32..68e03cd 100644
--- a/vdsm/rpc/bindingxmlrpc.py
+++ b/vdsm/rpc/bindingxmlrpc.py
@@ -453,6 +453,10 @@
vm = API.VM(vmId)
return vm.migrateCancel()
+ def vmMigrateChangeParams(self, vmId, params):
+ vm = API.VM(vmId)
+ return vm.migrateChangeParams(params)
+
def vmHotplugDisk(self, params):
vm = API.VM(params['vmId'])
return vm.hotplugDisk(params)
@@ -1067,6 +1071,7 @@
(self.vmMigrate, 'migrate'),
(self.vmGetMigrationStatus, 'migrateStatus'),
(self.vmMigrationCancel, 'migrateCancel'),
+ (self.vmMigrateChangeParams, 'vmMigrateChangeParams'),
(self.getCapabilities, 'getVdsCapabilities'),
(self.getHardwareInfo, 'getVdsHardwareInfo'),
(self.diskGetAlignment, 'getDiskAlignment'),
diff --git a/vdsm/rpc/vdsmapi-schema.json b/vdsm/rpc/vdsmapi-schema.json
index 7eaf04d..3bd87a8 100644
--- a/vdsm/rpc/vdsmapi-schema.json
+++ b/vdsm/rpc/vdsmapi-schema.json
@@ -7752,6 +7752,32 @@
'data': {'vmID': 'UUID'}}
##
+# @MigrateChangeParamsParams:
+#
+# Parameters for @VM.migrateChangeParams
+#
+# @maxBandwidth: #optional the new bandwidth
+#
+# Since: TODO
+##
+{'type': 'MigrateChangeParamsParams',
+ 'data': {'*maxBandwidth': 'int'}}
+
+##
+# @VM.migrateChangeParams:
+#
+# Change parameters of an ongoing migration
+#
+# @vmID: The UUID of the VM
+#
+# @params: The new parameters
+#
+# Since: TODO
+##
+{'command': {'class': 'VM', 'name': 'migrateChangeParams'},
+ 'data': {'vmID': 'UUID', 'params': 'MigrateChangeParamsParams'}}
+
+##
# @MigrationCreateState:
#
# Reports the state of a VM creation on the destination host.
diff --git a/vdsm/virt/migration.py b/vdsm/virt/migration.py
index 32caccb..14ce93e 100644
--- a/vdsm/virt/migration.py
+++ b/vdsm/virt/migration.py
@@ -404,6 +404,17 @@
else:
self._raiseAbortError()
+ def migrateChangeParams(self, params):
+ if 'maxBandwidth' in params:
+ self._set_max_bandwidth(params['maxBandwidth'])
+
+ def _set_max_bandwidth(self, bandwidth):
+ self._vm.log.debug('setting migration max bandwidth to %d', bandwidth)
+ self._maxBandwidth = int(bandwidth)
+ self._vm._dom.migrateSetMaxSpeed(int(bandwidth))
+ self._vm.log.debug('bandwidth set successfully')
+
+
def stop(self):
# if its locks we are before the migrateToURI3()
# call so no need to abortJob()
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index b8ec3d4..26eedc3 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -1546,6 +1546,11 @@
finally:
self._guestCpuLock.release()
+ def migrateChangeParams(self, params):
+ # TODO check if the self._acquireCpuLockWithTimeout() is needed here
+ self._migrationSourceThread.migrateChangeParams(params)
+ return {'status': doneCode}
+
def _customDevices(self):
"""
Get all devices that have custom properties
--
To view, visit https://gerrit.ovirt.org/46934
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I52219c0e1f7d619dd30441dd4c70bd401f91e56d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Tomas Jelinek <tjelinek(a)redhat.com>
8 years, 6 months