From 3cf287b8e1b734ddd01bb2e12a034550aedfc5bd Mon Sep 17 00:00:00 2001 From: Roopa Prabhu Date: Sun, 17 Apr 2016 23:45:59 -0700 Subject: [PATCH] addons: dhcp: check if vrf device exists before calling dhclient with vrf exec Ticket: CM-10292 Reviewed By: Testing Done: Tested mgmt vrf and other sanity tests --- addons/dhcp.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/dhcp.py b/addons/dhcp.py index 2c37d5d..14988b9 100644 --- a/addons/dhcp.py +++ b/addons/dhcp.py @@ -37,7 +37,8 @@ class dhcp(moduleBase): module_name=self.__class__.__name__, attr='dhcp-wait') wait = not str(dhcp_wait).lower() == "no" vrf = ifaceobj.get_attr_value_first('vrf') - if vrf and self.vrf_exec_cmd_prefix: + if (vrf and self.vrf_exec_cmd_prefix and + self.ipcmd.link_exists(vrf)): dhclient_cmd_prefix = '%s %s' %(self.vrf_exec_cmd_prefix, vrf) if ifaceobj.addr_family == 'inet': @@ -72,7 +73,8 @@ class dhcp(moduleBase): def _down(self, ifaceobj): dhclient_cmd_prefix = None vrf = ifaceobj.get_attr_value_first('vrf') - if vrf and self.vrf_exec_cmd_prefix: + if (vrf and self.vrf_exec_cmd_prefix and + self.ipcmd.link_exists(vrf)): dhclient_cmd_prefix = '%s %s' %(self.vrf_exec_cmd_prefix, vrf) self.dhclientcmd.release(ifaceobj.name, dhclient_cmd_prefix) self.ipcmd.link_down(ifaceobj.name)