Change in vdsm[master]: net: lookup dhclient file
Petr Horáček has posted comments on this change. Change subject: net: lookup dhclient file .. Patch Set 9: We can postpone this one. NM is not able to handle ifcfgs handled by ifacquire at this moment. -- To view, visit https://gerrit.ovirt.org/61918 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I94d2c35bfa8acfc808d3852d41b45b7df38c2c41 Gerrit-PatchSet: 9 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Petr HoráčekGerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Edward Haas Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Ondřej Svoboda Gerrit-Reviewer: Petr Horáček Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[master]: net: lookup dhclient file
Petr Horáček has posted comments on this change. Change subject: net: lookup dhclient file .. Patch Set 9: -Verified -- To view, visit https://gerrit.ovirt.org/61918 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I94d2c35bfa8acfc808d3852d41b45b7df38c2c41 Gerrit-PatchSet: 9 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Petr HoráčekGerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Edward Haas Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Ondřej Svoboda Gerrit-Reviewer: Petr Horáček Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[master]: net: lookup dhclient file
Petr Horáček has posted comments on this change. Change subject: net: lookup dhclient file .. Patch Set 9: Verified+1 Passed network/*test.py OK. -- To view, visit https://gerrit.ovirt.org/61918 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I94d2c35bfa8acfc808d3852d41b45b7df38c2c41 Gerrit-PatchSet: 9 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Petr HoráčekGerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Edward Haas Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Ondřej Svoboda Gerrit-Reviewer: Petr Horáček Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[master]: net: lookup dhclient file
gerrit-hooks has posted comments on this change. Change subject: net: lookup dhclient file .. Patch Set 9: * #1364081::Update tracker: OK * Check Bug-Url::OK * Check Public Bug::#1364081::OK, public bug * Check Product::#1364081::OK, Correct classification oVirt * Check TM::SKIP, not in a monitored branch (ovirt-3.6 ovirt-4.0) * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0']) -- To view, visit https://gerrit.ovirt.org/61918 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I94d2c35bfa8acfc808d3852d41b45b7df38c2c41 Gerrit-PatchSet: 9 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Petr HoráčekGerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Edward Haas Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Ondřej Svoboda Gerrit-Reviewer: Petr Horáček Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[master]: net: lookup dhclient file
gerrit-hooks has posted comments on this change. Change subject: net: lookup dhclient file .. Patch Set 8: * #1364081::Update tracker: OK * Check Bug-Url::OK * Check Public Bug::#1364081::OK, public bug * Check Product::#1364081::OK, Correct classification oVirt * Check TM::SKIP, not in a monitored branch (ovirt-3.6 ovirt-4.0) * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0']) -- To view, visit https://gerrit.ovirt.org/61918 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I94d2c35bfa8acfc808d3852d41b45b7df38c2c41 Gerrit-PatchSet: 8 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Petr HoráčekGerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Edward Haas Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Ondřej Svoboda Gerrit-Reviewer: Petr Horáček Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[master]: net: lookup dhclient file
gerrit-hooks has posted comments on this change. Change subject: net: lookup dhclient file .. Patch Set 7: * #1364081::Update tracker: OK * Check Bug-Url::OK * Check Public Bug::#1364081::OK, public bug * Check Product::#1364081::OK, Correct classification oVirt * Check TM::SKIP, not in a monitored branch (ovirt-3.6 ovirt-4.0) * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0']) -- To view, visit https://gerrit.ovirt.org/61918 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I94d2c35bfa8acfc808d3852d41b45b7df38c2c41 Gerrit-PatchSet: 7 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Petr HoráčekGerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Edward Haas Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Ondřej Svoboda Gerrit-Reviewer: Petr Horáček Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[master]: net: lookup dhclient file
gerrit-hooks has posted comments on this change. Change subject: net: lookup dhclient file .. Patch Set 6: * #1364081::Update tracker: OK * Check Bug-Url::OK * Check Public Bug::#1364081::OK, public bug * Check Product::#1364081::OK, Correct classification oVirt * Check TM::SKIP, not in a monitored branch (ovirt-3.6 ovirt-4.0) * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0']) -- To view, visit https://gerrit.ovirt.org/61918 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I94d2c35bfa8acfc808d3852d41b45b7df38c2c41 Gerrit-PatchSet: 6 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Petr HoráčekGerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Edward Haas Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Ondřej Svoboda Gerrit-Reviewer: Petr Horáček Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[master]: net: lookup dhclient file
Edward Haas has posted comments on this change. Change subject: net: lookup dhclient file .. Patch Set 5: Code-Review+1 -- To view, visit https://gerrit.ovirt.org/61918 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I94d2c35bfa8acfc808d3852d41b45b7df38c2c41 Gerrit-PatchSet: 5 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Petr HoráčekGerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Edward Haas Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Ondřej Svoboda Gerrit-Reviewer: Petr Horáček Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[master]: net: lookup dhclient file
gerrit-hooks has posted comments on this change. Change subject: net: lookup dhclient file .. Patch Set 5: * #1364081::Update tracker: OK * Check Bug-Url::OK * Check Public Bug::#1364081::OK, public bug * Check Product::#1364081::OK, Correct classification oVirt * Check TM::SKIP, not in a monitored branch (ovirt-3.6 ovirt-4.0) * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0']) -- To view, visit https://gerrit.ovirt.org/61918 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I94d2c35bfa8acfc808d3852d41b45b7df38c2c41 Gerrit-PatchSet: 5 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Petr HoráčekGerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Edward Haas Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Ondřej Svoboda Gerrit-Reviewer: Petr Horáček Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[master]: net: lookup dhclient file
gerrit-hooks has posted comments on this change. Change subject: net: lookup dhclient file .. Patch Set 4: * #1195208::Update tracker: OK * Check Bug-Url::OK * Check Public Bug::#1195208::OK, public bug * Check Product::#1195208::OK, Correct classification oVirt * Check TM::SKIP, not in a monitored branch (ovirt-3.6 ovirt-4.0) * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0']) -- To view, visit https://gerrit.ovirt.org/61918 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I94d2c35bfa8acfc808d3852d41b45b7df38c2c41 Gerrit-PatchSet: 4 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Petr HoráčekGerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Edward Haas Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Ondřej Svoboda Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[master]: net: lookup dhclient file
Petr Horáček has posted comments on this change. Change subject: net: lookup dhclient file .. Patch Set 3: (4 comments) https://gerrit.ovirt.org/#/c/61918/3/lib/vdsm/network/ip/dhclient.py File lib/vdsm/network/ip/dhclient.py: PS3, Line 113: extend > Can we use += ? Done PS3, Line 115: lease > Is this the dhclient lease? If so, please name it so. Done PS3, Line 121: elif len(leases) == 1: : return leases[0] > Why is this needed? The one below will handle this case as well. Optimalization. In most cases there should be only one lease file. In [2]: leases = ['/etc/sysconfig/network-scripts/ifcfg-enp0s25'] In [3]: def a(): ...: if len(leases) == 1: ...: return leases[0] ...: In [4]: import os In [5]: def b(): ...: return sorted(leases, key=os.path.getmtime, reverse=True)[0] ...: In [6]: timeit(a) Out[6]: 0.2383490680003888 In [7]: timeit(b) Out[7]: 3.6430967259998397 PS3, Line 128: _network_manager > _nm_lease_dir_exists Done -- To view, visit https://gerrit.ovirt.org/61918 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I94d2c35bfa8acfc808d3852d41b45b7df38c2c41 Gerrit-PatchSet: 3 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Petr HoráčekGerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Edward Haas Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Ondřej Svoboda Gerrit-Reviewer: Petr Horáček Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: Yes ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[master]: net: lookup dhclient file
Edward Haas has posted comments on this change. Change subject: net: lookup dhclient file .. Patch Set 3: Code-Review-1 (4 comments) Unit or Integration tests would be a nice add here. https://gerrit.ovirt.org/#/c/61918/3/lib/vdsm/network/ip/dhclient.py File lib/vdsm/network/ip/dhclient.py: PS3, Line 113: extend Can we use += ? PS3, Line 115: lease Is this the dhclient lease? If so, please name it so. PS3, Line 121: elif len(leases) == 1: : return leases[0] Why is this needed? The one below will handle this case as well. You should be able to drop the else then. PS3, Line 128: _network_manager _nm_lease_dir_exists -- To view, visit https://gerrit.ovirt.org/61918 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I94d2c35bfa8acfc808d3852d41b45b7df38c2c41 Gerrit-PatchSet: 3 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Petr HoráčekGerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Edward Haas Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Ondřej Svoboda Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: Yes ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[master]: net: lookup dhclient file
gerrit-hooks has posted comments on this change. Change subject: net: lookup dhclient file .. Patch Set 3: * #1195208::Update tracker: OK * Check Bug-Url::OK * Check Public Bug::#1195208::OK, public bug * Check Product::#1195208::OK, Correct classification oVirt * Check TM::SKIP, not in a monitored branch (ovirt-3.6 ovirt-4.0) * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0']) -- To view, visit https://gerrit.ovirt.org/61918 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I94d2c35bfa8acfc808d3852d41b45b7df38c2c41 Gerrit-PatchSet: 3 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Petr HoráčekGerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Edward Haas Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Ondřej Svoboda Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[master]: net: lookup dhclient file
gerrit-hooks has posted comments on this change. Change subject: net: lookup dhclient file .. Patch Set 2: * #1195208::Update tracker: OK * Check Bug-Url::OK * Check Public Bug::#1195208::OK, public bug * Check Product::#1195208::OK, Correct classification oVirt * Check TM::SKIP, not in a monitored branch (ovirt-3.6 ovirt-4.0) * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0']) -- To view, visit https://gerrit.ovirt.org/61918 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I94d2c35bfa8acfc808d3852d41b45b7df38c2c41 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Petr HoráčekGerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Edward Haas Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Ondřej Svoboda Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[master]: net: lookup dhclient file
gerrit-hooks has posted comments on this change. Change subject: net: lookup dhclient file .. Patch Set 1: * #1195208::Update tracker: OK * Check Bug-Url::OK * Check Public Bug::#1195208::OK, public bug * Check Product::#1195208::OK, Correct classification oVirt * Check TM::SKIP, not in a monitored branch (ovirt-3.6 ovirt-4.0) * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0']) -- To view, visit https://gerrit.ovirt.org/61918 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I94d2c35bfa8acfc808d3852d41b45b7df38c2c41 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Petr HoráčekGerrit-Reviewer: Jenkins CI Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[master]: net: lookup dhclient file
Petr Horáček has uploaded a new change for review. Change subject: net: lookup dhclient file .. net: lookup dhclient file Change-Id: I94d2c35bfa8acfc808d3852d41b45b7df38c2c41 Bug-Url: https://bugzilla.redhat.com/1195208 Signed-off-by: Petr Horáček--- M lib/vdsm/network/ip/dhclient.py 1 file changed, 38 insertions(+), 4 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/18/61918/1 diff --git a/lib/vdsm/network/ip/dhclient.py b/lib/vdsm/network/ip/dhclient.py index 318217c..95b3226 100644 --- a/lib/vdsm/network/ip/dhclient.py +++ b/lib/vdsm/network/ip/dhclient.py @@ -23,6 +23,7 @@ import errno import logging import os +import re import subprocess import threading @@ -36,6 +37,8 @@ DHCLIENT_CGROUP = 'vdsm-dhclient' LEASE_DIR = '/var/lib/dhclient' LEASE_FILE = os.path.join(LEASE_DIR, 'dhclient{0}--{1}.lease') +NM_LEASE_DIR = '/var/lib/NetworkManager' +NM_LEASE_FILE_REGEX = '^dhclient{0}-.*-{1}.lease$' class DhcpClient(object): @@ -46,8 +49,7 @@ self.iface = iface self.family = family self.default_route = default_route -self.duid_source_file = None if duid_source is None else ( -LEASE_FILE.format('' if family == 4 else '6', duid_source)) +self.duid_source = duid_source self.pidFile = self.PID_FILE % (family, self.iface) if not os.path.exists(LEASE_DIR): os.mkdir(LEASE_DIR) @@ -64,8 +66,10 @@ if not self.default_route: # Instruct Fedora/EL's dhclient-script not to set gateway on iface cmd += ['-e', 'DEFROUTE=no'] -if self.duid_source_file and supports_duid_file(): -cmd += ['-df', self.duid_source_file] +if self.duid_source and supports_duid_file(): +duid_source_file = _lease_file_lookup(self.iface, self.family) +if duid_source_file: +cmd += ['-df', duid_source_file] cmd = cmdutils.systemd_run(cmd, scope=True, slice=self._cgroup) return execCmd(cmd) @@ -102,6 +106,36 @@ return False +@memoized +def _network_manager(): +return os.path.exists(NM_LEASE_DIR) + + +def _lease_file_lookup(device_name, family): +if _network_manager(): +nm_lease = _newest_nm_lease(device_name, family) +if nm_lease: +return nm_lease + +lease = LEASE_FILE.format('' if family == 4 else '6', device_name) +if os.path.exists(lease): +return lease + + +def _newest_nm_lease(device_name, family): +regex = re.compile( +NM_LEASE_FILE_REGEX.format('' if family == 4 else '6', device_name)) +leases = [os.path.join(NM_LEASE_DIR, file) + for file in os.listdir(NM_LEASE_DIR) + if regex.match(file)] +if not leases: +return None +elif len(leases) == 1: +return leases[0] +else: +return sorted(leases, key=os.path.getmtime, reverse=True)[0] + + def _pid_lookup(device_name, family): for pid in pgrep('dhclient'): try: -- To view, visit https://gerrit.ovirt.org/61918 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I94d2c35bfa8acfc808d3852d41b45b7df38c2c41 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Petr Horáček ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org