Skip to content

Instantly share code, notes, and snippets.

@fredhsu
Created February 13, 2014 21:24
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/8984144 to your computer and use it in GitHub Desktop.
Save fredhsu/8984144 to your computer and use it in GitHub Desktop.
Example of rewriting source and destination mac with DirectFlow via eAPI
from jsonrpclib import Server
username = "admin"
password = "admin"
host = "172.22.28.156"
sip = "10.1.1.1"
smac = "0000.aaaa.bbbb"
dmac = "1111.aaaa.bbbb"
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 source ip {}".format(sip), "action set source mac ".format(smac), "action set destination mac".format(dmac)] )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment