Polywhat? Polymorphism.
It's a concept that's very important to network automation so let's break it down.
→ Poly = many
→ Morph = form or shape
A polymorphic data model supports many data forms.
Why is this important? We'll use devices as an example.
There are many kinds of devices: routers, switches, firewalls, patch panels, etc.
All of these devices share a very small number of attributes, like name and location. But their attributes soon diverge according to their function.
A router has a management IP but a patch panel doesn’t. A patch panel has a cable type but a switch doesn’t.
The way many tools accommodate these differences is to have a generic “device” object that leaves most fields optional. That way you can use it to log anything.
But when almost all fields are optional you can’t validate data against requirements. It’s possible to add a router without a management IP.
You can imagine the chaos (or perhaps you’ve experienced it) when all of your devices may or may not be missing key details. You don’t know what you can trust.
With polymorphism, you can have a single “device” object but that generic object can have specialized objects that inherit from it.
So you can specify that a router must have all the shared attributes of a generic device (like name and location) AND it must also have attributes specific to a router (like a management IP).
Now you know. Polymorphism makes your data model more accurate, which makes your automation more reliable. And yes, we use it in Infrahub. 😎