- 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
A simple convenience configfile can provide a mapping between VPP
interface names, Linux Control Plane interface names, and descriptions.
An example:
```
interfaces:
"TenGigabitEthernet6/0/0":
description: "Infra: xsw0.chrma0:2"
lcp: "xe1-0"
"TenGigabitEthernet6/0/0.3102":
description: "Infra: QinQ to Solnet for Daedalean"
lcp: "xe1-0.3102"
"TenGigabitEthernet6/0/0.310211":
description: "Cust: Daedalean IP Transit"
lcp: "xe1-0.3102.11"
```
This configuration file is completely optional. If the `-c` flag is
empty, or it's set but the file does not exist, the Agent will simply
enumerate all interfaces, and set the `ifAlias` OID to the same value
as the `ifName`. However, if the config file is read, it will change
the behavior as follows:
* Any `tapNN` interface names from VPP will be matched to their PHY by
looking up their Linux Control Plane interface. The `ifName` field
will be rewritten to the _LIP_ `host-if`. For example, `tap3` above
will become `xe1-0` while `tap3.310211` will become `xe1-0.3102.11`.
* The `ifAlias` OID for a PHY will be set to the `description` field.
* The `ifAlias` OID for a TAP will be set to the string `LCP: `
followed by its PHY `ifName`. For example, `xe1-0.3102.11` will
become `LCP TenGigabitEthernet6/0/0.310211 (tap9)`
It now is tolerant to VPP restarts. Upon initialization, we connect(),
blocking all but the first thread from trying. The rest will see
self.connected=True and move on.
Then, on each/any error, call vpp.disconect() and set connected=False
which will make any subsequent AgentX updater run force a reconnect.