P4 Developer Day May 2019 (#252)
* Update user-bootstrap to use latest version (#251) * p4c tests are failing in latest version. So, let's skip it during vagrant provisioning * Update tutorial to use latest version of P4 tools Modify switch.py to handle setting default_action Use --p4runtime-files instead of deprecated --p4runtime-file and --p4runtime-format flags Provide standard_metadata for mark_to_drop * Fix path for ECN exercise
This commit is contained in:
@@ -17,7 +17,8 @@ import sys
|
||||
|
||||
from google.rpc import status_pb2, code_pb2
|
||||
import grpc
|
||||
from p4 import p4runtime_pb2
|
||||
from p4.v1 import p4runtime_pb2
|
||||
from p4.v1 import p4runtime_pb2_grpc
|
||||
|
||||
# Used to indicate that the gRPC error Status object returned by the server has
|
||||
# an incorrect format.
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
import re
|
||||
|
||||
import google.protobuf.text_format
|
||||
from p4 import p4runtime_pb2
|
||||
from p4.config import p4info_pb2
|
||||
from p4.v1 import p4runtime_pb2
|
||||
from p4.config.v1 import p4info_pb2
|
||||
|
||||
from convert import encode
|
||||
|
||||
@@ -97,10 +97,7 @@ class P4InfoHelper(object):
|
||||
p4runtime_match = p4runtime_pb2.FieldMatch()
|
||||
p4runtime_match.field_id = p4info_match.id
|
||||
match_type = p4info_match.match_type
|
||||
if match_type == p4info_pb2.MatchField.VALID:
|
||||
valid = p4runtime_match.valid
|
||||
valid.value = bool(value)
|
||||
elif match_type == p4info_pb2.MatchField.EXACT:
|
||||
if match_type == p4info_pb2.MatchField.EXACT:
|
||||
exact = p4runtime_match.exact
|
||||
exact.value = encode(value, bitwidth)
|
||||
elif match_type == p4info_pb2.MatchField.LPM:
|
||||
|
||||
@@ -17,7 +17,8 @@ from abc import abstractmethod
|
||||
from datetime import datetime
|
||||
|
||||
import grpc
|
||||
from p4 import p4runtime_pb2
|
||||
from p4.v1 import p4runtime_pb2
|
||||
from p4.v1 import p4runtime_pb2_grpc
|
||||
from p4.tmp import p4config_pb2
|
||||
|
||||
MSG_LOG_MAX_LEN = 1024
|
||||
@@ -41,7 +42,7 @@ class SwitchConnection(object):
|
||||
if proto_dump_file is not None:
|
||||
interceptor = GrpcRequestLogger(proto_dump_file)
|
||||
self.channel = grpc.intercept_channel(self.channel, interceptor)
|
||||
self.client_stub = p4runtime_pb2.P4RuntimeStub(self.channel)
|
||||
self.client_stub = p4runtime_pb2_grpc.P4RuntimeStub(self.channel)
|
||||
self.requests_stream = IterableQueue()
|
||||
self.stream_msg_resp = self.client_stub.StreamChannel(iter(self.requests_stream))
|
||||
self.proto_dump_file = proto_dump_file
|
||||
@@ -89,7 +90,10 @@ class SwitchConnection(object):
|
||||
request.device_id = self.device_id
|
||||
request.election_id.low = 1
|
||||
update = request.updates.add()
|
||||
update.type = p4runtime_pb2.Update.INSERT
|
||||
if table_entry.is_default_action:
|
||||
update.type = p4runtime_pb2.Update.MODIFY
|
||||
else:
|
||||
update.type = p4runtime_pb2.Update.INSERT
|
||||
update.entity.table_entry.CopyFrom(table_entry)
|
||||
if dry_run:
|
||||
print "P4Runtime Write:", request
|
||||
|
||||
Reference in New Issue
Block a user