From Dan Kenigsberg <danken(a)redhat.com>:
Dan Kenigsberg has uploaded a new change for review.
Change subject: use os.path.join with P_VDSM_RUN
......................................................................
use os.path.join with P_VDSM_RUN
In three places the code assumes that P_VDSM_RUN ends with a slash.
Using os.path.join makes the code a bit more robust to common slash
forgetfulness. This makes it possible to make a couple of tests slightly
less ugly.
Change-Id: I51b14fca58345430a8556301b781e9f55713a55b
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
---
M lib/vdsm/constants.py.in
M lib/vdsm/network/dhclient_monitor.py
M lib/vdsm/network/ifacetracking.py
M tests/vm_test.py
M tests/vmfakelib.py
M tests/vmrecovery_test.py
6 files changed, 8 insertions(+), 8 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/13/70313/1
diff --git a/lib/vdsm/constants.py.in b/lib/vdsm/constants.py.in
index 44a36b9..e109bc6 100644
--- a/lib/vdsm/constants.py.in
+++ b/lib/vdsm/constants.py.in
@@ -80,7 +80,7 @@
P_VDSM_HOOKS = '@HOOKSDIR@/' # NOQA: E501 (potentially long line)
P_VDSM_LIB = '@VDSMLIBDIR@/' # NOQA: E501 (potentially long line)
P_VDSM_RUN = '@VDSMRUNDIR@/' # NOQA: E501 (potentially long line)
-P_VDSM_STORAGE = P_VDSM_RUN + 'storage/'
+P_VDSM_STORAGE = os.path.join(P_VDSM_RUN, 'storage/')
P_VDSM_CONF = '@CONFDIR@/' # NOQA: E501 (potentially long line)
P_VDSM_KEYS = '/etc/pki/vdsm/keys/'
P_VDSM_CERT = '/etc/pki/vdsm/certs/vdsmcert.pem'
diff --git a/lib/vdsm/network/dhclient_monitor.py b/lib/vdsm/network/dhclient_monitor.py
index 4a86960..4e7944e 100644
--- a/lib/vdsm/network/dhclient_monitor.py
+++ b/lib/vdsm/network/dhclient_monitor.py
@@ -41,7 +41,7 @@
IFACE_KEY = 'iface'
-MONITOR_FOLDER = P_VDSM_RUN + 'sourceRoutes'
+MONITOR_FOLDER = os.path.join(P_VDSM_RUN, 'sourceRoutes')
def start():
diff --git a/lib/vdsm/network/ifacetracking.py b/lib/vdsm/network/ifacetracking.py
index ffa3071..d1142b2 100644
--- a/lib/vdsm/network/ifacetracking.py
+++ b/lib/vdsm/network/ifacetracking.py
@@ -25,7 +25,7 @@
from vdsm.utils import rmFile
-TRACKED_INTERFACES_FOLDER = P_VDSM_RUN + 'trackedInterfaces'
+TRACKED_INTERFACES_FOLDER = os.path.join(P_VDSM_RUN, 'trackedInterfaces')
def add(device_name):
diff --git a/tests/vm_test.py b/tests/vm_test.py
index c7324cf..b0b2ff5 100644
--- a/tests/vm_test.py
+++ b/tests/vm_test.py
@@ -106,7 +106,7 @@
def assertBuildCmdLine(self, confToDom):
with namedTemporaryDir() as tmpDir:
- with MonkeyPatchScope([(constants, 'P_VDSM_RUN', tmpDir +
'/')]):
+ with MonkeyPatchScope([(constants, 'P_VDSM_RUN', tmpDir)]):
for conf, expectedXML in confToDom:
expectedXML = expectedXML % conf
diff --git a/tests/vmfakelib.py b/tests/vmfakelib.py
index c240c19..5a5e630 100644
--- a/tests/vmfakelib.py
+++ b/tests/vmfakelib.py
@@ -240,7 +240,7 @@
cif=None, create_device_objects=False,
post_copy=None):
with namedTemporaryDir() as tmpDir:
- with MonkeyPatchScope([(constants, 'P_VDSM_RUN', tmpDir + '/'),
+ with MonkeyPatchScope([(constants, 'P_VDSM_RUN', tmpDir),
(libvirtconnection, 'get', Connection),
(containersconnection, 'get', Connection),
(vm.Vm, 'send_status_event',
diff --git a/tests/vmrecovery_test.py b/tests/vmrecovery_test.py
index 2c8cc15..d69c872 100644
--- a/tests/vmrecovery_test.py
+++ b/tests/vmrecovery_test.py
@@ -140,7 +140,7 @@
@contextlib.contextmanager
def setup_env(self):
with fake.VM() as testvm, namedTemporaryDir() as tmpdir:
- with MonkeyPatchScope([(constants, 'P_VDSM_RUN', tmpdir +
'/')]):
+ with MonkeyPatchScope([(constants, 'P_VDSM_RUN', tmpdir)]):
yield testvm, tmpdir
@@ -188,7 +188,7 @@
def test_clean_vm_files(self):
with fake.VM() as testvm, namedTemporaryDir() as tmpdir:
- with MonkeyPatchScope([(constants, 'P_VDSM_RUN', tmpdir +
'/')]):
+ with MonkeyPatchScope([(constants, 'P_VDSM_RUN', tmpdir)]):
stored = recovery.File(testvm.id)
stored.save(testvm)
@@ -212,7 +212,7 @@
with namedTemporaryDir() as tmpdir:
with MonkeyPatchScope([
- (constants, 'P_VDSM_RUN', tmpdir + '/'),
+ (constants, 'P_VDSM_RUN', tmpdir),
(recovery, '_list_domains', lambda: []),
(containersconnection, 'recovery', lambda: []),
]):
--
To view, visit
https://gerrit.ovirt.org/70313
To unsubscribe, visit
https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I51b14fca58345430a8556301b781e9f55713a55b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>