Skip to content

Instantly share code, notes, and snippets.

@russellb
Created March 26, 2015 23:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save russellb/946953e8675063c0c756 to your computer and use it in GitHub Desktop.
Save russellb/946953e8675063c0c756 to your computer and use it in GitHub Desktop.
sanity checking ovn-nbctl
#!/bin/bash
exec 2>/dev/null
ovn-nbctl lswitch-add sw0
ovn-nbctl lswitch-add sw1
ovn-nbctl lswitch-add sw2
ovn-nbctl lswitch-add sw2
echo "*** Should be 4 Logical Switches:"
ovn-nbctl lswitch-list
echo
echo "*** Should fail to lookup switch by duplicate name sw2:"
ovn-nbctl lswitch-get-external-id sw2
echo
ovn-nbctl lswitch-set-external-id sw0 foo bar
ovn-nbctl lswitch-set-external-id sw0 foo2 bar2
echo "*** external:ids on sw0 should be foo=bar and foo2=bar2"
ovn-nbctl lswitch-get-external-id sw0
echo
echo "*** external:id 'foo' on sw0 should be bar"
ovn-nbctl lswitch-get-external-id sw0 foo
echo
ovn-nbctl lswitch-set-external-id sw0 foo
echo "*** external:ids on sw0 should be foo2=bar2"
ovn-nbctl lswitch-get-external-id sw0
echo
ovn-nbctl lport-add sw0-port0 sw0
ovn-nbctl lport-add sw0-port1 sw0
ovn-nbctl lport-add sw1-port0 sw1
ovn-nbctl lport-add sw1-port1 sw1
echo "*** Should be 2 ports on sw0:"
ovn-nbctl lport-list sw0
echo
echo "*** Should be 2 ports on sw1:"
ovn-nbctl lport-list sw1
echo
ovn-nbctl lport-set-external-id sw0-port0 foo bar
ovn-nbctl lport-set-external-id sw0-port0 foo2 bar2
echo "*** external:ids on sw0-port0 should be foo=bar and foo2=bar2"
ovn-nbctl lport-get-external-id sw0-port0
echo
echo "*** external:id 'foo' on sw0-port0 should be bar"
ovn-nbctl lport-get-external-id sw0-port0 foo
echo
ovn-nbctl lport-set-external-id sw0-port0 foo
echo "*** external:ids on sw0-port0 should be foo2=bar2"
ovn-nbctl lport-get-external-id sw0-port0
echo
ovn-nbctl lport-set-macs sw0-port0 fakemac0 fakemac1 fakemac2
echo "*** sw0-port0 should have 3 fake MACs"
ovn-nbctl lport-get-macs sw0-port0
echo
ovn-nbctl lport-set-macs sw0-port0 fakemac0 fakemac1
echo "*** sw0-port0 should have 2 fake MACs"
ovn-nbctl lport-get-macs sw0-port0
echo
ovn-nbctl lport-set-macs sw0-port0
echo "*** sw0-port0 should have 0 MACs"
ovn-nbctl lport-get-macs sw0-port0
echo
ovn-nbctl lport-del sw0-port0
ovn-nbctl lport-del sw0-port1
ovn-nbctl lport-del sw1-port0
ovn-nbctl lport-del sw1-port1
echo "*** Should be 0 ports on sw0:"
ovn-nbctl lport-list sw0
echo
echo "*** Should be 0 ports on sw1:"
ovn-nbctl lport-list sw1
echo
ovn-nbctl lswitch-del sw0
ovn-nbctl lswitch-del sw1
for lswitch in $(ovn-nbctl lswitch-list | awk '{print $1}'); do
ovn-nbctl lswitch-del $lswitch
done
echo "*** Should be 0 switches:"
ovn-nbctl lswitch-list
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment