@@ -245,6 +245,9 @@ def toHex(match):
245245 match [field ] = hex (value )
246246 return match
247247
248+ def prettify (fs ):
249+ pass
250+
248251
249252def do_listFlowSpace (gopts , opts , args ):
250253 passwd = getPassword (gopts )
@@ -264,6 +267,7 @@ def do_listFlowSpace(gopts, opts, args):
264267 print " None"
265268 sys .exit ()
266269 for item in ret :
270+ prettify (item )
267271 if opts .pretty :
268272 print json .dumps (item , sort_keys = True , indent = 1 )
269273 print "\n \n "
@@ -318,7 +322,7 @@ def do_addFlowSpace(gopts, opts, args):
318322 acts = []
319323 for action in actions :
320324 parts = action .split ('=' )
321- act = { 'slice-name' : parts [0 ], "permission" : int ( parts [1 ]) }
325+ act = { 'slice-name' : parts [0 ], "permission" : parts [1 ] }
322326 acts .append (act )
323327 req ['slice-action' ] = acts
324328 ret = connect (gopts , "add-flowspace" , passwd , data = [req ])
@@ -572,6 +576,8 @@ def pa_regEventCB(args, cmd):
572576
573577 (sdesc , ldesc ) = DESCS [cmd ]
574578 parser = OptionParser (usage = usage , description = ldesc )
579+ parser .add_option ("-d" , "--dpid" , dest = "dpid" , type = "string" , default = None ,
580+ help = "Set the dpid for registering for the flowtable information; default='all'" )
575581 return parser .parse_args (args )
576582
577583def do_regEventCB (gopts , opts , args ):
@@ -580,6 +586,10 @@ def do_regEventCB(gopts, opts, args):
580586 sys .exit ()
581587 passwd = getPassword (gopts )
582588 req = { 'url' : args [0 ], 'method' : args [1 ], 'event-type' : args [2 ], 'cookie' : args [3 ]}
589+ if opts .dpid is not None :
590+ req ['dpid' ] = opts .dpid
591+ else :
592+ req ['dpid' ] = 'all'
583593 ret = connect (gopts , "register-event-callback" , passwd , data = req )
584594 if ret :
585595 print "Callback %s successfully added" % args [3 ]
@@ -590,18 +600,23 @@ def pa_unregEventCB(args, cmd):
590600
591601 (sdesc , ldesc ) = DESCS [cmd ]
592602 parser = OptionParser (usage = usage , description = ldesc )
603+ parser .add_option ("-d" , "--dpid" , dest = "dpid" , type = "string" , default = None ,
604+ help = "Set the dpid for unregistering for the flowtable information; default='all'" )
593605 return parser .parse_args (args )
594606
595607def do_unregEventCB (gopts , opts , args ):
596608 if len (args ) != 3 :
597609 print "unregister-event-callback : Must specify all the arguments"
598610 sys .exit ()
599611 passwd = getPassword (gopts )
600- req = { 'method' : args [1 ], 'event-type' : args [2 ], 'cookie' : args [3 ]}
612+ req = { 'method' : args [0 ], 'event-type' : args [1 ], 'cookie' : args [2 ]}
613+ if opts .dpid is not None :
614+ req ['dpid' ] = opts .dpid
615+ else :
616+ req ['dpid' ] = 'all'
601617 ret = connect (gopts , "unregister-event-callback" , passwd , data = req )
602618 if ret :
603- print "Callback %s successfully removed" % args [3 ]
604-
619+ print "Callback %s successfully removed" % args [2 ]
605620
606621def do_listFVHealth (gopts , opts , args ):
607622 passwd = getPassword (gopts )
@@ -754,6 +769,14 @@ def toInt(val):
754769 return int (val ,16 )
755770 return int (val )
756771
772+ def toMacInt (val ):
773+ if val is None :
774+ return
775+ if val .find (":" ) != - 1 :
776+ return int (val .replace (':' , '' ),16 )
777+ if val .find ("-" ) != - 1 :
778+ int (val .replace ('-' , '' ),16 )
779+
757780def toStr (val ):
758781 return str (val )
759782
@@ -789,10 +812,10 @@ def print_help(option, opt, value, parser):
789812MATCHSTRS = {
790813 'in_port' : ('in_port' , toInt ),
791814 'input_port' : ('in_port' , toInt ),
792- 'dl_dst' : ('dl_dst' , toInt ),
793- 'eth_dst' : ('dl_dst' , toInt ),
794- 'dl_src' : ('dl_src' , toInt ),
795- 'eth_src' : ('dl_src' ,toInt ),
815+ 'dl_dst' : ('dl_dst' , toStr ),
816+ 'eth_dst' : ('dl_dst' , toStr ),
817+ 'dl_src' : ('dl_src' , toStr ),
818+ 'eth_src' : ('dl_src' ,toStr ),
796819 'dl_type' : ('dl_type' ,toInt ),
797820 'eth_type' : ('dl_type' ,toInt ),
798821 'dl_vlan' : ('dl_vlan' , toInt ),
@@ -975,7 +998,8 @@ def print_help(option, opt, value, parser):
975998 )),
976999 'register-event-callback' : ("Registers your server, for events from FlowVisor" ,
9771000 ("Registers for events from FlowVisor. Possible events are: DEVICE_CONNECTED, "
978- "SLICE_CONNECTED, and SLICE_DISCONNECTED. More may be added later."
1001+ "SLICE_CONNECTED, SLICE_DISCONNECTED and FLOWTABLE_CALLBACK. For FLOWTABLE_CALLBACK"
1002+ " event type dpid has to be input with -d option. More events may be added later."
9791003 )),
9801004 'unregister-event-callback' : ("Unregisters your server from FlowVisor" ,
9811005 ("Unregisters your server from FlowVisor thereby deactivating event "
0 commit comments