Commit 6e746119 authored by root's avatar root
Browse files

updated for netbox 2.9+, __getVal more robust in returning '' if we can't get...

updated for netbox 2.9+, __getVal more robust in returning '' if we can't get a value and changes to get ip from ip adress objects
parent b81912db
......@@ -208,12 +208,14 @@ class Netbox:
def __getVal(self, obj, key1, key2=None):
val = ''
if key1 in obj:
if key2 and key2 in obj[key1]:
val = obj[key1][key2]
else:
val = obj[key1]
return val
try:
if key1 in obj:
if key2 and key2 in obj[key1]:
val = obj[key1][key2]
else:
val = obj[key1]
finally:
return val
def addRow(self, title, obj, key1, key2=None):
"""Generate html row containing title and value from key(s) in object
......@@ -444,9 +446,9 @@ if netbox.host:
email_html += netbox.addLinkRow('Site', netbox.host, 'site', 'name') # Sites use the slug
email_html += netbox.addLinkRow('Rack', netbox.host, 'rack', 'name')
email_html += netbox.addRow('Position', netbox.host, 'position')
email_html += netbox.addRow('Primary IP', netbox.host, 'primary_ip')
email_html += netbox.addRow('Primary IPv4', netbox.host, 'primary_ip4')
email_html += netbox.addRow('Primary IPv6', netbox.host, 'primary_ip6')
email_html += netbox.addRow('Primary IP', netbox.host, 'primary_ip', 'address')
email_html += netbox.addRow('Primary IPv4', netbox.host, 'primary_ip4', 'address')
email_html += netbox.addRow('Primary IPv6', netbox.host, 'primary_ip6', 'address')
email_html += netbox.addLinkRow('Device Type', netbox.host, 'device_type', 'model')
email_html += netbox.addRow('Status', netbox.host, 'status', 'label')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment