mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
addons: dhcp: check if iface has link-local address before starting dhclient6
Ticket: CM-13248 Reviewed By: Roopa, Kanna, Nikhil G Testing Done: See bug Today before starting dhclient6, we are sleeping 2 seconds we need to make sure the configured interface is up and has a link-local address. In some cases 2 seconds is not enough. This patch will install a retry loop with a 10 sec timeout. We are querying ip -6 addr show to make sure the interface is properly confi- -gured but in the future the plan is to move this call to netlink. Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
import re
|
||||||
from ipaddr import IPNetwork
|
from ipaddr import IPNetwork
|
||||||
from sets import Set
|
from sets import Set
|
||||||
from ifupdown.iface import *
|
from ifupdown.iface import *
|
||||||
@@ -79,8 +80,20 @@ class dhcp(moduleBase):
|
|||||||
#add delay before starting IPv6 dhclient to
|
#add delay before starting IPv6 dhclient to
|
||||||
#make sure the configured interface/link is up.
|
#make sure the configured interface/link is up.
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
self.dhclientcmd.start6(ifaceobj.name, wait=wait,
|
timeout = 10
|
||||||
cmd_prefix=dhclient_cmd_prefix)
|
while timeout:
|
||||||
|
timeout -= 2
|
||||||
|
addr_output = utils.exec_command('ip -6 addr show %s'
|
||||||
|
% ifaceobj.name)
|
||||||
|
r = re.search('inet6 .* scope link', addr_output)
|
||||||
|
if r:
|
||||||
|
self.dhclientcmd.start6(ifaceobj.name,
|
||||||
|
wait=wait,
|
||||||
|
cmd_prefix=dhclient_cmd_prefix)
|
||||||
|
return
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
self.log_error(str(e), ifaceobj)
|
self.log_error(str(e), ifaceobj)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user