示例#1
0
def ofp_bucket_to_loxi_bucket(pb):
    return of13.bucket(
        weight=pb.weight,
        watch_port=pb.watch_port,
        watch_group=pb.watch_group,
        actions=[to_loxi(action) for action in pb.actions]
    )
示例#2
0
def ofp_bucket_to_loxi_bucket(pb):
    return of13.bucket(
        weight=pb.weight,
        watch_port=pb.watch_port,
        watch_group=pb.watch_group,
        actions=[to_loxi(action) for action in pb.actions]
    )
示例#3
0
文件: of13.py 项目: kenchiang/loxigen
 def test_group_desc_stats_reply(self):
     obj = ofp.message.group_desc_stats_reply(
         xid=0x12345678,
         flags=0,
         entries=[
             ofp.group_desc_stats_entry(
                 type=ofp.OFPGT_FF,
                 group_id=1,
                 buckets=[
                     ofp.bucket(
                         weight=1,
                         watch_port=5,
                         watch_group=0xffffffff,
                         actions=[
                             ofp.action.output(port=5, max_len=0),
                             ofp.action.output(port=6, max_len=0)]),
                     ofp.bucket(
                         weight=1,
                         watch_port=6,
                         watch_group=0xffffffff,
                         actions=[
                             ofp.action.output(port=5, max_len=0),
                             ofp.action.output(port=6, max_len=0)])]),
             ofp.group_desc_stats_entry(type=ofp.OFPGT_FF, group_id=2, buckets=[])])
     buf = ''.join([
         '\x04', '\x13', # version, type
         '\x00\x80', # length
         '\x12\x34\x56\x78', # xid
         '\x00\x07', # stats_type
         '\x00\x00', # flags
         '\x00' * 4, # pad
         '\x00\x68', # entries[0].length
         '\x03', # entries[0].group_type
         '\x00', # entries[0].pad
         '\x00\x00\x00\x01', # entries[0].group_id
         '\x00\x30', # entries[0].buckets[0].len
         '\x00\x01', # entries[0].buckets[0].weight
         '\x00\x00\x00\x05', # entries[0].buckets[0].watch_port
         '\xff\xff\xff\xff', # entries[0].buckets[0].watch_group
         '\x00' * 4, # entries[0].pad
         '\x00\x00', # entries[0].buckets[0].actions[0].type
         '\x00\x10', # entries[0].buckets[0].actions[0].len
         '\x00\x00\x00\x05', # entries[0].buckets[0].actions[0].port
         '\x00\x00', # entries[0].buckets[0].actions[0].max_len
         '\x00' * 6, # entries[0].pad
         '\x00\x00', # entries[0].buckets[0].actions[1].type
         '\x00\x10', # entries[0].buckets[0].actions[1].len
         '\x00\x00\x00\x06', # entries[0].buckets[0].actions[1].port
         '\x00\x00', # entries[0].buckets[0].actions[1].max_len
         '\x00' * 6, # entries[0].pad
         '\x00\x30', # entries[0].buckets[1].len
         '\x00\x01', # entries[0].buckets[1].weight
         '\x00\x00\x00\x06', # entries[0].buckets[1].watch_port
         '\xff\xff\xff\xff', # entries[0].buckets[1].watch_group
         '\x00' * 4, # entries[0].pad
         '\x00\x00', # entries[0].buckets[1].actions[0].type
         '\x00\x10', # entries[0].buckets[1].actions[0].len
         '\x00\x00\x00\x05', # entries[0].buckets[1].actions[0].port
         '\x00\x00', # entries[0].buckets[1].actions[0].max_len
         '\x00' * 6, # entries[0].pad
         '\x00\x00', # entries[0].buckets[1].actions[1].type
         '\x00\x10', # entries[0].buckets[1].actions[1].len
         '\x00\x00\x00\x06', # entries[0].buckets[1].actions[1].port
         '\x00\x00', # entries[0].buckets[1].actions[1].max_len
         '\x00' * 6, # entries[0].pad
         '\x00\x08', # entries[1].length
         '\x03', # entries[1].group_type
         '\x00', # entries[1].pad
         '\x00\x00\x00\x02', # entries[1].group_id
     ])
     test_serialization(obj, buf)
示例#4
0
文件: of13.py 项目: kenchiang/loxigen
 def test_group_mod(self):
     obj = ofp.message.group_mod(
         xid=0x12345678,
         command=ofp.OFPGC_MODIFY,
         group_type=ofp.OFPGT_FF,
         group_id=5,
         buckets=[
             ofp.bucket(
                 weight=1,
                 watch_port=5,
                 watch_group=0xffffffff,
                 actions=[
                     ofp.action.output(port=5, max_len=0),
                     ofp.action.output(port=6, max_len=0)]),
             ofp.bucket(
                 weight=1,
                 watch_port=6,
                 watch_group=0xffffffff,
                 actions=[
                     ofp.action.output(port=5, max_len=0),
                     ofp.action.output(port=6, max_len=0)])])
     buf = ''.join([
         '\x04', '\x0f', # version, type
         '\x00\x70', # length
         '\x12\x34\x56\x78', # xid
         '\x00\x01', # command
         '\x03', # group_type
         '\x00', # pad
         '\x00\x00\x00\x05', # group_id
         '\x00\x30', # buckets[0].len
         '\x00\x01', # buckets[0].weight
         '\x00\x00\x00\x05', # buckets[0].watch_port
         '\xff\xff\xff\xff', # buckets[0].watch_group
         '\x00' * 4, # pad
         '\x00\x00', # buckets[0].actions[0].type
         '\x00\x10', # buckets[0].actions[0].len
         '\x00\x00\x00\x05', # buckets[0].actions[0].port
         '\x00\x00', # buckets[0].actions[0].max_len
         '\x00' * 6, # pad
         '\x00\x00', # buckets[0].actions[1].type
         '\x00\x10', # buckets[0].actions[1].len
         '\x00\x00\x00\x06', # buckets[0].actions[1].port
         '\x00\x00', # buckets[0].actions[1].max_len
         '\x00' * 6, # pad
         '\x00\x30', # buckets[1].len
         '\x00\x01', # buckets[1].weight
         '\x00\x00\x00\x06', # buckets[1].watch_port
         '\xff\xff\xff\xff', # buckets[1].watch_group
         '\x00' * 4, # pad
         '\x00\x00', # buckets[1].actions[0].type
         '\x00\x10', # buckets[1].actions[0].len
         '\x00\x00\x00\x05', # buckets[1].actions[0].port
         '\x00\x00', # buckets[1].actions[0].max_len
         '\x00' * 6, # pad
         '\x00\x00', # buckets[1].actions[1].type
         '\x00\x10', # buckets[1].actions[1].len
         '\x00\x00\x00\x06', # buckets[1].actions[1].port
         '\x00\x00', # buckets[1].actions[1].max_len
         '\x00' * 6, # pad
     ])
     test_serialization(obj, buf)