Skip to content

Commit 8276f0e

Browse files
author
rincewind
committed
Introduce insecure option for usage with self-signed certificates
1 parent 2e7e2c2 commit 8276f0e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

check_vmware_nsxt.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class Client:
8888

8989
API_PREFIX = '/api/v1/'
9090

91-
def __init__(self, api, username, password, logger=None):
91+
def __init__(self, api, username, password, logger=None, verify=True):
9292
# TODO: parse and validate url?
9393

9494
self.api = api
@@ -114,7 +114,7 @@ def request(self, url, method='GET', **kwargs):
114114
self.logger.debug("starting API %s request from: %s", method, url)
115115

116116
try:
117-
response = requests.request(method, request_url, auth=HTTPBasicAuth(self.username, self.password))
117+
response = requests.request(method, request_url, auth=HTTPBasicAuth(self.username, self.password), verify=verify)
118118
except requests.exceptions.RequestException as e:
119119
raise CriticalException(e)
120120

@@ -397,6 +397,8 @@ def parse_args():
397397

398398
args.add_argument('--version', '-V', help='Print version', action='store_true')
399399

400+
args.add_argument('--insecure', help='Do not verify TLS certificate. Be careful with this option, please', action='store_true', required=False)
401+
400402
return args.parse_args()
401403

402404

@@ -409,7 +411,7 @@ def main():
409411
print("check_vmware_nsxt version %s" % VERSION)
410412
return 0
411413

412-
client = Client(args.api, args.username, args.password)
414+
client = Client(args.api, args.username, args.password, verify=args.insecure)
413415

414416
if args.mode == 'cluster-status':
415417
return client.get_cluster_status().print_and_return()

0 commit comments

Comments
 (0)