本文整理汇总了Python中pybvc.openflowdev.ofswitch.Match.set_vlan_pcp方法的典型用法代码示例。如果您正苦于以下问题:Python Match.set_vlan_pcp方法的具体用法?Python Match.set_vlan_pcp怎么用?Python Match.set_vlan_pcp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybvc.openflowdev.ofswitch.Match
的用法示例。
在下文中一共展示了Match.set_vlan_pcp方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Instruction
# 需要导入模块: from pybvc.openflowdev.ofswitch import Match [as 别名]
# 或者: from pybvc.openflowdev.ofswitch.Match import set_vlan_pcp [as 别名]
instruction = Instruction(instruction_order = 0)
action = OutputAction(action_order = 0, port = 7)
instruction.add_apply_action(action)
flow_entry.add_instruction(instruction)
# --- Match Fields: Ethernet Type
# Ethernet Source Address
# Ethernet Destination Address
# VLAN ID
# VLAN PCP
match = Match()
match.set_eth_type(eth_type)
match.set_eth_src(eth_src)
match.set_eth_dst(eth_dst)
match.set_vlan_id(vlan_id)
match.set_vlan_pcp(vlan_pcp)
flow_entry.add_match(match)
print ("\n")
print ("<<< Flow to send:")
print flow_entry.get_payload()
time.sleep(rundelay)
result = ofswitch.add_modify_flow(flow_entry)
status = result[0]
if(status.eq(STATUS.OK) == True):
print ("<<< Flow successfully added to the Controller")
else:
print ("\n")
print ("!!!Demo terminated, reason: %s" % status.brief().lower())
exit(0)
示例2: of_demo_13
# 需要导入模块: from pybvc.openflowdev.ofswitch import Match [as 别名]
# 或者: from pybvc.openflowdev.ofswitch.Match import set_vlan_pcp [as 别名]
def of_demo_13():
f = "cfg.yml"
d = {}
if(load_dict_from_file(f, d) is False):
print("Config file '%s' read error: " % f)
exit()
try:
ctrlIpAddr = d['ctrlIpAddr']
ctrlPortNum = d['ctrlPortNum']
ctrlUname = d['ctrlUname']
ctrlPswd = d['ctrlPswd']
nodeName = d['nodeName']
rundelay = d['rundelay']
except:
print ("Failed to get Controller device attributes")
exit(0)
print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
print ("<<< Demo 13 Start")
print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
ofswitch = OFSwitch(ctrl, nodeName)
# --- Flow Match: Ethernet Type
# Ethernet Source Address
# Ethernet Destination Address
# VLAN ID
# VLAN PCP
eth_type = ETH_TYPE_IPv4
eth_src = "00:00:00:11:23:ad"
eth_dst = "00:ff:29:01:19:61"
vlan_id = 100
vlan_pcp = PCP_CA # 'Critical Applications' (priority 3)
print ("<<< 'Controller': %s, 'OpenFlow' switch: '%s'"
% (ctrlIpAddr, nodeName))
print "\n"
print ("<<< Set OpenFlow flow on the Controller")
print (" Match: Ethernet Type (%s)\n"
" Ethernet Source Address (%s)\n"
" Ethernet Destination Address (%s)\n"
" VLAN ID (%s)\n"
" VLAN PCP(%s)"
% (hex(eth_type), eth_src,
eth_dst, vlan_id, vlan_pcp))
print (" Action: Output (to Physical Port Number)")
time.sleep(rundelay)
flow_entry = FlowEntry()
table_id = 0
flow_entry.set_flow_table_id(table_id)
flow_id = 20
flow_entry.set_flow_id(flow_id)
flow_entry.set_flow_hard_timeout(0)
flow_entry.set_flow_idle_timeout(0)
flow_entry.set_flow_priority(1011)
# --- Instruction: 'Apply-actions'
# Action: 'Output' to port 7
instruction = Instruction(instruction_order=0)
action = OutputAction(order=0, port=7)
instruction.add_apply_action(action)
flow_entry.add_instruction(instruction)
# --- Match Fields: Ethernet Type
# Ethernet Source Address
# Ethernet Destination Address
# VLAN ID
# VLAN PCP
match = Match()
match.set_eth_type(eth_type)
match.set_eth_src(eth_src)
match.set_eth_dst(eth_dst)
match.set_vlan_id(vlan_id)
match.set_vlan_pcp(vlan_pcp)
flow_entry.add_match(match)
print ("\n")
print ("<<< Flow to send:")
print flow_entry.get_payload()
time.sleep(rundelay)
result = ofswitch.add_modify_flow(flow_entry)
status = result.get_status()
if(status.eq(STATUS.OK)):
print ("<<< Flow successfully added to the Controller")
else:
print ("\n")
print ("!!!Demo terminated, reason: %s" % status.brief().lower())
exit(0)
print ("\n")
print ("<<< Get configured flow from the Controller")
time.sleep(rundelay)
result = ofswitch.get_configured_flow(table_id, flow_id)
#.........这里部分代码省略.........