This prevents DHCP requests failures taking time during
boot if the interface isn't up yet. If the interface is
down, dhclient will fail to send packets.
At boot-time, enslaving an interface to vrf flaps it. By
waiting for the interface to come back up before starting
dhclient reduces time to boot.
Reviewed-by: CCR-10987
Closes: CM-32460
Co-developed-by: Nilesh Shinde <nilesh@nvidia.com>
Signed-off-by: Andy Roulin <aroulin@nvidia.com>
self._run_dhclient_cmd(cmd, cmd_prefix)
def start(self, ifacename, wait=True, cmd_prefix=None):
+ retries = 0
+ out = "0"
+
+ # wait if interface isn't up yet
+ while '1' not in out and retries < 5:
+ path = 'sys/class/net/%s/carrier' %ifacename
+ out = self.read_file_oneline(path)
+ retries += 1
+ time.sleep(1)
+
if os.path.exists('/sbin/dhclient3'):
cmd = ['/sbin/dhclient3', '-pf',
'/run/dhclient.%s.pid' %ifacename,