예제 #1
0
    flow_entry.add_instruction(instruction)

    # --- Match Fields: Ethernet Type
    #                   Input Port
    #                   MPLS Label
    match = Match()
    match.set_eth_type(eth_type)
    match.set_in_port(in_port)
    match.set_mpls_label(mpls_label)
    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) == True):
        print("<<< Flow successfully added to the Controller")
    else:
        print("\n")
        print("!!!Demo terminated, reason: %s" % status.detailed())
        exit(0)

    print("\n")
    print("<<< Get configured flow from the Controller")
    time.sleep(rundelay)
    result = ofswitch.get_configured_flow(table_id, flow_id)
    status = result.get_status()
    if (status.eq(STATUS.OK) == True):
        print("<<< Flow successfully read from the Controller")
예제 #2
0
파일: demo8.py 프로젝트: Elbrys/pydevodl
    match = Match()
    match.set_eth_type(eth_type)
    match.set_eth_src(eth_src)
    match.set_eth_dst(eth_dst)
    match.set_ipv4_src(ipv4_src)
    match.set_ipv4_dst(ipv4_dst)
    match.set_ip_proto(ip_proto)
    match.set_ip_dscp(ip_dscp)
    match.set_in_port(input_port)
    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)
    status = result.get_status()
    if(status.eq(STATUS.OK)):
        print ("<<< Flow successfully read from the Controller")
예제 #3
0
    
    print ("\n")
    print ("<<< Set OpenFlow flows on the Controller")

    print ("\n")
    print ("<<< Flows to be configured:")
    
    flowEntries = sorted(flowEntries, key=lambda fe: fe.get_flow_priority())
    for fe in flowEntries:
        print (" %s" % fe.to_ofp_oxm_syntax())
    
    
    time.sleep(rundelay)
    success = True
    for fe in flowEntries:
        result = ofswitch.add_modify_flow(fe)
        status = result.get_status()
        if(status.eq(STATUS.OK) == True):
            pass
        else:
            success = False
            print ("\n")
            print ("!!!Demo terminated, failed to add flow:\n '%s'" % fe.to_ofp_oxm_syntax())
            print (" Failure reason: %s" % status.detailed())
    
    if success:
        print "\n"
        print ("<<< Flows successfully added to the Controller")
    else:
        print "\n"
        print ("<<< Removing all flows from the Controller")
예제 #4
0
    ofswitch.delete_flows(flow_table_id)

    print("\n")
    print("<<< Set OpenFlow flows on the Controller")

    print("\n")
    print("<<< Flows to be configured:")

    flowEntries = sorted(flowEntries, key=lambda fe: fe.get_flow_priority())
    for fe in flowEntries:
        print(" %s" % fe.to_ofp_oxm_syntax())

    time.sleep(rundelay)
    success = True
    for fe in flowEntries:
        result = ofswitch.add_modify_flow(fe)
        status = result.get_status()
        if (status.eq(STATUS.OK) == True):
            pass
        else:
            success = False
            print("\n")
            print("!!!Demo terminated, failed to add flow:\n '%s'" %
                  fe.to_ofp_oxm_syntax())
            print(" Failure reason: %s" % status.detailed())

    if success:
        print "\n"
        print("<<< Flows successfully added to the Controller")
    else:
        print "\n"
예제 #5
0
 
 flow_entry1.add_instruction(instruction)
 
 match = Match()
 
 match.set_eth_type(arp_eth_type)
 match.set_vlan_id(customer_vlan_id)
 match.set_in_port(in_port = customer_port)
 
 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) == True):
     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)
 
 # ---------------------------------------------------
 # Second flow entry
 # ---------------------------------------------------
 print "\n"
 print ("<<< Set OpenFlow flow on the Controller")
 print ("        Match:  Ethernet Type (%s)\n"