예제 #1
0
def add_tbl_0_to_all_sws():
    switches = of.SwitchList(
        cfg.of_controller_ip,
        cfg.of_controller_port).get_response().get_sw_list()
    for sw in switches:
        print(sw)
        flow_mod = fm.Flowmod(sw)
        flow_mod.add_action(
            fm.Action(fm.ActionTypes.GotoTable, {'table_id': 100}))
        req = of.PushFlowmod(flow_mod, cfg.of_controller_ip,
                             cfg.of_controller_port)
        req.get_response()
예제 #2
0
def add_flow_mod():
    flow_mod = fm.Flowmod(5, hard_timeout=120)
    flow_mod.add_match(fm.Match(fm.MatchTypes.in_port, 2))
    flow_mod.add_action(fm.Action(fm.ActionTypes.Output, {'port': 1}))

    print(flow_mod)
    p.pprint(flow_mod.get_json())

    req = of.PushFlowmod(flow_mod, cfg.of_controller_ip,
                         cfg.of_controller_port)
    resp = req.get_response()
    print(resp)
예제 #3
0
def add_flow_mod_ip():
    hm = mapper.HostMapper(cfg.dns_server_ip, cfg.of_controller_ip,
                           cfg.of_controller_port)
    sw_dpid = hm.map_sw_to_dpid(5)
    flow_mod = fm.Flowmod(sw_dpid, hard_timeout=120, priority=20, table_id=100)
    match = fm.Match(fm.MatchTypes.ipv4_src, '10.0.15.2')
    match.add_criteria(fm.MatchTypes.eth_type, 2048)
    flow_mod.add_match(match)
    flow_mod.add_action(fm.Action(fm.ActionTypes.Output, {'port': 23}))
    print(flow_mod)
    p.pprint(flow_mod.get_json())
    req = of.PushFlowmod(flow_mod, cfg.of_controller_ip,
                         cfg.of_controller_port)
    resp = req.get_response()
    print(resp)
예제 #4
0
def add_low_prio_flow_mod(dpid):
    flow_mod = fm.Flowmod(dpid, priority=1, table_id=100)
    flow_mod.add_action(fm.Action(fm.ActionTypes.Output, {'port': 4294967293}))
    req = of.PushFlowmod(flow_mod, cfg.of_controller_ip,
                         cfg.of_controller_port)
    resp = req.get_response()
 def add_default_route(self, dpid, table_id):
     flow_mod = fm.Flowmod(dpid, priority=1, table_id=100)
     flow_mod.add_action(fm.Action(fm.ActionTypes.Output, {'port':4294967293}))
     self.push_flow_mod(dpid, flow_mod)