Skip to content

Commit a28d928

Browse files
author
sodn
committed
Merge branch 'main' into sodn_yang_connector_protofiles
2 parents e991341 + 571fc95 commit a28d928

File tree

9 files changed

+81
-10
lines changed

9 files changed

+81
-10
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
November 2024
2+
==========
3+
4+
November 26 - Yang v24.11
5+
------------------------
6+
7+
8+
9+
.. csv-table:: New Module Versions
10+
:header: "Modules", "Version"
11+
12+
``yang.connector``, v24.11
13+
``yang.ncdiff``, v24.11
14+
15+
16+
17+
18+
Changelogs
19+
^^^^^^^^^^
20+
21+
yang.connector
22+
""""""""""""""
23+
24+
yang.ncdiff
25+
"""""""""""

connector/docs/changelog/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Changelog
44
.. toctree::
55
:maxdepth: 2
66

7+
2024/november
78
2024/october
89
2024/September
910
2024/august
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
--------------------------------------------------------------------------------
2+
New
3+
--------------------------------------------------------------------------------
4+
* yang.connector
5+
* Added support for GRPC_MAX_RECEIVE_MESSAGE_LENGTH and GRPC_MAX_SEND_MESSAGE_LENGTH attributes to pick up from testbed settings.

connector/src/yang/connector/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"""
88

