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
def create_group_mod(dp, config): buckets_config = FlowDescription.get_buckets_config(config) buckets = Buckets.create_buckets(dp, buckets_config) mod = dp.ofproto_parser.OFPGroupMod( dp, Utils.get_group_mod_command(dp, config['cmd']), Utils.get_mod_type(dp, config['type']), Utils.get_mod_group(dp, config['group_id']), buckets) return mod
def create_group_mod(dp, config): buckets_config= FlowDescription.get_buckets_config(config) buckets = Buckets.create_buckets(dp, buckets_config) mod = dp.ofproto_parser.OFPGroupMod( dp, Utils.get_group_mod_command(dp, config['cmd']), Utils.get_mod_type(dp, config['type']), Utils.get_mod_group(dp, config['group_id']), buckets ) return mod
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
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
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