Change in vdsm[ovirt-4.0]: net: canonicalize IPv4 prefix to netmask
by phoracek@redhat.com
Petr Horáček has uploaded a new change for review.
Change subject: net: canonicalize IPv4 prefix to netmask
......................................................................
net: canonicalize IPv4 prefix to netmask
In order to fix OVS switch, this patch moves canonicalization of
passed IPv4 prefix into netmask from legacy_switch.py to
canonicalize.py.
It also adds missing 'prefix' to setupNetworks documentation.
Change-Id: I344eef120b4c19f90d4dd20c7857bb73ab259e9b
Bug-Url: https://bugzilla.redhat.com/1374194
Signed-off-by: Petr Horáček <phoracek(a)redhat.com>
---
M lib/vdsm/network/api.py
M lib/vdsm/network/canonicalize.py
M lib/vdsm/network/legacy_switch.py
M tests/network/func_static_ip_test.py
M tests/network/netfunctestlib.py
5 files changed, 30 insertions(+), 14 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/07/64507/1
diff --git a/lib/vdsm/network/api.py b/lib/vdsm/network/api.py
index 799686f..1b5ab48 100644
--- a/lib/vdsm/network/api.py
+++ b/lib/vdsm/network/api.py
@@ -209,7 +209,7 @@
bonding="<name>" | nic="<name>"
(bonding and nics are mutually exclusive)
ipaddr="<ipv4>"
- netmask="<ipv4>"
+ netmask="<ipv4>" | prefix=<prefixlen>
gateway="<ipv4>"
bootproto="..."
ipv6addr="<ipv6>[/<prefixlen>]"
diff --git a/lib/vdsm/network/canonicalize.py b/lib/vdsm/network/canonicalize.py
index b0bc983..3468796 100644
--- a/lib/vdsm/network/canonicalize.py
+++ b/lib/vdsm/network/canonicalize.py
@@ -22,6 +22,7 @@
import six
from .netinfo import bridges, mtus, bonding, dns
+from .netinfo.addresses import prefix2netmask
from vdsm import utils
from .errors import ConfigNetworkError
@@ -47,6 +48,7 @@
_canonicalize_switch_type_net(attrs)
_canonicalize_ip_default_route(attrs)
_canonicalize_nameservers(attrs)
+ _canonicalize_prefix(attrs)
def canonicalize_bondings(bonds):
@@ -138,3 +140,15 @@
data['nameservers'] = dns.get_host_nameservers()
else:
data['nameservers'] = []
+
+
+def _canonicalize_prefix(data):
+ prefix = data.pop('prefix', None)
+ if prefix:
+ if 'netmask' in data:
+ raise ConfigNetworkError(
+ ne.ERR_BAD_PARAMS, 'Both PREFIX and NETMASK supplied')
+ try:
+ data['netmask'] = prefix2netmask(int(prefix))
+ except ValueError as ve:
+ raise ConfigNetworkError(ne.ERR_BAD_ADDR, 'Bad prefix: %s' % ve)
diff --git a/lib/vdsm/network/legacy_switch.py b/lib/vdsm/network/legacy_switch.py
index 05a62c2..8d426ec 100644
--- a/lib/vdsm/network/legacy_switch.py
+++ b/lib/vdsm/network/legacy_switch.py
@@ -30,7 +30,6 @@
from vdsm.network import kernelconfig
from vdsm.network import libvirt
from vdsm.network.netinfo import NET_PATH
-from vdsm.network.netinfo import addresses
from vdsm.network.netinfo import bridges
from vdsm.network.netinfo import mtus
from vdsm.network.netinfo import nics as netinfo_nics
@@ -187,7 +186,7 @@
@_alter_running_config
def _add_network(network, configurator, nameservers,
vlan=None, bonding=None, nic=None, ipaddr=None,
- netmask=None, prefix=None, mtu=None, gateway=None,
+ netmask=None, mtu=None, gateway=None,
dhcpv6=None, ipv6addr=None, ipv6gateway=None,
ipv6autoconf=None, bridged=True, _netinfo=None, hostQos=None,
defaultRoute=None, blockingdhcp=False, **options):
@@ -201,16 +200,6 @@
if network == '':
raise ConfigNetworkError(ne.ERR_BAD_BRIDGE,
'Empty network names are not valid')
- if prefix:
- if netmask:
- raise ConfigNetworkError(ne.ERR_BAD_PARAMS,
- 'Both PREFIX and NETMASK supplied')
- else:
- try:
- netmask = addresses.prefix2netmask(int(prefix))
- except ValueError as ve:
- raise ConfigNetworkError(ne.ERR_BAD_ADDR, 'Bad prefix: %s' %
- ve)
logging.debug('Validating network...')
if network in _netinfo.networks:
diff --git a/tests/network/func_static_ip_test.py b/tests/network/func_static_ip_test.py
index 136a44c..e9bfdb2 100644
--- a/tests/network/func_static_ip_test.py
+++ b/tests/network/func_static_ip_test.py
@@ -108,6 +108,17 @@
with self.setupNetworks(netcreate, bondcreate, NOCHK):
self.assertNetworkIp(NETWORK_NAME, netcreate[NETWORK_NAME])
+ def test_add_net_with_prefix(self):
+ with dummy_device() as nic:
+ network_attrs = {'nic': nic,
+ 'ipaddr': IPv4_ADDRESS,
+ 'prefix': IPv4_PREFIX_LEN,
+ 'switch': self.switch}
+ netcreate = {NETWORK_NAME: network_attrs}
+
+ with self.setupNetworks(netcreate, {}, NOCHK):
+ self.assertNetworkIp(NETWORK_NAME, netcreate[NETWORK_NAME])
+
@attr(type='functional', switch='legacy')
class NetworkStaticIpBasicLegacyTest(NetworkStaticIpBasicTemplate):
diff --git a/tests/network/netfunctestlib.py b/tests/network/netfunctestlib.py
index 7b59fa8..9e9b14f 100644
--- a/tests/network/netfunctestlib.py
+++ b/tests/network/netfunctestlib.py
@@ -30,6 +30,7 @@
from vdsm.network import kernelconfig
from vdsm.network.ip import dhclient
from vdsm.network.ip.address import ipv6_supported
+from vdsm.network.netinfo.addresses import prefix2netmask
from vdsm.network.netinfo.nics import operstate
from testlib import VdsmTestCase
@@ -283,7 +284,8 @@
def assertStaticIPv4(self, netattrs, ipinfo):
requires_ipaddress()
address = netattrs['ipaddr']
- netmask = netattrs['netmask']
+ netmask = (netattrs.get('netmask') or
+ prefix2netmask(int(netattrs.get('prefix'))))
self.assertEqual(address, ipinfo['addr'])
self.assertEqual(netmask, ipinfo['netmask'])
ipv4 = ipaddress.IPv4Interface(
--
To view, visit https://gerrit.ovirt.org/64507
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I344eef120b4c19f90d4dd20c7857bb73ab259e9b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-4.0
Gerrit-Owner: Petr Horáček <phoracek(a)redhat.com>
6 years, 7 months
Change in vdsm[master]: build: Remove build requires needed for the tests
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: build: Remove build requires needed for the tests
......................................................................
build: Remove build requires needed for the tests
We are not running the tests during the build, so we don't need to pull
these packages. These packages are installed in the CI using
automation/check-patch.packages. Developers should also use the same
file for setting up a development environment.
Change-Id: I3c385b0abeb2657a26215ce5b96976cc290734bb
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M vdsm.spec.in
1 file changed, 1 insertion(+), 55 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/00/65500/1
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 9252530..e4806fe 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -57,54 +57,10 @@
%{!?_licensedir:%global license %%doc}
-BuildRequires: cyrus-sasl-lib
BuildRequires: python
BuildRequires: python2-devel
-BuildRequires: python-mock
-BuildRequires: python-netaddr
-BuildRequires: python-six >= 1.9.0
BuildRequires: rpm-build
-
-# BuildRequires needed by the tests during the build
-BuildRequires: dosfstools
-BuildRequires: genisoimage
-BuildRequires: libnl3
-BuildRequires: libselinux-python
-BuildRequires: libvirt-python
-BuildRequires: m2crypto
-BuildRequires: mom >= 0.5.5
-BuildRequires: openssl
-BuildRequires: policycoreutils-python
-BuildRequires: psmisc
-BuildRequires: PyYAML
-BuildRequires: python-cpopen >= 1.4-1
-BuildRequires: python-inotify
-BuildRequires: python-ioprocess >= 0.16.1-1
-BuildRequires: python-pthreading
-BuildRequires: qemu-img
-BuildRequires: rpm-python
-%if 0%{?with_gluster_mgmt}
-BuildRequires: python-blivet
-%endif
-BuildRequires: sanlock-python
-
-%if 0%{?with_openvswitch}
-BuildRequires: openvswitch >= 2.0.0
-%endif
-
-%if 0%{?with_python3}
-%if 0%{?rhel}
-BuildRequires: python34-nose
-BuildRequires: python34-six
-%else # fedora
-BuildRequires: python3-nose
-BuildRequires: python3-six
-BuildRequires: python3-netaddr
-BuildRequires: python3-yaml
-BuildRequires: libselinux-python3
-BuildRequires: libvirt-python3
-%endif # rhel
-%endif # support python3
+BuildRequires: systemd-units
# Autotools BuildRequires
%if 0%{?enable_autotools}
@@ -114,16 +70,6 @@
BuildRequires: libtool
%endif
-BuildRequires: systemd-units
-
-%if 0%{?rhel}
-BuildRequires: python-decorator
-%endif # rhel
-
-%if 0%{?fedora}
-BuildRequires: python2-decorator
-BuildRequires: python3-decorator
-%endif
# Numactl is not available on s390[x] and ARM
%ifnarch s390 s390x %{arm}
--
To view, visit https://gerrit.ovirt.org/65500
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3c385b0abeb2657a26215ce5b96976cc290734bb
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
6 years, 7 months
Change in vdsm[master]: build: Disable tests during build
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: build: Disable tests during build
......................................................................
build: Disable tests during build
Tests are needed for development, not for building a package. This
allows us to use latest and greatest development tools, which are not
available in brew or koji.
Since we install nose using pip, remove the build requires - we don't
need now nose to build rpms.
Change-Id: I9e3589c365166f934f117b53c65cea4b90db3516
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M vdsm.spec.in
1 file changed, 0 insertions(+), 6 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/66/63966/1
diff --git a/vdsm.spec.in b/vdsm.spec.in
index f234b09..c7f6dde 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -62,7 +62,6 @@
BuildRequires: python2-devel
BuildRequires: python-mock
BuildRequires: python-netaddr
-BuildRequires: python-nose
BuildRequires: python-six >= 1.9.0
BuildRequires: rpm-build
@@ -95,10 +94,8 @@
%if 0%{?with_python3}
%if 0%{?rhel}
-BuildRequires: python34-nose
BuildRequires: python34-six
%else # fedora
-BuildRequires: python3-nose
BuildRequires: python3-six
BuildRequires: python3-netaddr
BuildRequires: python3-yaml
@@ -781,9 +778,6 @@
# Install the libvirt hook for cleaning up the XML
install -Dm 0755 vdsm/virt/libvirt-hook.sh \
%{buildroot}%{_sysconfdir}/libvirt/hooks/qemu
-
-%check
-make tests
%pre
# Force standard locale behavior (English)
--
To view, visit https://gerrit.ovirt.org/63966
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9e3589c365166f934f117b53c65cea4b90db3516
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
6 years, 7 months
Change in vdsm[master]: utils: Wait for terminated process
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: utils: Wait for terminated process
......................................................................
utils: Wait for terminated process
utils.terminating was not waiting for a terminated process, passing the
process to zombiereaper. This behavior may be disastrous storage and
mostly unwanted for other code.
When we run a child process touching shared storage, we must wait for
the child process. If we kill the child process without waiting, engine
may start the same operation on another host, while the original child
process is still running, possibly in interruptible state, trying to
write to storage.
To avoid this issue, we always invoke wait() after killing the process.
Special code that do not want to wait for the child process should not
use this context manager.
Change-Id: Ida04e2c7ba092efdc2927ed9f460b0098ba2ad94
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M lib/vdsm/utils.py
M tests/utilsTests.py
2 files changed, 7 insertions(+), 34 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/24/65324/1
diff --git a/lib/vdsm/utils.py b/lib/vdsm/utils.py
index a428c8e..e5c28b8 100644
--- a/lib/vdsm/utils.py
+++ b/lib/vdsm/utils.py
@@ -738,8 +738,7 @@
if proc.poll() is None:
logging.debug('Terminating process pid=%d' % proc.pid)
proc.kill()
- if proc.poll() is None:
- zombiereaper.autoReapPID(proc.pid)
+ proc.wait()
except Exception:
logging.exception('Failed to kill process %d' % proc.pid)
diff --git a/tests/utilsTests.py b/tests/utilsTests.py
index 388a65d..6ff85d4 100644
--- a/tests/utilsTests.py
+++ b/tests/utilsTests.py
@@ -42,9 +42,8 @@
from vdsm import cmdutils
from vdsm import commands
from vdsm import panic
-from vdsm.common import zombiereaper
-from monkeypatch import MonkeyPatch, MonkeyPatchScope
+from monkeypatch import MonkeyPatch
from vmTestsData import VM_STATUS_DUMP
from monkeypatch import Patch
from testlib import forked, online_cpus, namedTemporaryDir
@@ -83,22 +82,11 @@
self.patch.revert()
-def wait_for_removal(path, timeout, wait=0.1):
- deadline = utils.monotonic_time() + timeout
- while True:
- if not os.path.exists(path):
- return True
- if utils.monotonic_time() > deadline:
- return False
- time.sleep(wait)
-
-
class TerminatingTests(TestCaseBase):
def setUp(self):
self.proc = commands.execCmd([EXT_SLEEP, "2"], sync=False)
self.kill_proc = self.proc.kill
- self.reaped = set()
def tearDown(self):
if self.proc.poll() is None:
@@ -108,8 +96,7 @@
def test_terminating(self):
with utils.terminating(self.proc):
self.assertIsNone(self.proc.poll())
- proc_path = "/proc/%d" % self.proc.pid
- self.assertTrue(wait_for_removal(proc_path, timeout=1))
+ self.assertEqual(self.proc.returncode, -signal.SIGKILL)
def test_terminating_with_kill_exception(self):
class FakeKillError(Exception):
@@ -118,24 +105,11 @@
def fake_kill():
raise FakeKillError("fake kill exception")
- with MonkeyPatchScope([(zombiereaper,
- 'autoReapPID',
- self.reaped.add
- )]):
- self.proc.kill = fake_kill
- with utils.terminating(self.proc):
- self.assertIsNone(self.proc.poll())
- self.assertTrue(self.proc.pid not in self.reaped)
+ self.proc.kill = fake_kill
+ with utils.terminating(self.proc):
+ self.assertIsNone(self.proc.poll())
- def test_terminating_with_infected_kill(self):
- with MonkeyPatchScope([(zombiereaper,
- 'autoReapPID',
- self.reaped.add
- )]):
- self.proc.kill = lambda: None
- with utils.terminating(self.proc):
- self.assertIsNone(self.proc.poll())
- self.assertTrue(self.proc.pid in self.reaped)
+ self.assertIsNone(self.proc.returncode)
class RetryTests(TestCaseBase):
--
To view, visit https://gerrit.ovirt.org/65324
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ida04e2c7ba092efdc2927ed9f460b0098ba2ad94
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
6 years, 7 months
Change in vdsm[master]: readme: Fix build status url
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: readme: Fix build status url
......................................................................
readme: Fix build status url
Previously we pointed to Nir's private fork, now that oVirt's github is
triggering builds we should point to the correct builds.
Change-Id: If40bda074383ffa1c4626bb7e68a6035cf7039e3
Signed-off-by: Nir Soffer <nirsof(a)gmail.com>
---
M README.md
1 file changed, 2 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/04/65904/1
diff --git a/README.md b/README.md
index e253d3a..d3ba4c8 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# Vdsm: Virtual Desktop Server Manager
-[]
-(https://travis-ci.org/nirs/vdsm)
+[]
+(https://travis-ci.org/oVirt/vdsm)
The Vdsm service exposes an API for managing virtualization
hosts running the KVM hypervisor technology. Vdsm manages and monitors
--
To view, visit https://gerrit.ovirt.org/65904
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If40bda074383ffa1c4626bb7e68a6035cf7039e3
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
6 years, 7 months