Skip to content

Commit

Permalink
grpc client implementation for active-active dualtor (sonic-net#248)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vdahiya12 authored May 31, 2022
1 parent 6b8bf69 commit 0d90023
Show file tree
Hide file tree
Showing 5 changed files with 1,373 additions and 117 deletions.
47 changes: 47 additions & 0 deletions sonic-ycabled/proto/proto_out/linkmgr_grpc_driver.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
syntax = "proto3";

service DualToRActive {
rpc QueryAdminForwardingPortState(AdminRequest) returns (AdminReply) {}
rpc SetAdminForwardingPortState(AdminRequest) returns (AdminReply) {}
rpc QueryOperationPortState(OperationRequest) returns (OperationReply) {}
rpc QueryLinkState(LinkStateRequest) returns (LinkStateReply) {}
rpc QueryServerVersion(ServerVersionRequest) returns (ServerVersionReply) {}
}

message AdminRequest {
repeated int32 portid = 1;
repeated bool state = 2;
}

message AdminReply {
repeated int32 portid = 1;
repeated bool state = 2;
}

message OperationRequest {
repeated int32 portid = 1;
}

message OperationReply {
repeated int32 portid = 1;
repeated bool state = 2;
}

message LinkStateRequest {
repeated int32 portid = 1;
}

message LinkStateReply {
repeated int32 portid = 1;
repeated bool state = 2;
}

message ServerVersionRequest {
string version = 1;
}

message ServerVersionReply {
string version = 1;
}


Empty file.
32 changes: 30 additions & 2 deletions sonic-ycabled/setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,34 @@
from setuptools import setup, find_packages
from distutils.command.build_ext import build_ext as _build_ext
import distutils.command

class GrpcTool(distutils.cmd.Command):
def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
import grpc_tools.protoc

grpc_tools.protoc.main([
'grpc_tools.protoc',
'-Iproto',
'--python_out=.',
'--grpc_python_out=.',
'proto/proto_out/linkmgr_grpc_driver.proto'
])

class BuildExtCommand (_build_ext, object):
def run(self):
self.run_command('GrpcTool')
super(BuildExtCommand, self).run()

setup(
name='sonic-ycabled',
version='1.0',
description='Y-cable configuration daemon for SONiC',
description='Y-cable and smart nic configuration daemon for SONiC',
license='Apache 2.0',
author='SONiC Team',
author_email='linuxnetdev@microsoft.com',
Expand All @@ -16,13 +41,16 @@
'ycabled = ycable.ycable:main',
]
},
cmdclass={'build_ext': BuildExtCommand,
'GrpcTool': GrpcTool},
install_requires=[
# NOTE: This package also requires swsscommon, but it is not currently installed as a wheel
'enum34; python_version < "3.4"',
'sonic-py-common',
],
setup_requires=[
'wheel'
'wheel',
'grpcio-tools'
],
tests_require=[
'pytest',
Expand Down
Loading

0 comments on commit 0d90023

Please sign in to comment.