Skip to content

Conversation

@ganglyu
Copy link

@ganglyu ganglyu commented Aug 31, 2023

  1. Upgrade grpcio and grpcio-tools
  2. Support origin in gnmi prefix
  3. Print grpc error code
  4. Support PROTO encoding for gnmi get
  5. Ignore / in []
  6. Support proto_bytes for gnmi set
  7. Support multiple path and value for gnmi set, get and subscribe

Upstream PR for google/gnxi:
google#350
google#351

@qiluo-msft
Copy link

qiluo-msft commented Sep 4, 2023

    print("Client receives an exception '{}' indicating gNMI server is shut down and Exiting ..."

Original error message seems useful. If you do not check err.code, will you print similar fancy message? If not, let's use if-else to print UNAVAILABLE message and general message. #Closed


Refers to: gnmi_cli_py/py_gnmicli.py:557 in 31ba981. [](commit_id = 31ba981, deletion_comment = True)

parser.add_argument('--update_count', default=0, type=int, help='Max number of streaming updates to receive. 0 means no limit.')
parser.add_argument('--subscribe_mode', default=0, type=int, help='[0=STREAM, 1=ONCE, 2=POLL]')
parser.add_argument('--encoding', default=0, type=int, help='[0=JSON, 1=BYTES, 2=PROTO, 3=ASCII, 4=JSON_IETF]')
parser.add_argument('--encoding', default=4, type=int, help='[0=JSON, 1=BYTES, 2=PROTO, 3=ASCII, 4=JSON_IETF]')
Copy link

@qiluo-msft qiluo-msft Sep 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4

This is a valid bugfix on its own. Suggest separate into a standalone commit, not to mix with proto feature. #Closed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is not necessary, so I have reverted it.

i = 0
for notification in response.notification:
for update in notification.update:
with open(proto_list[i], 'wb') as fp:
Copy link

@qiluo-msft qiluo-msft Sep 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[i]

Possible to index out of range? #Closed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

' with "@"; eg "@interfaces.json".',
required=False)
parser.add_argument('--proto', type=str, help='Output files for proto bytes',
nargs="+", required=False)
Copy link

@qiluo-msft qiluo-msft Sep 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"+"

You assume at least one file. If the query is expected to fail, do you allow gnmicli to have 0 args? #Closed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated to use *

@qiluo-msft
Copy link

qiluo-msft commented Sep 4, 2023

def _path_names(xpath):

Could you check the go implementation https://github.com/google/gnxi/blob/2cca83d741c326d88cc3652cfbac26161bbb7209/utils/xpath/xpath.go#L255.
Is it more robust? #Closed


Refers to: gnmi_cli_py/py_gnmicli.py:173 in 88adc85. [](commit_id = 88adc85, deletion_comment = False)

try:
proto_bytes = six.moves.builtins.open(json_value.strip('$'), 'rb').read()
except (IOError, ValueError) as e:
raise Exception('Error while loading proto: %s' % str(e))
Copy link

@qiluo-msft qiluo-msft Sep 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exception

Suggest to use ValueError. Does the error message contains the filename? If not, suggest add it to help troubleshoot. #Closed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

raise Exception('Error while loading proto: %s' % str(e))
val.proto_bytes = proto_bytes
return val
elif '#' in json_value:
Copy link

@qiluo-msft qiluo-msft Sep 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'#' in json_value

Is it a new feature in command line? I do not see any usage text or code comment, so hard to read. #Closed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Use '#' to indicate empty value" is kind of hacky to me.
could you just use empty python string to "to indicate empty value"?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

'\nCan be Leaf value or JSON file. If JSON file, prepend'
' with "@"; eg "@interfaces.json".',
required=False)
parser.add_argument('--value_list', type=str, help='Value for SetRequest.'
Copy link

@qiluo-msft qiluo-msft Sep 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

value_list

Possible to reuse original -val with nargs="+" ? #Closed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

parser.add_argument('-x', '--xpath', type=str, help='The gNMI path utilized'
'in the GetRequest or Subscirbe', required=True)
'in the GetRequest or Subscirbe')
parser.add_argument('--xpath_list', type=str, help='The gNMI path utilized'
Copy link

@qiluo-msft qiluo-msft Sep 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--xpath_list

Possible to reuse original -x with nargs="+" ? #Closed

Copy link
Author

@ganglyu ganglyu Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

gnmi_elems = []
gnmi_origin = None
if p_names and ":" in p_names[0]:
res = p_names[0].split(":", 1)
Copy link

@qiluo-msft qiluo-msft Sep 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

":"

If it your invention or gnmi protocol? #Closed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not gnmi protocol.
Google gnxi was using the same solution: google@89f51f0
Now they use prefix to support origin:
google#295
Please let me know which one is better.

Copy link
Author

@ganglyu ganglyu Sep 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to gnmi spec: In the case that a prefix is specified, it MUST specify any required origin.
Now I use prefix to support origin

@ganglyu ganglyu requested a review from qiluo-msft September 6, 2023 01:52
@ganglyu ganglyu closed this by deleting the head repository Sep 7, 2023
@ganglyu ganglyu reopened this Sep 8, 2023
@lguohan lguohan merged commit 3adf8b9 into lguohan:master Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants