Skip to content

Commit 0d90023

Browse files
authored
grpc client implementation for active-active dualtor (sonic-net#248)
This PR is to support the gRPC interaction with to the SoC/Nic-Simulator for link manager state machine ActiveActiveStateMachine to work if the port is configured as active-active cable type. It supports the RPC's support for SONiC by creating channels/stubs when a cable is pulled in as well as when the ycabled is initialized from supervisord. The logic to treat a cable/port as "active-active" comes from minigraph/config_db and then this PR has the logic to take care of serving RPC's as requested by other daemons. It does the RPC call when an appropriate request lands the ycabled as described below The following Tables are served by ycabled for gRPC RPC by listening to changes in app DB request from linkmgr/orchagent and corresponding results are written to state DB. HW_MUX_CABLE_TABLE HW_MUX_TABLE_TABLE_PEER This PR also adds logic to listening to the forwarding state command table and get the response back from gRPC and write to forwarding state response FORWARDING_STATE_COMMAND -> FORWARDING_STATE_RESPONSE for getting the forwarding state request/response using gRPC This PR also has logic for gRPC library build using build_ext extension. The proto definition is present in proto/proto_out/ The setup.py changes make sure that gRPC libs are generated correctly. the corresponding gRPC libs are generated in proto_out directory in python packages directory and are imported by ycabled Motivation and Context DualToR active-active support for gRPC interface to support the state machine How Has This Been Tested? Unit-Tests and deploying changes on a DualToR testbed
1 parent 6b8bf69 commit 0d90023

File tree

5 files changed

+1373
-117
lines changed

5 files changed

+1373
-117
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
syntax = "proto3";
2+
3+
service DualToRActive {
4+
rpc QueryAdminForwardingPortState(AdminRequest) returns (AdminReply) {}
5+
rpc SetAdminForwardingPortState(AdminRequest) returns (AdminReply) {}
6+
rpc QueryOperationPortState(OperationRequest) returns (OperationReply) {}
7+
rpc QueryLinkState(LinkStateRequest) returns (LinkStateReply) {}
8+
rpc QueryServerVersion(ServerVersionRequest) returns (ServerVersionReply) {}
9+
}
10+
11+
message AdminRequest {
12+
repeated int32 portid = 1;
13+
repeated bool state = 2;
14+
}
15+
16+
message AdminReply {
17+
repeated int32 portid = 1;
18+
repeated bool state = 2;
19+
}
20+
21+
message OperationRequest {
22+
repeated int32 portid = 1;
23+
}
24+
25+
message OperationReply {
26+
repeated int32 portid = 1;
27+
repeated bool state = 2;
28+
}
29+
30+
message LinkStateRequest {
31+
repeated int32 portid = 1;
32+
}
33+
34+
message LinkStateReply {
35+
repeated int32 portid = 1;
36+
repeated bool state = 2;
37+
}
38+
39+
message ServerVersionRequest {
40+
string version = 1;
41+
}
42+
43+
message ServerVersionReply {
44+
string version = 1;
45+
}
46+
47+

sonic-ycabled/proto_out/__init__.py

Whitespace-only changes.

sonic-ycabled/setup.py

+30-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,34 @@
11
from setuptools import setup, find_packages
2+
from distutils.command.build_ext import build_ext as _build_ext
3+
import distutils.command
4+
5+
class GrpcTool(distutils.cmd.Command):
6+
def initialize_options(self):
7+
pass
8+
9+
def finalize_options(self):
10+
pass
11+
12+
def run(self):
13+
import grpc_tools.protoc
14+
15+
grpc_tools.protoc.main([
16+
'grpc_tools.protoc',
17+
'-Iproto',
18+
'--python_out=.',
19+
'--grpc_python_out=.',
20+
'proto/proto_out/linkmgr_grpc_driver.proto'
21+
])
22+
23+
class BuildExtCommand (_build_ext, object):
24+
def run(self):
25+
self.run_command('GrpcTool')
26+
super(BuildExtCommand, self).run()
227

328
setup(
429
name='sonic-ycabled',
530
version='1.0',
6-
description='Y-cable configuration daemon for SONiC',
31+
description='Y-cable and smart nic configuration daemon for SONiC',
732
license='Apache 2.0',
833
author='SONiC Team',
934
author_email='linuxnetdev@microsoft.com',
@@ -16,13 +41,16 @@
1641
'ycabled = ycable.ycable:main',
1742
]
1843
},
44+
cmdclass={'build_ext': BuildExtCommand,
45+
'GrpcTool': GrpcTool},
1946
install_requires=[
2047
# NOTE: This package also requires swsscommon, but it is not currently installed as a wheel
2148
'enum34; python_version < "3.4"',
2249
'sonic-py-common',
2350
],
2451
setup_requires=[
25-
'wheel'
52+
'wheel',
53+
'grpcio-tools'
2654
],
2755
tests_require=[
2856
'pytest',

0 commit comments

Comments
 (0)