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


Python ofswitch.OFSwitch类代码示例

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


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

示例1: print

 except:
     print ("Failed to get Controller device attributes")
     exit(0)
 
 openflow_node_ids = []
 openflow_nodes = []
 
 print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
 print ("<<< Demo Start")
 print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
 
 rundelay = 3
 
 
 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)):
开发者ID:jebpublic,项目名称:pydevodl,代码行数:31,代码来源:demo33.py

示例2: print

        ctrlPortNum = d['ctrlPortNum']
        ctrlUname = d['ctrlUname']
        ctrlPswd = d['ctrlPswd']
        nodeName = d['nodeName']
    except:
        print ("Failed to get Controller device attributes")
        exit(0)

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

    rundelay = 5

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

    # --- Flow Match: Ethernet Source Address
    #                 Ethernet Destination Address
    #                 IPv4 Source Address
    #                 IPv4 Destination Address
    #                 IP Protocol Number
    #                 IP DSCP
    #                 Input Port
    #     NOTE: Ethernet type MUST be 2048 (0x800) -> IPv4 protocol
    eth_type = ETH_TYPE_IPv4
    eth_src = "00:1c:01:00:23:aa"
    eth_dst = "00:02:02:60:ff:fe"
    ipv4_src = "10.0.245.1/24"
    ipv4_dst = "192.168.1.123/16"
    ip_proto = IP_PROTO_TLSP
开发者ID:Elbrys,项目名称:pydevodl,代码行数:31,代码来源:demo8.py

示例3: print

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

    rundelay = 5

    print ("\n")
    print ("<<< Creating Controller instance")
    time.sleep(rundelay)
    ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd, None)
    print ("'Controller':")
    print ctrl.brief_json()

    print ("\n")
    print ("<<< Get information about OpenFlow node '%s'" % nodeName)
    time.sleep(rundelay)
    ofswitch = OFSwitch(ctrl, nodeName)
    result = ofswitch.get_switch_info()
    status = result.get_status()
    if status.eq(STATUS.OK) == True:
        print ("Node '%s' generic info:" % nodeName)
        info = result.get_data()
        print json.dumps(info, indent=4)
    else:
        print ("\n")
        print ("!!!Demo terminated, reason: %s" % status.brief().lower())
        exit(0)

    print ("\n")
    result = ofswitch.get_features_info()
    status = result.get_status()
    if status.eq(STATUS.OK) == True:
开发者ID:jebpublic,项目名称:pydevodl,代码行数:31,代码来源:demo2.py

示例4: print

        ctrlPswd = d['ctrlPswd']
        nodeName = d['nodeName']
    except:
        print ("Failed to get Controller device attributes")
        exit(0)

    rundelay = 5

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

    rundelay = 5

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

    print ("<<< 'Controller': %s, 'OpenFlow' switch: '%s'" %
           (ctrlIpAddr, nodeName))

    first_flow_id = 110
    # ---------------------------------------------------
    # First flow entry
    # ---------------------------------------------------
    table_id = 0
    flow_id = first_flow_id
    flow_name = "Set IPv4 ToS action"
    priority = 600
    cookie = 1000

    match_in_port = 109
开发者ID:Elbrys,项目名称:pydevodl,代码行数:31,代码来源:demo31.py

示例5: print

        ctrlPortNum = d['ctrlPortNum']
        ctrlUname = d['ctrlUname']
        ctrlPswd = d['ctrlPswd']
        nodeName = d['nodeName']
    except:
        print ("Failed to get Controller device attributes")
        exit(0)

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

    rundelay = 3

    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)):
开发者ID:Elbrys,项目名称:pydevodl,代码行数:31,代码来源:demo36.py

