Skip to content

Instantly share code, notes, and snippets.

@metabsd
Created October 7, 2020 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metabsd/7ff85d47158baf725cfaed25374c9415 to your computer and use it in GitHub Desktop.
Save metabsd/7ff85d47158baf725cfaed25374c9415 to your computer and use it in GitHub Desktop.
def get_ip(tor):
try:
return str(ip_interface(tor["primary_ip"]["address"]).ip)
except Exception:
return "NO_IP"
tors_list = [
{
"name": tor["name"],
"device_role": tor["device_role"]["name"],
"site_id": tor["config_context"]["alias"]["site_id"],
"ip": get_ip(tor),
}
for tor in self.get_devices_filter_by(
role="abc", tag="tag", cf_owner=5, status="active"
)
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment