Exemplo n.º 1
0
def create_flow_mod(dp, config):

    matches_config = FlowDescription.get_matches(config)
    matches = Matches.create_matches(dp, matches_config)

    instr_config = FlowDescription.get_instr_config(config)
    instructions = Instructions.create_instructions(dp, instr_config)

    mod = dp.ofproto_parser.OFPFlowMod (
        dp,
        cookie = 0,
        cookie_mask = 0,
        table_id = Utils.get_table(config['table']),
        command = Utils.get_mod_command(dp, config['cmd']),
        idle_timeout = 0,
        hard_timeout = 0,
        priority = 0,
        buffer_id = 0,
        out_port = Utils.get_mod_port(dp, config['port']),
        out_group = Utils.get_mod_group(dp, config['group']),
        flags=0,
        match=matches,
        instructions=instructions
    )
    return mod
Exemplo n.º 2
0
def create_buckets(dp, config):
    LOG.debug('BUCKETS:')
    buckets = []
    '''
    Buckets config is a list
    '''
    LOG.debug('buckets config: %s', config)
    for entry in config:
        LOG.debug('entry: %s ', entry)

        actions = Actions.create_actions(dp, entry['actions'])

        bucket = dp.ofproto_parser.OFPBucket(
            weight=int(entry['weight'], 0),
            watch_port=Utils.get_mod_port(dp, entry['watch_port']),
            watch_group=Utils.get_mod_group(dp, entry['watch_group']),
            actions=actions)
        LOG.debug('bucket: %s', bucket)
        buckets.append(bucket)
        LOG.debug('buckets: %s', buckets)
    return buckets
Exemplo n.º 3
0
def create_buckets(dp, config):
    LOG.debug('BUCKETS:')
    buckets = []
    '''
    Buckets config is a list
    '''
    LOG.debug('buckets config: %s', config)
    for entry in config:
        LOG.debug('entry: %s ', entry)
        
        actions = Actions.create_actions(dp, entry['actions'])

        bucket = dp.ofproto_parser.OFPBucket(
            weight = int(entry['weight'], 0),
            watch_port = Utils.get_mod_port(dp,entry['watch_port']),
            watch_group = Utils.get_mod_group(dp,entry['watch_group']),
            actions = actions
        ) 
        LOG.debug('bucket: %s', bucket)
        buckets.append(bucket)
        LOG.debug('buckets: %s', buckets)
    return buckets
Exemplo n.º 4
0
def create_flow_mod(dp, config):

    matches_config = FlowDescription.get_matches(config)
    matches = Matches.create_matches(dp, matches_config)

    instr_config = FlowDescription.get_instr_config(config)
    instructions = Instructions.create_instructions(dp, instr_config)

    mod = dp.ofproto_parser.OFPFlowMod(
        dp,
        cookie=0,
        cookie_mask=0,
        table_id=Utils.get_table(config['table']),
        command=Utils.get_mod_command(dp, config['cmd']),
        idle_timeout=0,
        hard_timeout=0,
        priority=0,
        buffer_id=0,
        out_port=Utils.get_mod_port(dp, config['port']),
        out_group=Utils.get_mod_group(dp, config['group']),
        flags=0,
        match=matches,
        instructions=instructions)
    return mod