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

Added support for grpc message length #149

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
--------------------------------------------------------------------------------
New
--------------------------------------------------------------------------------
* yang.connector
* Added support for GRPC_MAX_RECEIVE_MESSAGE_LENGTH and GRPC_MAX_SEND_MESSAGE_LENGTH attributes to pick up from testbed settings.
12 changes: 11 additions & 1 deletion connector/src/yang/connector/gnmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def banner(string):
def to_plaintext(string):
return string

from .settings import Settings

# create a logger for this module
log = logging.getLogger(__name__)
Expand Down Expand Up @@ -239,6 +240,9 @@ def __init__(self, *args, **kwargs):
self.results = deque()
self.metadata = None

# connection_info is set by BaseConnection class
self.settings = self.connection_info.pop('settings', Settings())

@property
def connected(self):
"""Return True if session is connected."""
Expand Down Expand Up @@ -304,7 +308,12 @@ def connect(self):
port = str(dev_args.get('port'))
target = '{0}:{1}'.format(host, port)

options = [('grpc.max_receive_message_length', 1000000000)]
max_receive_message_length = self.settings.get('GRPC_MAX_RECEIVE_MESSAGE_LENGTH')
max_send_message_length = self.settings.get('GRPC_MAX_SEND_MESSAGE_LENGTH')

options = [('grpc.max_receive_message_length', max_receive_message_length),
('grpc.max_send_message_length', max_send_message_length)]

# Gather certificate settings
root = dev_args.get('root_certificate')
if not root:
Expand Down Expand Up @@ -351,6 +360,7 @@ def connect(self):
)
else:
self.channel = grpc.insecure_channel(target)
self.channel = grpc.insecure_channel(target, options)
self.metadata = [
("username", username),
("password", password),
Expand Down
4 changes: 4 additions & 0 deletions connector/src/yang/connector/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ def __init__(self, *args, **kwargs):
self.NETCONF_SCREEN_LOGGING_MAX_LINES = 40
# Enable XML formatting by default
self.NETCONF_LOGGING_FORMAT_XML = True
# Default receive message length
self.GRPC_MAX_RECEIVE_MESSAGE_LENGTH = 1000000000
# Default send message length
self.GRPC_MAX_SEND_MESSAGE_LENGTH = 1000000000