当前位置: 首页>>代码示例>>Python>>正文


Python OFSwitch.get_port_queues_stats方法代码示例

本文整理汇总了Python中pybvc.openflowdev.ofswitch.OFSwitch.get_port_queues_stats方法的典型用法代码示例。如果您正苦于以下问题:Python OFSwitch.get_port_queues_stats方法的具体用法?Python OFSwitch.get_port_queues_stats怎么用?Python OFSwitch.get_port_queues_stats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pybvc.openflowdev.ofswitch.OFSwitch的用法示例。


在下文中一共展示了OFSwitch.get_port_queues_stats方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: of_demo_43

# 需要导入模块: from pybvc.openflowdev.ofswitch import OFSwitch [as 别名]
# 或者: from pybvc.openflowdev.ofswitch.OFSwitch import get_port_queues_stats [as 别名]

#.........这里部分代码省略.........
    action.set_outport(act_out_port)
    instruction.add_apply_action(action)

    flow_entry1.add_instruction(instruction)

    # Match Fields for the Flow Entry
    match = Match()

    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))
开发者ID:s-garbuzov,项目名称:pybvc,代码行数:70,代码来源:demo43.py


注:本文中的pybvc.openflowdev.ofswitch.OFSwitch.get_port_queues_stats方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。