Organise Openvswitch switch contents - bridges, ports, flows etc - into a filesystem structure to make it easy to query either using built-in commands or conventional tools like find and grep. Built-in tools exist to query Openstack and build ovs-appctl ofproto/trace commands.
Use ovs-stat on a host running openvswitch or a sosreport containing ovs data (requires openvswitch and networking plugin output). The result is a "dataset" - a sysfs-style representation of the switch - along with a summary of key attributes. This structure can then be queried manually or by using the built-in queries provided. It can also be viewed as a tree using the --tree command or exported as a tarball. Each dataset is keyed by hostname so that you can build a catalog of datasets from multiple hosts to allow searching across them.
NOTE: a recent version of snapd is needed to get latest support for ovs interface hence why we use the snap version since distro apt package may not be sufficient.
sudo snap install ovs-stat
sudo snap connect ovs-stat:openvswitch
sudo snap connect ovs-stat:network-control
NOTE: the above interfaces are needed for a live ovs. If analysing sosreport data and your sosreport lives on a separate/remote filesystem you only need the following:
sudo snap connect ovs-stat:removable-media
NOTE: because running commands against an openvswitch is typically root-only and because a strictly confined snap can only access the $HOME of the current user, we need to use a location outside $HOME such as /tmp so that the snap can access the path as root.
NOTE: because this is a snap, /tmp/results is converted to /tmp/snap.ovs-stat/tmp/results under the hood
Create dataset from local host and prints summary
Display an existing dataset using tree command
sudo ovs-stat -p /tmp/results --tree
Create dataset from sosreport. note that we don't use sudo for this.`
ovs-stat -p /tmp/results /path/to/sosreport
Using a path (-p) that contains an existing dataset will switch to read-only mode and will not clobber existing data. To refresh an existing dataset you will need to use --force.
Create dataset from local host and include openstack assertions
sudo ovs-stat -p /tmp/results --openstack
Show all Openstack ports on a bridge br-int
ovs-stat -p /tmp/results --query "openstack.ports br-int"
Show all Openstack ports on vlan 53
ovs-stat -p /tmp/results --query "openstack.ports 53"
Show all Neutron layer2-population flood tunnels for vlan 53
ovs-stat -p /tmp/results --query "openstack.l2pop 53"
Generate ofproto/trace commands for a given port
$ ovs-stat -p ./mydataset --query "ofproto-trace.port tapa05cfc36-21 dhcp"
sudo ovs-appctl ofproto/trace br-int udp,in_port=157,dl_src=b3:22:2f:03:42:5d,dl_dst=ff:ff:ff:ff:ff:ff,nw_src=0.0.0.0,nw_dst=255.255.255.255,udp_src=68,udp_dst=67
If your dataset is empty or you see a bunch of "permission denied" make sure you have added the necessary interface connections (see Install section).
If you are running ovs-stat against a sosreport make sure not to use sudo (since snap can only access your $HOME).