本文整理汇总了Python中pybvc.openflowdev.ofswitch.OFSwitch.get_port_queue_stats方法的典型用法代码示例。如果您正苦于以下问题:Python OFSwitch.get_port_queue_stats方法的具体用法?Python OFSwitch.get_port_queue_stats怎么用?Python OFSwitch.get_port_queue_stats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybvc.openflowdev.ofswitch.OFSwitch
的用法示例。
在下文中一共展示了OFSwitch.get_port_queue_stats方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: of_demo_43
# 需要导入模块: from pybvc.openflowdev.ofswitch import OFSwitch [as 别名]
# 或者: from pybvc.openflowdev.ofswitch.OFSwitch import get_port_queue_stats [as 别名]
#.........这里部分代码省略.........
match.set_in_port(match_in_port)
match.set_eth_type(match_eth_type)
match.set_ipv4_dst(match_ipv4_dst_addr)
flow_entry1.add_match(match)
print ("\n")
print ("<<< Flow to send:")
print flow_entry1.get_payload()
time.sleep(rundelay)
result = ofswitch.add_modify_flow(flow_entry1)
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.detailed())
delete_flows(ofswitch, table_id, range(first_flow_id, flow_id + 1))
exit(0)
print "\n".strip()
print ("<<< Get Queues Statistics for Port '%s'") % act_out_port
time.sleep(rundelay)
queues = []
result = ofswitch.get_port_queues_stats(act_out_port, decode_obj=True)
status = result.get_status()
if(status.eq(STATUS.OK)):
queues = result.get_data()
elif(status.eq(STATUS.DATA_NOT_FOUND)):
pass
else:
print ("\n")
print ("!!!Error, failed to get queue statistics for port '%s" %
act_out_port)
print ("!!!Demo terminated, reason: %s" % status.detailed())
delete_flows(ofswitch, table_id, range(first_flow_id, flow_id + 1))
exit(0)
print "\n".strip()
s = "Port '{} - Queues Statistics'".format(act_out_port)
print " %s\n" % s
if queues:
for queue in sorted(queues, key=lambda q: q.queue_id()):
print " Queue '{}'".format(queue.queue_id())
print "\n".strip()
print " Tx Packets : {}".format(queue.tx_pkts())
print " Tx Bytes : {}".format(queue.tx_bytes())
print " Tx Errors : {}".format(queue.tx_errs())
print " Duration : {}s".format(queue.time_alive())
print "\n".strip()
else:
print " None"
print "\n".strip()
print ("<<< Get Queue '%s' Statistics for Port '%s'" %
(act_queue_id, act_out_port))
time.sleep(rundelay)
queue = None
result = ofswitch.get_port_queue_stats(port_num=act_out_port,
queue_id=act_queue_id,
decode_obj=True)
status = result.get_status()
if(status.eq(STATUS.OK)):
queue = result.get_data()
elif(status.eq(STATUS.DATA_NOT_FOUND)):
pass
else:
print ("\n")
print ("!!!Error, failed to get port '%s' queue '%s' statistics " %
act_out_port, act_queue_id)
print ("!!!Demo terminated, reason: %s" % status.detailed())
delete_flows(ofswitch, table_id, range(first_flow_id, flow_id + 1))
exit(0)
print "\n".strip()
s = "Port '{}' - Queue '{}' Statistics".format(act_out_port, act_queue_id)
print " %s\n" % s
if queue:
print " Tx Packets : {}".format(queue.tx_pkts())
print " Tx Bytes : {}".format(queue.tx_bytes())
print " Tx Errors : {}".format(queue.tx_errs())
print " Duration : {}s".format(queue.time_alive())
print "\n".strip()
else:
print " None"
print ("\n")
print ("<<< Delete flows from the Controller's cache "
"and from the table '%s' on the '%s' node" % (table_id, nodeName))
time.sleep(rundelay)
delete_flows(ofswitch, table_id, range(first_flow_id, flow_id + 1))
print ("\n")
print (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
print (">>> Demo End")
print (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")