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

@@ -14,6 +14,7 @@ from collections import OrderedDict
from utilsbase import *
from systemutils import *
from cache import *
import ifupdown.ifupdownflags as ifupdownflags
VXLAN_UDP_PORT = 4789
@@ -28,7 +29,7 @@ class iproute2(utilsBase):
def __init__(self, *args, **kargs):
utilsBase.__init__(self, *args, **kargs)
if self.CACHE:
if ifupdownflags.flags.CACHE:
self._fill_cache()
def _fill_cache(self):
@@ -181,9 +182,9 @@ class iproute2(utilsBase):
def _cache_get(self, type, attrlist, refresh=False):
try:
if self.DRYRUN:
if ifupdownflags.flags.DRYRUN:
return False
if self.CACHE:
if ifupdownflags.flags.CACHE:
if self._fill_cache():
# if we filled the cache, return new data
return linkCache.get_attr(attrlist)
@@ -215,14 +216,14 @@ class iproute2(utilsBase):
return False
def _cache_update(self, attrlist, value):
if self.DRYRUN: return
if ifupdownflags.flags.DRYRUN: return
try:
linkCache.add_attr(attrlist, value)
except:
pass
def _cache_delete(self, attrlist):
if self.DRYRUN: return
if ifupdownflags.flags.DRYRUN: return
try:
linkCache.del_attr(attrlist)
except:
@@ -590,7 +591,7 @@ class iproute2(utilsBase):
self._cache_update([name], {})
def link_exists(self, ifacename):
if self.DRYRUN:
if ifupdownflags.flags.DRYRUN:
return True
return os.path.exists('/sys/class/net/%s' %ifacename)