1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Add exception wrapper

This commit is contained in:
Jeremy Stretch
2016-03-22 15:14:03 -04:00
parent 8d99502916
commit 69726ac443

View File

@ -65,12 +65,15 @@ class FreeRADIUSClientsRenderer(renderers.BaseRenderer):
def render(self, data, media_type=None, renderer_context=None): def render(self, data, media_type=None, renderer_context=None):
clients = [] clients = []
for secret in data: try:
if secret['device']['primary_ip'] and secret['plaintext']: for secret in data:
client = self.CLIENT_TEMPLATE.format( if secret['device']['primary_ip'] and secret['plaintext']:
name=secret['device']['name'], client = self.CLIENT_TEMPLATE.format(
ip=secret['device']['primary_ip']['address'].split('/')[0], name=secret['device']['name'],
secret=secret['plaintext'] ip=secret['device']['primary_ip']['address'].split('/')[0],
) secret=secret['plaintext']
clients.append(client) )
clients.append(client)
except:
pass
return '\n'.join(clients) return '\n'.join(clients)