p4lang / p4runtime-shell

An interactive Python shell for P4Runtime
Apache License 2.0
76 stars 40 forks source link

The option "--role-name" isn't available #111

Closed Pterosaur closed 1 year ago

Pterosaur commented 1 year ago
Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.7/dist-packages/p4runtime_sh/__main__.py", line 2, in <module>
    main()  # pragma: no cover
  File "/usr/local/lib/python3.7/dist-packages/p4runtime_sh/shell.py", line 2830, in main
    ssl_options)
  File "/usr/local/lib/python3.7/dist-packages/p4runtime_sh/shell.py", line 2770, in setup
    client = P4RuntimeClient(device_id, grpc_addr, election_id, role_name, ssl_options)
  File "/usr/local/lib/python3.7/dist-packages/p4runtime_sh/p4runtime.py", line 191, in __init__
    self.set_up_stream()
  File "/usr/local/lib/python3.7/dist-packages/p4runtime_sh/p4runtime.py", line 236, in set_up_stream
    self.handshake()
  File "/usr/local/lib/python3.7/dist-packages/p4runtime_sh/p4runtime.py", line 246, in handshake
    arbitration.role.name = self.role_name
AttributeError: 'Role' object has no attribute 'name'
Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.7/dist-packages/p4runtime_sh/__main__.py", line 2, in <module>
    main()  # pragma: no cover
  File "/usr/local/lib/python3.7/dist-packages/p4runtime_sh/shell.py", line 2830, in main
    ssl_options)
  File "/usr/local/lib/python3.7/dist-packages/p4runtime_sh/shell.py", line 2780, in setup
    client.set_fwd_pipe_config(p4info_path, bin_path)
  File "/usr/local/lib/python3.7/dist-packages/p4runtime_sh/p4runtime.py", line 132, in handle
    return f(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/p4runtime_sh/p4runtime.py", line 284, in set_fwd_pipe_config
    req.role = self.role_name
AttributeError: 'SetForwardingPipelineConfigRequest' object has no attribute 'role'
antoninbas commented 1 year ago

You could be using an older version of the P4Runtime Protobuf messages. Latest version does have this field: https://github.com/p4lang/p4runtime/blob/45c056724a40cf4352acf40241a628136d4cb6ff/proto/p4/v1/p4runtime.proto#L601

Pterosaur commented 1 year ago

As @antoninbas said, it works after I upgraded my p4runtime library.