Skip to content

Instantly share code, notes, and snippets.

@fredhsu
Created February 13, 2014 22:10
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 fredhsu/8984952 to your computer and use it in GitHub Desktop.
Save fredhsu/8984952 to your computer and use it in GitHub Desktop.
DirectFlow example that matches on destination IP and sets the output port
from jsonrpclib import Server
username = "admin"
password = "admin"
host = "172.22.28.156"
dip = "10.1.1.1"
outport = "Port-Channel 100"
urlString = "https://{}:{}@{}/command-api".format(username, password, switch)
switchReq = Server( urlString )
# The following rpc request will match on the source IP, then change both source and dest mac
response = switchReq.runCmds( 1, ["enable", "configure", "openflow", "flow a10", "persistent", "match destination ip {}".format(dip), "action set output interface {}".format(outport)] )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment