Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple_Switch stops to work and pops up AttributeError: 'module' object has no attribute 'P4RuntimeStub' #74

Open
rafaelsilvag opened this issue Mar 3, 2020 · 1 comment

Comments

@rafaelsilvag
Copy link

rafaelsilvag commented Mar 3, 2020

The following message appers after running the p4app script.

s1 Starting P4 switch s1.
simple_switch -i 1@s1-eth1 -i 2@s1-eth2 -i 3@s1-eth3 --nanolog ipc:///tmp/bm-0-log.ipc --device-id 0 /tmp/p4app-logs/polka.json --thrift-port 9090
P4 switch s1 has been started.
Traceback (most recent call last):
  File "/p4app/main.py", line 461, in <module>
    main()
  File "/p4app/main.py", line 415, in main
    net = config_network(bw, method, n, is_fabric)
  File "/p4app/main.py", line 135, in config_network
    net.start()
  File "/scripts/p4app.py", line 100, in start
    Mininet.start(self, *args, **kwargs)
  File "build/bdist.linux-x86_64/egg/mininet/net.py", line 548, in start
  File "/scripts/p4_mininet.py", line 353, in start
    proto_dump_file='/tmp/p4app-logs/' + self.name + '-p4runtime-requests.txt')
  File "/scripts/p4runtime_lib/switch.py", line 44, in __init__
    self.client_stub = p4runtime_pb2.P4RuntimeStub(self.channel)
AttributeError: 'module' object has no attribute 'P4RuntimeStub'

I have used the latest p4app version, and it has appeared for all tested protofub, p4c, PI and behavioral-model versions.

@MehTheHedgehog
Copy link

We also encountered this problem during our P4 testing.

@rafaelsilvag If you are interested in local solution for this issue, here is what needs to be changed in p4app to resolve this issue.

index 4c38c2d..392701b 100644
--- a/docker/scripts/p4runtime_lib/switch.py
+++ b/docker/scripts/p4runtime_lib/switch.py
@@ -18,6 +18,7 @@ from datetime import datetime
 
 import grpc
 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants