Change in vdsm[master]: iproute2, netinfo: Change the location of our dhclient lease...

osvoboda at redhat.com osvoboda at redhat.com
Tue Aug 5 19:43:39 UTC 2014


Ondřej Svoboda has uploaded a new change for review.

Change subject: iproute2, netinfo: Change the location of our dhclient lease files
......................................................................

iproute2, netinfo: Change the location of our dhclient lease files

To prepare for DHCPv6 support, name the files 'dhclient[46]-iface.leases.
The plural not only mirrors the 'generate_lease_file_name' function
in initscripts but also reflects the fact that there is usually more
than one lease in the files.
DHCPv4 lease files now carry a '4' in the name for simplicity, explicitly
suggesting the DHCP flavour used.

Also simplify globs representing our and 3rd party lease files locations.

Change-Id: I0eb2d3c7b8163684f3bb8c59ad908a260d2138b6
Signed-off-by: Ondřej Svoboda <osvoboda at redhat.com>
---
M lib/vdsm/netinfo.py
M vdsm/network/configurators/dhclient.py
2 files changed, 7 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/11/31111/1

diff --git a/lib/vdsm/netinfo.py b/lib/vdsm/netinfo.py
index 95c3860..a3dc2ea 100644
--- a/lib/vdsm/netinfo.py
+++ b/lib/vdsm/netinfo.py
@@ -57,10 +57,8 @@
 
 # possible names of dhclient's lease files (e.g. as NetworkManager's slave)
 _DHCLIENT_LEASES_GLOBS = [
-    '/var/lib/dhclient/dhclient-*.lease',   # Fedora 20 legacy network service
-    '/var/lib/dhclient/dhclient-*.leases',  # RHEL 6.5 network service
+    '/var/lib/dhclient/dhclient*.lease*',  # iproute2 configurator, initscripts
     '/var/lib/NetworkManager/dhclient-*.lease',  # NetworkManager
-    '/var/lib/dhclient/dhclient.leases',  # default
 ]
 
 NET_CONF_PREF = NET_CONF_DIR + 'ifcfg-'
diff --git a/vdsm/network/configurators/dhclient.py b/vdsm/network/configurators/dhclient.py
index 0b83b24..4e02b91 100644
--- a/vdsm/network/configurators/dhclient.py
+++ b/vdsm/network/configurators/dhclient.py
@@ -32,17 +32,17 @@
 
 
 class DhcpClient(object):
-    PID_FILE = '/var/run/dhclient-%s.pid'
-    LEASE_DIR = '/var/lib/dhclient/'
-    LEASE_FILE = LEASE_DIR + 'dhclient-%s.lease'
+    PID_FILE = '/var/run/dhclient%s-%s.pid'
+    LEASE_DIR = '/var/lib/dhclient'
+    LEASE_FILE = os.path.join(LEASE_DIR, 'dhclient%s-%s.leases')
     DHCLIENT = CommandPath('dhclient', '/sbin/dhclient')
 
-    def __init__(self, iface):
+    def __init__(self, iface, family=4):
         self.iface = iface
-        self.pidFile = self.PID_FILE % self.iface
+        self.pidFile = self.PID_FILE % (family, self.iface)
         if not os.path.exists(self.LEASE_DIR):
             os.mkdir(self.LEASE_DIR)
-        self.leaseFile = (self.LEASE_FILE % self.iface)
+        self.leaseFile = self.LEASE_FILE % (family, self.iface)
 
     def _dhclient(self):
         # Ask dhclient to stop any dhclient running for the device


-- 
To view, visit http://gerrit.ovirt.org/31111
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0eb2d3c7b8163684f3bb8c59ad908a260d2138b6
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ondřej Svoboda <osvoboda at redhat.com>


More information about the vdsm-patches mailing list