mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
ifupdownaddons: iproute2: add optional refresh flag to addr get api
Ticket: Reviewed By: trivial Testing Done: tested address gets with refresh flag + ran ssim test testifupdown2.py - also fixes refresh flag handling in cache _addr_fill function - this api can be used to get addresses from the cache by first refreshing the cache. So the caller gets fresh running addresses. (its not used right now but came up during the need to re-apply addresses for ipv6 vrf slaves since their addresses may disappear)
This commit is contained in:
@@ -132,10 +132,10 @@ class iproute2(utilsBase):
|
||||
"""
|
||||
|
||||
linkout = {}
|
||||
if iproute2._cache_fill_done: return
|
||||
if iproute2._cache_fill_done and not refresh: return
|
||||
try:
|
||||
# Check if ifacename is already full, in which case, return
|
||||
if ifacename:
|
||||
if ifacename and not refresh:
|
||||
linkCache.get_attr([ifacename, 'addrs'])
|
||||
return
|
||||
except:
|
||||
@@ -331,8 +331,9 @@ class iproute2(utilsBase):
|
||||
# ignore errors
|
||||
pass
|
||||
|
||||
def addr_get(self, ifacename, details=True):
|
||||
addrs = self._cache_get('addr', [ifacename, 'addrs'])
|
||||
def addr_get(self, ifacename, details=True, refresh=False):
|
||||
addrs = self._cache_get('addr', [ifacename, 'addrs'],
|
||||
refresh=refresh)
|
||||
if not addrs:
|
||||
return None
|
||||
if details:
|
||||
|
Reference in New Issue
Block a user