1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00

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
This commit is contained in:
Roopa Prabhu
2016-04-17 23:45:59 -07:00
parent f332cfbee8
commit 3cf287b8e1

View File

@ -37,7 +37,8 @@ class dhcp(moduleBase):
module_name=self.__class__.__name__, attr='dhcp-wait') module_name=self.__class__.__name__, attr='dhcp-wait')
wait = not str(dhcp_wait).lower() == "no" wait = not str(dhcp_wait).lower() == "no"
vrf = ifaceobj.get_attr_value_first('vrf') 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) dhclient_cmd_prefix = '%s %s' %(self.vrf_exec_cmd_prefix, vrf)
if ifaceobj.addr_family == 'inet': if ifaceobj.addr_family == 'inet':
@ -72,7 +73,8 @@ class dhcp(moduleBase):
def _down(self, ifaceobj): def _down(self, ifaceobj):
dhclient_cmd_prefix = None dhclient_cmd_prefix = None
vrf = ifaceobj.get_attr_value_first('vrf') 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) dhclient_cmd_prefix = '%s %s' %(self.vrf_exec_cmd_prefix, vrf)
self.dhclientcmd.release(ifaceobj.name, dhclient_cmd_prefix) self.dhclientcmd.release(ifaceobj.name, dhclient_cmd_prefix)
self.ipcmd.link_down(ifaceobj.name) self.ipcmd.link_down(ifaceobj.name)