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

addons: vrf: don't delete vrf map file at init if mgmt vrf already exists

Ticket: CM-12084
Reviewed By: julien, nikhil
Testing Done: tested with --allow=mgmt class

This fixes a problem where vrf map file was getting deleted
at boot during the second invocation of ifup. This is because
the code uses PERFMODE to check it is boot..but does
not realize that this may not be the first invocation of
ifup during the boot.

This patch adds additional checks for mgmt netdev to
make sure we delete the vrf map file only the first time.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
This commit is contained in:
Roopa Prabhu
2016-08-12 23:49:29 -07:00
parent fa01b17413
commit d9e75535d4

View File

@@ -58,9 +58,18 @@ class vrf(moduleBase):
self.bondcmd = None
self.dhclientcmd = None
self.name = self.__class__.__name__
if ifupdownflags.flags.PERFMODE:
# if perf mode is set, remove vrf map file.
# start afresh. PERFMODE is set at boot
self.vrf_mgmt_devname = policymanager.policymanager_api.get_module_globals(module_name=self.__class__.__name__, attr='vrf-mgmt-devname')
if (ifupdownflags.flags.PERFMODE and
not (self.vrf_mgmt_devname and os.path.exists('/sys/class/net/%s'
%self.vrf_mgmt_devname))):
# if perf mode is set (PERFMODE is set at boot), and this is the first
# time we are calling ifup at boot (check for mgmt vrf existance at
# boot, make sure this is really the first invocation at boot.
# ifup is called with PERFMODE at boot multiple times (once for mgmt vrf
# and the second time with all auto interfaces). We want to delete
# the map file only the first time. This is to avoid accidently
# deleting map file with a valid mgmt vrf entry
if os.path.exists(self.iproute2_vrf_filename):
try:
self.logger.info('vrf: removing file %s'
@@ -113,7 +122,6 @@ class vrf(moduleBase):
self.vrf_fix_local_table = True
self.vrf_count = 0
self.vrf_mgmt_devname = policymanager.policymanager_api.get_module_globals(module_name=self.__class__.__name__, attr='vrf-mgmt-devname')
self.vrf_helper = policymanager.policymanager_api.get_module_globals(module_name=self.__class__.__name__, attr='vrf-helper')
def _iproute2_vrf_map_initialize(self, writetodisk=True):