本文整理汇总了Python中pybvc.openflowdev.ofswitch.OFSwitch.delete_flows方法的典型用法代码示例。如果您正苦于以下问题:Python OFSwitch.delete_flows方法的具体用法?Python OFSwitch.delete_flows怎么用?Python OFSwitch.delete_flows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybvc.openflowdev.ofswitch.OFSwitch
的用法示例。
在下文中一共展示了OFSwitch.delete_flows方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: clear_flow
# 需要导入模块: from pybvc.openflowdev.ofswitch import OFSwitch [as 别名]
# 或者: from pybvc.openflowdev.ofswitch.OFSwitch import delete_flows [as 别名]
def clear_flow(self, options):
parser = argparse.ArgumentParser(
prog=self.prog,
description='Clear OpenFlow flows',
usage="%(prog)s clear-flow -s=SWITCHID|--switch=SWICTHID\n"
" -t=TABLEID|--table=TABLEID\n"
" [-f=FLOWID|--flow=FLOWID]\n"
"\n\n"
"Clear cached flows on the Controller\n\n"
"\n\n"
"Options:\n"
" -s, --switch switch identifier\n"
" -t, --table flow table id\n"
" -f, --flow flow id\n"
)
parser.add_argument('-s', '--switch', metavar = "SWITCHID")
parser.add_argument('-t', '--table', metavar = "TABLEID",
type=self.positive_int)
parser.add_argument('-f', '--flow', metavar = "FLOWID")
parser.add_argument('-U', action="store_true", dest="usage",
help=argparse.SUPPRESS)
args = parser.parse_args(options)
if(args.usage):
parser.print_usage()
print "\n".strip()
return
if (args.switch == None):
msg = "option -s (or --switch) is required"
parser.error(msg)
if (args.table == None):
msg = "option -t (or --table) is required"
parser.error(msg)
print "\n".strip()
print " [Controller '%s']" % self.ctrl_cfg.to_string()
ctrl = Controller(self.ctrl_cfg.ip_addr, self.ctrl_cfg.tcp_port,
self.ctrl_cfg.admin_name, self.ctrl_cfg.admin_pswd)
ofswitch = OFSwitch(ctrl, args.switch)
if(args.flow != None):
result = ofswitch.delete_flow(args.table, args.flow)
else:
result = ofswitch.delete_flows(args.table)
status = result.get_status()
print "\n".strip()
print "%s" % status.detailed()
print "\n".strip()
示例2: of_demo_26
# 需要导入模块: from pybvc.openflowdev.ofswitch import OFSwitch [as 别名]
# 或者: from pybvc.openflowdev.ofswitch.OFSwitch import delete_flows [as 别名]
#.........这里部分代码省略.........
flowEntries.append(flow_entry)
# Sample flow entry
flow_entry = FlowEntry()
flow_entry.set_flow_cookie(1234)
flow_entry.set_flow_table_id(flow_table_id)
flow_entry.set_flow_id(flow_id)
flow_id += 1
flow_entry.set_flow_hard_timeout(0)
flow_entry.set_flow_idle_timeout(0)
flow_entry.set_flow_priority(4000)
instruction = Instruction(instruction_order=0)
action = PopVlanHeaderAction(order=0)
instruction.add_apply_action(action)
action = OutputAction(order=1, port=110)
instruction.add_apply_action(action)
flow_entry.add_instruction(instruction)
match = Match()
match.set_eth_type(ETH_TYPE_IPv4)
match.set_vlan_id(100)
match.set_in_port(111)
flow_entry.add_match(match)
flowEntries.append(flow_entry)
print ("\n")
print ("<<< Remove configured flows from the Controller")
ofswitch.delete_flows(flow_table_id)
print ("\n")
print ("<<< Set OpenFlow flows on the Controller")
print ("\n")
print ("<<< Flows to be configured:")
flowEntries = sorted(flowEntries, key=lambda fe: fe.get_flow_priority())
for fe in flowEntries:
print (" %s" % fe.to_ofp_oxm_syntax())
time.sleep(rundelay)
success = True
for fe in flowEntries:
result = ofswitch.add_modify_flow(fe)
status = result.get_status()
if(status.eq(STATUS.OK)):
pass
else:
success = False
print ("\n")
print ("!!!Demo terminated, failed to add flow:\n '%s'" %
fe.to_ofp_oxm_syntax())
print (" Failure reason: %s" % status.detailed())
if success:
print "\n"
print ("<<< Flows successfully added to the Controller")
else:
print "\n"
print ("<<< Removing all flows from the Controller")
ofswitch.delete_flows(flow_table_id)
示例3: Match
# 需要导入模块: from pybvc.openflowdev.ofswitch import OFSwitch [as 别名]
# 或者: from pybvc.openflowdev.ofswitch.OFSwitch import delete_flows [as 别名]
flow_entry.add_instruction(instruction)
match = Match()
match.set_eth_type(ETH_TYPE_IPv4)
match.set_vlan_id(100)
match.set_in_port(111)
flow_entry.add_match(match)
flowEntries.append(flow_entry)
print ("\n")
print ("<<< Remove configured flows from the Controller")
ofswitch.delete_flows(flow_table_id)
print ("\n")
print ("<<< Set OpenFlow flows on the Controller")
print ("\n")
print ("<<< Flows to be configured:")
flowEntries = sorted(flowEntries, key=lambda fe: fe.get_flow_priority())
for fe in flowEntries:
print (" %s" % fe.to_ofp_oxm_syntax())
time.sleep(rundelay)
success = True