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

ifupdown: add new ifupdownflags class to carry ifupdown flags

Ticket: cleanup
Reviewed By:
Testing Done: Tested ifupdown sanity

This gets rid of some ugly previous flag handling which was
passed through modules. This creates a global instance of
flags that all addon modules and helper modules can use.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
This commit is contained in:
Roopa Prabhu
2016-04-14 14:45:47 -07:00
parent 96a71b65cb
commit fc5e1735c0
24 changed files with 144 additions and 151 deletions

View File

@@ -6,6 +6,7 @@
import os
import re
import ifupdown.ifupdownflags as ifupdownflags
from ifupdown.iface import *
from utilsbase import *
from iproute2 import *
@@ -19,7 +20,7 @@ class bondutil(utilsBase):
def __init__(self, *args, **kargs):
utilsBase.__init__(self, *args, **kargs)
if self.CACHE and not self._cache_fill_done:
if ifupdownflags.flags.CACHE and not self._cache_fill_done:
self._bond_linkinfo_fill_all()
self._cache_fill_done = True
@@ -79,9 +80,9 @@ class bondutil(utilsBase):
def _cache_get(self, attrlist, refresh=False):
try:
if self.DRYRUN:
if ifupdownflags.flags.DRYRUN:
return None
if self.CACHE:
if ifupdownflags.flags.CACHE:
if not bondutil._cache_fill_done:
self._bond_linkinfo_fill_all()
bondutil._cache_fill_done = True
@@ -108,7 +109,7 @@ class bondutil(utilsBase):
return False
def _cache_update(self, attrlist, value):
if self.DRYRUN: return
if ifupdownflags.flags.DRYRUN: return
try:
if attrlist[-1] == 'slaves':
linkCache.add_to_attrlist(attrlist, value)
@@ -118,7 +119,7 @@ class bondutil(utilsBase):
pass
def _cache_delete(self, attrlist, value=None):
if self.DRYRUN: return
if ifupdownflags.flags.DRYRUN: return
try:
if attrlist[-1] == 'slaves':
linkCache.remove_from_attrlist(attrlist, value)
@@ -128,7 +129,7 @@ class bondutil(utilsBase):
pass
def _cache_invalidate(self):
if self.DRYRUN: return
if ifupdownflags.flags.DRYRUN: return
linkCache.invalidate()
def set_attrs(self, bondname, attrdict, prehook):
@@ -147,7 +148,7 @@ class bondutil(utilsBase):
self.write_file('/sys/class/net/%s/bonding/%s'
%(bondname, attrname), attrval)
except Exception, e:
if self.FORCE:
if ifupdownflags.flags.FORCE:
self.logger.warn(str(e))
pass
else:
@@ -323,7 +324,7 @@ class bondutil(utilsBase):
try:
self.remove_slave(bondname, slave)
except Exception, e:
if not self.FORCE:
if not ifupdownflags.flags.FORCE:
raise Exception('error removing slave %s'
%slave + ' from bond %s' %bondname +
'(%s)' %str(e))