refactor: Simplify cache_clear()

Don't return the cache, simply set self.cache to empty dictionary. Call
it from readconfig()

TESTED:
- unit tests and yaml tests pass
This commit is contained in:
Pim van Pelt
2022-12-03 12:31:18 +00:00
parent 61f8169d69
commit 1b0fa13f74

View File

@ -51,8 +51,7 @@ class VPPApi:
self.connected = False
self.clientname = clientname
self.vpp = None
self.cache = self.cache_clear()
self.cache_read = False
self.cache_clear()
self.lcp_enabled = False
def connect(self, retries=30):
@ -99,9 +98,9 @@ class VPPApi:
return True
def cache_clear(self):
"""Remove the cached VPP configuration elements and return an empty dictionary"""
"""Remove the cached VPP configuration elements and return True"""
self.cache_read = False
return {
self.cache = {
"lcps": {},
"interface_names": {},
"interfaces": {},
@ -113,6 +112,7 @@ class VPPApi:
"l2xcs": {},
"taps": {},
}
return True
def cache_remove_lcp(self, lcpname):
"""Removes the LCP and TAP interface, identified by lcpname, from the VPP config cache"""
@ -204,7 +204,7 @@ class VPPApi:
self.logger.error("Could not connect to VPP")
return False
self.cache_read = False
self.cache_clear()
## Workaround LCPng and linux-cp, in order.
self.lcp_enabled = False