99
# metadata
10-
__version__ = '24.10'
10+
__version__ = '24.11'
1111
__author__ = (
1212
'Jonathan Yang <[email protected]>',
1313
'Siming Yuan <[email protected]',

connector/src/yang/connector/gnmi.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def banner(string):
3131
def to_plaintext(string):
3232
return string
3333

34+
from .settings import Settings
3435

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

243+
# connection_info is set by BaseConnection class
244+
self.settings = self.connection_info.pop('settings', Settings())
245+
242246
@property
243247
def connected(self):
244248
"""Return True if session is connected."""
@@ -304,7 +308,12 @@ def connect(self):
304308
port = str(dev_args.get('port'))
305309
target = '{0}:{1}'.format(host, port)
306310

307-
options = [('grpc.max_receive_message_length', 1000000000)]
311+
max_receive_message_length = self.settings.get('GRPC_MAX_RECEIVE_MESSAGE_LENGTH')
312+
max_send_message_length = self.settings.get('GRPC_MAX_SEND_MESSAGE_LENGTH')
313+
314+
options = [('grpc.max_receive_message_length', max_receive_message_length),
315+
('grpc.max_send_message_length', max_send_message_length)]
316+
308317
# Gather certificate settings
309318
root = dev_args.get('root_certificate')
310319
if not root:
@@ -351,6 +360,7 @@ def connect(self):
351360
)
352361
else:
353362
self.channel = grpc.insecure_channel(target)
363+
self.channel = grpc.insecure_channel(target, options)
354364
self.metadata = [
355365
("username", username),
356366
("password", password),

connector/src/yang/connector/settings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ def __init__(self, *args, **kwargs):
88
self.NETCONF_SCREEN_LOGGING_MAX_LINES = 40
99
# Enable XML formatting by default
1010
self.NETCONF_LOGGING_FORMAT_XML = True
11+
# Default receive message length
12+
self.GRPC_MAX_RECEIVE_MESSAGE_LENGTH = 1000000000
13+
# Default send message length
14+
self.GRPC_MAX_SEND_MESSAGE_LENGTH = 1000000000

connector/src/yang/connector/tests/test_gnmi.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ def test_connect(self):
2525
' ip : "1.2.3.4"\n' \
2626
' port: 830\n' \
2727
' username: admin\n' \
28-
' password: admin\n'
28+
' password: admin\n' \
2929

3030
testbed = loader.load(yaml)
3131
device = testbed.devices['dummy']
3232
with patch('yang.connector.gnmi.grpc.insecure_channel') as mock_grpc:
3333
device.connect(alias='gnmi', via='Gnmi')
34-
mock_grpc.assert_called_with('1.2.3.4:830')
34+
mock_grpc.assert_called_with('1.2.3.4:830', [('grpc.max_receive_message_length', 1000000000), ('grpc.max_send_message_length', 1000000000)])
3535

3636
def test_re_connect(self):
3737

@@ -46,16 +46,16 @@ def test_re_connect(self):
4646
' ip : "1.2.3.4"\n' \
4747
' port: 830\n' \
4848
' username: admin\n' \
49-
' password: admin\n'
49+
' password: admin\n' \
5050

5151
testbed = loader.load(yaml)
5252
device = testbed.devices['dummy']
5353
with patch('yang.connector.gnmi.grpc.insecure_channel') as mock_grpc:
5454
device.connect()
55-
mock_grpc.assert_called_with('1.2.3.4:830')
55+
mock_grpc.assert_called_with('1.2.3.4:830', [('grpc.max_receive_message_length', 1000000000), ('grpc.max_send_message_length', 1000000000)])
5656
device.disconnect()
5757
device.connect(alias='gnmi', via='Gnmi')
58-
mock_grpc.assert_called_with('1.2.3.4:830')
58+
mock_grpc.assert_called_with('1.2.3.4:830', [('grpc.max_receive_message_length', 1000000000), ('grpc.max_send_message_length', 1000000000)])
5959

6060
def test_connect_proxy(self):
6161
yaml = \
@@ -91,7 +91,7 @@ def test_connect_proxy(self):
9191
mock_tunnel.side_effect = ['830']
9292
device.connections['Gnmi'].sshtunnel = AttrDict({'tunnel_ip': '4.3.2.1'})
9393
device.connect(alias='gnmi', via='Gnmi')
94-
mock_grpc.assert_called_with('4.3.2.1:830')
94+
mock_grpc.assert_called_with('4.3.2.1:830', [('grpc.max_receive_message_length', 1000000000), ('grpc.max_send_message_length', 1000000000)])
9595
request = {
9696
"namespace": {"oc-acl": "http://openconfig.net/yang/acl"},
9797
"nodes": [
@@ -159,6 +159,29 @@ def test_get_prefix(self):
159159
path = xpath_util.get_prefix('rfc7951')
160160
self.assertIsInstance(path, proto.gnmi_pb2.Path)
161161

162+
def test_connect_grcp_length(self):
163+
yaml = \
164+
'devices:\n' \
165+
' dummy:\n' \
166+
' type: dummy_device\n' \
167+
' connections:\n' \
168+
' Gnmi:\n' \
169+
' class: yang.connector.Gnmi\n' \
170+
' protocol: gnmi\n' \
171+
' ip : "1.2.3.4"\n' \
172+
' port: 830\n' \
173+
' username: admin\n' \
174+
' password: admin\n' \
175+
' settings:\n' \
176+
' GRPC_MAX_RECEIVE_MESSAGE_LENGTH: 100\n' \
177+
' GRPC_MAX_SEND_MESSAGE_LENGTH: 100\n' \
178+
179+
testbed = loader.load(yaml)
180+
device = testbed.devices['dummy']
181+
with patch('yang.connector.gnmi.grpc.insecure_channel') as mock_grpc:
182+
device.connect(alias='gnmi', via='Gnmi')
183+
mock_grpc.assert_called_with('1.2.3.4:830', [('grpc.max_receive_message_length', 100), ('grpc.max_send_message_length', 100)])
184+
162185

163186
if __name__ == '__main__':
164187
unittest.main()

ncdiff/docs/usage_gnmi_set.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ YAML topology file:
2727
enable: admin
2828
line: admin
2929
connections:
30+
defaults:
31+
class: unicon.Unicon
3032
a:
3133
protocol: telnet
3234
ip: "1.2.3.4"
@@ -35,7 +37,8 @@ YAML topology file:
3537
protocol : telnet
3638
ip : "2.3.4.5"
3739
gnmi:
38-
class: yang.connector.gNMI
40+
class: yang.connector.Gnmi
41+
protocol: gnmi
3942
ip : "2.3.4.5"
4043
port: 50052
4144
timeout: 10

ncdiff/src/yang/ncdiff/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
edit-config message."""
55

66
# metadata
7-
__version__ = '24.10'
7+
__version__ = '24.11'
88
__author__ = 'Jonathan Yang <[email protected]>'
99
__contact__ = '[email protected]'
1010
__copyright__ = 'Cisco Systems, Inc.'

0 commit comments

Comments
 (0)