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


Python OFSwitch.get_configured_group_ids方法代码示例

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


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

示例1: of_demo_36

# 需要导入模块: from pybvc.openflowdev.ofswitch import OFSwitch [as 别名]
# 或者: from pybvc.openflowdev.ofswitch.OFSwitch import get_configured_group_ids [as 别名]
def of_demo_36():

    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 36 Start")
    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")

    ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
    ofswitch = OFSwitch(ctrl, nodeName)

    print "\n".strip()
    print ("<<< 'Controller': %s, 'OpenFlow' switch: '%s'" %
           (ctrlIpAddr, nodeName))

    grp_ids_cfg = []
    grp_ids_oper = []

    print "\n".strip()
    print ("<<< Get OpenFlow Groups Information")
    time.sleep(rundelay)

    result = ofswitch.get_configured_group_ids()
    status = result.get_status()
    if(status.eq(STATUS.OK)):
        grp_ids_cfg = result.get_data()
    elif(status.eq(STATUS.DATA_NOT_FOUND)):
        grp_ids_cfg = []
    else:
        print ("\n")
        print ("!!!Demo terminated, reason: %s" % status.detailed())
        exit(0)

    result = ofswitch.get_operational_group_ids()
    status = result.get_status()
    if(status.eq(STATUS.OK)):
        grp_ids_oper = result.get_data()
    elif(status.eq(STATUS.DATA_NOT_FOUND)):
        grp_ids_oper = []
    else:
        print ("\n")
        print ("!!!Demo terminated, reason: %s" % status.detailed())
        exit(0)

    # Show current state of the Group Table in the Controller's
    # configuration and operational data stores
    print_groups(grp_ids_cfg, grp_ids_oper)

    # Create new group
    group_id = 15
    group_type = OFPGT_FF
    group_name = "Example of 'link fast failover' group"
    watch_port1 = 110
    watch_port2 = 111
    watch_port3 = 112
    out_port1 = 110
    out_port2 = 111
    out_port3 = 112
    print "\n".strip()
    print ("<<< Create Group")
    print "\n".strip()
    print ("        Group Type : %s\n"
           "        Group ID   : %s\n"
           "        Group Name : \"%s\"" %
           (group_type.strip('group-').upper(),
            group_id, group_name))
    print ("        Buckets    :")
    print ("                     [0] watch-port: %s" %
           watch_port1)
    print ("                         actions: Output (%s)" %
           out_port1)
    print ("                     [1] watch-port: %s" %
           watch_port2)
    print ("                         actions: Output (%s)" %
           out_port2)
    print ("                     [2] watch-port: %s" %
           watch_port3)
    print ("                         actions: Output (%s)" %
           out_port3)
    time.sleep(rundelay)

    # Allocate a placeholder for the group entry
    group_entry = GroupEntry(group_id, group_type)
    group_entry.set_group_name(group_name)

#.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:pybvc,代码行数:103,代码来源:demo36.py

示例2: of_demo_34

# 需要导入模块: from pybvc.openflowdev.ofswitch import OFSwitch [as 别名]
# 或者: from pybvc.openflowdev.ofswitch.OFSwitch import get_configured_group_ids [as 别名]
def of_demo_34():

    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)

    openflow_node_ids = []
    openflow_nodes = []

    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
    print ("<<< Demo 34 Start")
    print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")



    ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
    ofswitch = OFSwitch(ctrl, nodeName)

    print "\n".strip()
    print ("<<< 'Controller': %s, 'OpenFlow' switch: '%s'"
           % (ctrlIpAddr, nodeName))

    grp_ids_cfg = []
    grp_ids_oper = []

    print "\n".strip()
    print ("<<< Get OpenFlow Groups Information")
    time.sleep(rundelay)

    result = ofswitch.get_configured_group_ids()
    status = result.get_status()
    if(status.eq(STATUS.OK)):
        grp_ids_cfg = result.get_data()
    elif(status.eq(STATUS.DATA_NOT_FOUND)):
        grp_ids_cfg = []
    else:
        print ("\n")
        print ("!!!Demo terminated, reason: %s" % status.detailed())
        exit(0)

    result = ofswitch.get_operational_group_ids()
    status = result.get_status()
    if(status.eq(STATUS.OK)):
        grp_ids_oper = result.get_data()
    elif(status.eq(STATUS.DATA_NOT_FOUND)):
        grp_ids_oper = []
    else:
        print ("\n")
        print ("!!!Demo terminated, reason: %s" % status.detailed())
        exit(0)

    # Show current state of the Group Table in the Controller's
    # configuration and operational data stores
    print_groups(grp_ids_cfg, grp_ids_oper)

    # Create new group
    group_id = 13
    group_type = OFPGT_SELECT
    group_name = "Example of 'load balancing' group"
    weight1 = 60
    weight2 = 30
    weight3 = 10
    out_port1 = 110
    out_port2 = 111
    out_port3 = 112
    print "\n".strip()
    print ("<<< Create Group")
    print "\n".strip()
    print ("        Group Type : %s\n"
           "        Group ID   : %s\n"
           "        Group Name : \"%s\"" % (group_type.strip('group-').upper(),
                                            group_id, group_name))
    print ("        Buckets    :")
    print ("                     [0] weight : %s"
           % weight1)
    print ("                         actions: Output (%s)"
           % out_port1)
    print ("                     [1] weight : %s"
           % weight2)
    print ("                         actions: Output (%s)"
           % out_port2)
    print ("                     [2] weight : %s"
           % weight3)
    print ("                         actions: Output (%s)"
           % out_port3)
    time.sleep(rundelay)

#.........这里部分代码省略.........
开发者ID:pruiksmalw,项目名称:pybvc,代码行数:103,代码来源:demo34.py

示例3: Controller

# 需要导入模块: from pybvc.openflowdev.ofswitch import OFSwitch [as 别名]
# 或者: from pybvc.openflowdev.ofswitch.OFSwitch import get_configured_group_ids [as 别名]
 
 ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
 ofswitch = OFSwitch(ctrl, nodeName)
 
 print "\n".strip()
 print ("<<< 'Controller': %s, 'OpenFlow' switch: '%s'" % (ctrlIpAddr,
                                                           nodeName))
 
 grp_ids_cfg = []
 grp_ids_oper = []
 
 print "\n".strip()
 print ("<<< Get OpenFlow Groups Information")
 time.sleep(rundelay)
 
 result = ofswitch.get_configured_group_ids()
 status = result.get_status()
 if(status.eq(STATUS.OK)):
     grp_ids_cfg = result.get_data()
 elif(status.eq(STATUS.DATA_NOT_FOUND)):
     grp_ids_cfg = []
 else:
     print ("\n")
     print ("!!!Demo terminated, reason: %s" % status.detailed())
     exit(0)
 
 result = ofswitch.get_operational_group_ids()
 status = result.get_status()
 if(status.eq(STATUS.OK)):
     grp_ids_oper = result.get_data()
 elif(status.eq(STATUS.DATA_NOT_FOUND)):
开发者ID:jebpublic,项目名称:pybvcsamples,代码行数:33,代码来源:demo35.py


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