Skip to content

Commit

Permalink
Merge pull request #6 from jasonyates/main
Browse files Browse the repository at this point in the history
  • Loading branch information
goebelmeier committed Oct 29, 2021
2 parents 4911c08 + bd62f75 commit 42b537c
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions netbox_cisco_support/management/commands/sync_eox_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,22 @@ def handle(self, *args, **kwargs):
# with open('/source/netbox_cisco_support/api-answer/%s' % filename, 'w') as outfile:
# outfile.write(api_call_response.text)

# Deserialize JSON API Response into Python object "data"
data = json.loads(api_call_response.text)
# Validate response from Cisco
if api_call_response.status_code == 200:

# Call our Device Type Update method for that particular PID
self.update_device_type_eox_data(pid, data)
# Deserialize JSON API Response into Python object "data"
data = json.loads(api_call_response.text)

# Call our Device Type Update method for that particular PID
self.update_device_type_eox_data(pid, data)

i += 1

else:

# Show an error
self.stdout.write(self.style.ERROR('API Error: ' + api_call_response.text))

i += 1

# Step 2: Get all Serial Numbers for all Devices of that particular manufacturer
serial_numbers = self.get_serial_numbers(MANUFACTURER)
Expand All @@ -332,13 +341,21 @@ def handle(self, *args, **kwargs):
api_call_response = requests.get(url, headers=api_call_headers)
self.stdout.write(self.style.SUCCESS('Call ' + url))

# Deserialize JSON API Response into Python object "data"
data = json.loads(api_call_response.text)
# Validate response from Cisco
if api_call_response.status_code == 200:

# Deserialize JSON API Response into Python object "data"
data = json.loads(api_call_response.text)

# Iterate through all serial numbers included in the API response
for device in data['serial_numbers']:
# Iterate through all serial numbers included in the API response
for device in data['serial_numbers']:

# Call our Device Update method for that particular Device
self.update_device_eox_data(device)
# Call our Device Update method for that particular Device
self.update_device_eox_data(device)

i += 1

else:

i += 1
# Show an error
self.stdout.write(self.style.ERROR('API Error: ' + api_call_response.text))

0 comments on commit 42b537c

Please sign in to comment.