示例6: print

 print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
 
 rundelay = 5
 
 print ("\n")
 print ("<<< Creating Controller instance")
 time.sleep(rundelay)
 ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd, None)
 print ("'Controller':")
 print ctrl.brief_json()
 
 
 print ("\n")
 print ("<<< Get detailed information about ports on OpenFlow node '%s'" % nodeName)
 time.sleep(rundelay)
 ofswitch = OFSwitch(ctrl, nodeName)
 
 result = ofswitch.get_ports_list()
 status = result.get_status()
 if(status.eq(STATUS.OK) == True):
     ports = result.get_data()
     for port in ports:
         result = ofswitch.get_port_detail_info(port)
         status = result.get_status()
         if(status.eq(STATUS.OK) == True):
             print ("Port '%s' info:" % port)
             info = result.get_data()
             print json.dumps(info, indent=4)
         else:
             print ("\n")
             print ("!!!Demo terminated, reason: %s" % status.brief().lower())
开发者ID:jebpublic,项目名称:pydevodl,代码行数:31,代码来源:demo3.py

示例7: print

 status = result.get_status()
 if(status.eq(STATUS.OK) == True):
     print ("OpenFlow node names (composed as \"openflow:datapathid\"):")
     nodenames = result.get_data()
     print json.dumps(nodenames, indent=4)
 else:
     print ("\n")
     print ("!!!Demo terminated, reason: %s" % status.brief().lower())
     exit(0)
 
 
 print "\n"
 print ("<<< Get generic information about OpenFlow nodes")
 time.sleep(rundelay)
 for name in nodenames:
     ofswitch = OFSwitch(ctrl, name)
     result = ofswitch.get_switch_info()
     status = result.get_status()
     if(status.eq(STATUS.OK) == True):
         print ("'%s' info:" % name)
         info = result.get_data()
         print json.dumps(info, indent=4)
     else:
         print ("\n")
         print ("!!!Demo terminated, reason: %s" % status.brief().lower())
         exit(0)
 
 
 print ("\n")
 print (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
 print (">>> Demo End")
开发者ID:jebpublic,项目名称:pydevodl,代码行数:31,代码来源:demo1.py

示例8: print

     ctrlUname = d['ctrlUname']
     ctrlPswd = d['ctrlPswd']
     nodeName = d['nodeName']
 except:
     print ("Failed to get Controller device attributes")
     exit(0)
 
 
 print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
 print ("<<< Demo Start")
 print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
 
 rundelay = 5
 
 ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
 ofswitch = OFSwitch(ctrl, nodeName)
 
 print ("<<< 'Controller': %s, 'OpenFlow' switch: '%s'" % (ctrlIpAddr, nodeName))
 
 
 flow_table_id = 0
 flow_id_base = 12
 flow_id = flow_id_base
 flowEntries = []
 
 # Sample flow entry
 flow_entry = FlowEntry()
 flow_entry.set_flow_cookie(6001)
 flow_entry.set_flow_table_id(flow_table_id)
 flow_entry.set_flow_id(flow_id)
 flow_id += 1
开发者ID:jebpublic,项目名称:pydevodl,代码行数:31,代码来源:demo26.py

示例9: print

     ctrlPortNum = d['ctrlPortNum']
     ctrlUname = d['ctrlUname']
     ctrlPswd = d['ctrlPswd']
     nodeName = d['nodeName']
 except:
     print ("Failed to get Controller device attributes")
     exit(0)
 
 print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
 print ("<<< Demo Start")
 print ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
 
 rundelay = 5
 
 ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
 ofswitch = OFSwitch(ctrl, nodeName)
 
 table_id = 0
 priority = 500
 cookie = 1000
 cookie_mask = 255
 customer_port = 110
 provider_port = 111
 qinq_eth_type = ETH_TYPE_STAG  # 802.1ad (QinQ) VLAN tagged frame
 dot1q_eth_type = ETH_TYPE_CTAG # 802.1q VLAN tagged frame
 arp_eth_type = ETH_TYPE_ARP
 ip_eth_type = ETH_TYPE_IPv4
 provider_vlan_id = 100 # Provider VLAN
 customer_vlan_id = 998 # Customer VLAN   
 first_flow_id = 31
 
开发者ID:jebpublic,项目名称:pydevodl,代码行数:30,代码来源:demo25.py


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