Skip to content

Commit 569faca

Browse files
authored
Add patch for gnmi client to support extensive configurations (#23151)
<!-- Please make sure you've read and understood our contributing guidelines: https://github.com/Azure/SONiC/blob/gh-pages/CONTRIBUTING.md failure_prs.log skip_prs.log Make sure all your commits include a signature generated with `git commit -s` ** If this is a bug fix, make sure your description includes "fixes #xxxx", or "closes #xxxx" or "resolves #xxxx" Please provide the following information: --> #### Why I did it The command line has a length limitation, which restricts the number of configurations it can support. ##### Work item tracking - Microsoft ADO **(number only)**: #### How I did it To overcome this limitation, introduce a new argument: arg_file. Users can place extensive configurations within the arg_file, enabling the GNMI client to handle a larger and more complex set of configurations. #### How to verify it Run gnmi end to end test <!-- If PR needs to be backported, then the PR must be tested against the base branch and the earliest backport release branch and provide tested image version on these two branches. For example, if the PR is requested for master, 202211 and 202012, then the requester needs to provide test results on master and 202012. --> #### Which release branch to backport (provide reason below if selected) <!-- - Note we only backport fixes to a release branch, *not* features! - Please also provide a reason for the backporting below. - e.g. - [x] 202006 --> - [ ] 201811 - [ ] 201911 - [ ] 202006 - [ ] 202012 - [ ] 202106 - [ ] 202111 - [ ] 202205 - [ ] 202211 - [ ] 202305 #### Tested branch (Please provide the tested image version) <!-- - Please provide tested image version - e.g. - [x] 20201231.100 --> - [ ] <!-- image version 1 --> - [ ] <!-- image version 2 --> #### Description for the changelog <!-- Write a short (one line) summary that describes the changes in this pull request for inclusion in the changelog: --> <!-- Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU. --> #### Link to config_db schema for YANG module changes <!-- Provide a link to config_db schema for the table for which YANG model is defined Link should point to correct section on https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md --> #### A picture of a cute animal (not mandatory but encouraged)
1 parent 32ef97a commit 569faca

2 files changed

Lines changed: 50 additions & 1 deletion

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
From 5c8bc9e0142952748b327375ea2a45813dfe297f Mon Sep 17 00:00:00 2001
2+
From: ganglyu <ganglv@microsoft.com>
3+
Date: Wed, 9 Apr 2025 16:04:04 +0800
4+
Subject: [PATCH] Add args file to support huge configurations
5+
6+
The command line has a length limitation, which restricts the number of configurations it can support. To overcome this limitation, introduce a new argument: arg_file. Users can place extensive configurations within the arg_file, enabling the GNMI client to handle a larger and more complex set of configurations.
7+
8+
---
9+
gnmi_cli_py/py_gnmicli.py | 9 +++++++++
10+
1 file changed, 9 insertions(+)
11+
12+
diff --git a/gnmi_cli_py/py_gnmicli.py b/gnmi_cli_py/py_gnmicli.py
13+
index 0ea6f3d..00549e3 100644
14+
--- a/gnmi_cli_py/py_gnmicli.py
15+
+++ b/gnmi_cli_py/py_gnmicli.py
16+
@@ -35,6 +35,7 @@ import json
17+
import logging
18+
import os
19+
import re
20+
+import shlex
21+
import ssl
22+
import sys
23+
import string
24+
@@ -94,6 +95,8 @@ def _create_parser():
25+
'\npython py_gnmicli.py -t 127.0.0.1 -p 8080 -x \'/access-points/'
26+
'access-point[hostname=test-ap]/\' -rcert ~/certs/target-cert.crt -o '
27+
'openconfig.example.com')
28+
+ parser.add_argument('--arg_file', type=str, help='The args file',
29+
+ required=False)
30+
parser.add_argument('-t', '--target', type=str, help='The gNMI Target',
31+
required=True)
32+
parser.add_argument('-p', '--port', type=str, help='The port the gNMI Target '
33+
@@ -533,6 +536,12 @@ def subscribe_start(stub, options, req_iterator):
34+
def main():
35+
argparser = _create_parser()
36+
args = vars(argparser.parse_args())
37+
+ # Merge input args with args from arg_file if specified
38+
+ if args['arg_file']:
39+
+ with open(args['arg_file'], 'r') as file:
40+
+ file_content = file.read()
41+
+ simulated_args = shlex.split(file_content)
42+
+ args.update(vars(argparser.parse_args(simulated_args)))
43+
if args['version']:
44+
print(__version__)
45+
sys.exit()
46+
--
47+
2.48.1.windows.1
48+

dockers/docker-ptf/gnxi-patches/series

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
0002-Adding-support-for-subscribe-mode-1.patch
33
0003-gNMI_client-Add-an-option-to-trigger-memory-spike-on.patch
44
0004-Add-support-for-streaming-structured-events-in-night.patch
5-
0005-Enhance-gnmi_cli_py-4.patch
5+
0005-Enhance-gnmi_cli_py-4.patch
6+
0006-Add-support-for-extensive-configurations.patch

0 commit comments

Comments
 (0)