-
Couldn't load subscription status.
- Fork 7
Enhance gnmi_cli_py #4
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
Conversation
d3ecdf4 to
4e6cd2b
Compare
Original error message seems useful. If you do not check err.code, will you print similar fancy message? If not, let's use Refers to: gnmi_cli_py/py_gnmicli.py:557 in 31ba981. [](commit_id = 31ba981, deletion_comment = True) |
gnmi_cli_py/py_gnmicli.py
Outdated
| 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]') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated to use *
Could you check the go implementation https://github.com/google/gnxi/blob/2cca83d741c326d88cc3652cfbac26161bbb7209/utils/xpath/xpath.go#L255. Refers to: gnmi_cli_py/py_gnmicli.py:173 in 88adc85. [](commit_id = 88adc85, deletion_comment = False) |
gnmi_cli_py/py_gnmicli.py
Outdated
| 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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
gnmi_cli_py/py_gnmicli.py
Outdated
| raise Exception('Error while loading proto: %s' % str(e)) | ||
| val.proto_bytes = proto_bytes | ||
| return val | ||
| elif '#' in json_value: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added comment.
There was a problem hiding this 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"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
gnmi_cli_py/py_gnmicli.py
Outdated
| '\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.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
gnmi_cli_py/py_gnmicli.py
Outdated
| 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' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
gnmi_cli_py/py_gnmicli.py
Outdated
| gnmi_elems = [] | ||
| gnmi_origin = None | ||
| if p_names and ":" in p_names[0]: | ||
| res = p_names[0].split(":", 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Upstream PR for google/gnxi:
google#350
google#351