From 62ec0b89ad1eb68b51b3984c872e354a235f0d49 Mon Sep 17 00:00:00 2001 From: John Bowdre Date: Fri, 15 Jan 2021 14:55:54 -0600 Subject: [PATCH] code cleanup --- src/main/python/allocate_ip/source.py | 3 +-- src/main/python/get_ip_ranges/source.py | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/python/allocate_ip/source.py b/src/main/python/allocate_ip/source.py index d338dc1..2f4e7f7 100644 --- a/src/main/python/allocate_ip/source.py +++ b/src/main/python/allocate_ip/source.py @@ -82,12 +82,11 @@ def auth_session(uri, auth, cert): req = requests.post(auth_uri, auth=auth, verify=cert) if req.status_code != 200: raise requests.exceptions.RequestException('Authentication Failure!') - print('Auth success.') token = {"token": req.json()['data']['token']} return token def do_allocate_ip(self, auth_credentials, cert): -# Build variables + # Build variables username = auth_credentials["privateKeyId"] password = auth_credentials["privateKey"] hostname = self.inputs["endpoint"]["endpointProperties"]["hostName"] diff --git a/src/main/python/get_ip_ranges/source.py b/src/main/python/get_ip_ranges/source.py index 954ebae..950856e 100644 --- a/src/main/python/get_ip_ranges/source.py +++ b/src/main/python/get_ip_ranges/source.py @@ -44,7 +44,6 @@ def auth_session(uri, auth, cert): req = requests.post(auth_uri, auth=auth, verify=cert) if req.status_code != 200: raise requests.exceptions.RequestException('Authentication Failure!') - print('Auth success.') token = {"token": req.json()['data']['token']} return token @@ -63,8 +62,8 @@ def do_get_ip_ranges(self, auth_credentials, cert): # Request list of subnets subnet_uri = f'{uri}/subnets/' ipRanges = [] - subnet_req = requests.get(f'{subnet_uri}?filter_by=isPool&filter_value=1', headers=token, verify=cert) - subnets = subnet_req.json()['data'] + subnets = requests.get(f'{subnet_uri}?filter_by=isPool&filter_value=1', headers=token, verify=cert) + subnets = subnets.json()['data'] for subnet in subnets: ipRange = {} ipRange['id'] = str(subnet['id']) @@ -79,7 +78,8 @@ def do_get_ip_ranges(self, auth_credentials, cert): ipRange['dnsServerAddresses'] = [server.strip() for server in str(subnet['nameservers']['namesrv1']).split(';')] gw_req = requests.get(f"{subnet_uri}/{subnet['id']}/addresses/?filter_by=is_gateway&filter_value=1", headers=token, verify=cert) if gw_req.status_code == 200: - ipRange['gatewayAddress'] = gw_req.json()['data'][0]['ip'] + gateway = gw_req.json()['data'][0]['ip'] + ipRange['gatewayAddress'] = gateway logging.debug(ipRange) ipRanges.append(ipRange)