Skip to content

skip verify gnmi #156

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions connector/src/yang/connector/gnmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.device = kwargs.get('device')
self.dev_args = self.connection_info
self.skip_verify = kwargs.get('skip_verify')
if self.dev_args.get('protocol', '') != 'gnmi':
msg = 'Invalid protocol {0}'.format(self.dev_args.get('protocol', ''))
raise TypeError(msg)
Expand Down Expand Up @@ -266,6 +267,7 @@ def connect(self):
dev_args = self.dev_args
username = dev_args.get('username', '')
password = dev_args.get('password', '')
skip_verify = dev_args.get('skip_verify')

if dev_args.get('custom_log', ''):
self.log = dev_args.get('custom_log')
Expand Down Expand Up @@ -368,18 +370,17 @@ def connect(self):
self.log.info("Connecting insecure channel")

self.service = proto.gnmi_pb2_grpc.gNMIStub(self.channel)


resp = self.capabilities()
if resp:
log.info('\ngNMI version: {0} supported encodings: {1}\n\n'.format(
resp.gNMI_version,
[proto.gnmi_pb2.Encoding.Name(i) for i in resp.supported_encodings]))
log.info(banner('gNMI CONNECTED'))
else:
log.info(banner('gNMI Capabilities not returned'))
self.disconnect()
raise gNMIException('Connection not successful')
if not skip_verify:
resp = self.capabilities()
if resp:
log.info('\ngNMI version: {0} supported encodings: {1}\n\n'.format(
resp.gNMI_version,
[proto.gnmi_pb2.Encoding.Name(i) for i in resp.supported_encodings]))
log.info(banner('gNMI CONNECTED'))
else:
log.info(banner('gNMI Capabilities not returned'))
self.disconnect()
raise gNMIException('Connection not successful')

def set(self, request):
"""Gnmi SET method.
Expand Down