Add support to install multicast rules (#289)

This commit is contained in:
Tu Dang
2019-09-25 10:38:54 -07:00
committed by Nate Foster
parent 590f4ff6f2
commit d1705a797c
3 changed files with 41 additions and 0 deletions

View File

@@ -133,6 +133,18 @@ class SwitchConnection(object):
yield response
def WriteMulticastGroupEntry(self, mc_entry, dry_run=False):
request = p4runtime_pb2.WriteRequest()
request.device_id = self.device_id
request.election_id.low = 1
update = request.updates.add()
update.type = p4runtime_pb2.Update.INSERT
update.entity.packet_replication_engine_entry.CopyFrom(mc_entry)
if dry_run:
print "P4Runtime Write:", request
else:
self.client_stub.Write(request)
class GrpcRequestLogger(grpc.UnaryUnaryClientInterceptor,
grpc.UnaryStreamClientInterceptor):
"""Implementation of a gRPC interceptor that logs request to a file"""