Improvement: Use interface/LCP caching on VPP API
- Set an initial vppapi.iface_dict and lcp_dict to None. - Set an event watcher API call, with a callback - When events happen, flush the iface/lcp cache (by setting them to None). - When get_ifaces / get_lcp sees an empty cache, fetch the data from VPP API and put into the cache for subsequent calls. This way, the VPP API is only used upon startup (when the caches are empty), and on interface add/del/changes (note: the events fire for link, and admin up/down, but not for MTU changes). One small race condition exists: if a new LCP is created, this does not trigger an interface event. Adding a want_lcp_events() makes sense, but until then, a few options remain: 0) race exists only if inerface was created; THEN the cache was refreshed; and THEN the LCP was created. 1) create the lcp and then force a change to any interface (this will create an sw_interface event and flush the cache) 2) restart vpp-snmp-agent
This commit is contained in:
@ -108,7 +108,6 @@ class MyAgent(agentx.Agent):
|
||||
num_ifaces = len(ifaces)
|
||||
num_vppstat = len(self.vppstat["/if/names"])
|
||||
num_lcp = len(lcp)
|
||||
self.logger.debug("LCP: %s" % (lcp))
|
||||
self.logger.debug(
|
||||
"Retrieved Interfaces: vppapi=%d vppstat=%d lcp=%d"
|
||||
% (num_ifaces, num_vppstat, num_lcp)
|
||||
|
Reference in New Issue
Block a user