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:
		| @@ -51,8 +51,7 @@ class VPPApi: | |||||||
|         self.connected = False |         self.connected = False | ||||||
|         self.clientname = clientname |         self.clientname = clientname | ||||||
|         self.vpp = None |         self.vpp = None | ||||||
|         self.cache = self.cache_clear() |         self.cache_clear() | ||||||
|         self.cache_read = False |  | ||||||
|         self.lcp_enabled = False |         self.lcp_enabled = False | ||||||
|  |  | ||||||
|     def connect(self, retries=30): |     def connect(self, retries=30): | ||||||
| @@ -99,9 +98,9 @@ class VPPApi: | |||||||
|         return True |         return True | ||||||
|  |  | ||||||
|     def cache_clear(self): |     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 |         self.cache_read = False | ||||||
|         return { |         self.cache = { | ||||||
|             "lcps": {}, |             "lcps": {}, | ||||||
|             "interface_names": {}, |             "interface_names": {}, | ||||||
|             "interfaces": {}, |             "interfaces": {}, | ||||||
| @@ -113,6 +112,7 @@ class VPPApi: | |||||||
|             "l2xcs": {}, |             "l2xcs": {}, | ||||||
|             "taps": {}, |             "taps": {}, | ||||||
|         } |         } | ||||||
|  |         return True | ||||||
|  |  | ||||||
|     def cache_remove_lcp(self, lcpname): |     def cache_remove_lcp(self, lcpname): | ||||||
|         """Removes the LCP and TAP interface, identified by lcpname, from the VPP config cache""" |         """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") |             self.logger.error("Could not connect to VPP") | ||||||
|             return False |             return False | ||||||
|  |  | ||||||
|         self.cache_read = False |         self.cache_clear() | ||||||
|  |  | ||||||
|         ## Workaround LCPng and linux-cp, in order. |         ## Workaround LCPng and linux-cp, in order. | ||||||
|         self.lcp_enabled = False |         self.lcp_enabled = False | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user