Skip to content

python#

Nornir Transform Function

Nornir includes a function that allows for the transformation of inventory data, a feature integrated within the Nornir platform itself. The documentation for Nornir 3.0 is somewhat sparse regarding the usage of Transform functions, so I often refer to the more comprehensive 2.5 documentation. According to the Nornir documentation:

A transform function is a plugin that manipulates the inventory independently from the inventory plugin used. Useful to extend data using the environment, a secret store or similar.

Nautobot: Get IP Addresses From Nautobot

One of Nautobot's primary functions is to serve as an IPAM solution. Within that realm, the application needs to provide a method to get at IP address data for a device, quickly and easily. In this post I will review three prominent methods to get an IP address from Nautobot. It will demonstrate getting the address via:

  • Nautobot REST API
  • curl
  • Python Requests
  • GoLang HTTP
  • pynautobot
  • Ansible Lookup
  • Nautobot GraphQL API
  • curl
  • Python Requests
  • GoLang HTTP
  • pynautobot
  • Ansible Lookup

GraphQL - Aliasing

One of the features that I find myself using periodically that I think is underrated as far as using GraphQL is its ability to alias return keys in the response. This can be extremely helpful for developers writing applications, as it allows them to have the API response with the keys they are looking for. I have found this feature particularly useful when working on applications like Meraki and Nautobot together. In Nautobot a place is typically defined as the key site. In the Meraki world this is commonly set up as a network. Without GraphQL's alias feature, the developer would need to translate this data over.

Let's explore two scenarios where a developer might choose to alias the response from GraphQL:

  • Quick translation between systems
  • Response from multiple queries

I will demonstrate the capabilities of these scenarios using the Nautobot demo instance at https://demo.nautobot.com. For each of these, make sure that you have logged in already before going to the GraphiQL page.