Add Role to Interface
The initial schema is capturing some technical information about devices, interfaces and IP addresses, but to distinguish between a Loopback interface and a physical interface we need to rely on the name of the interface.
Add a Role to the interface model
In the file workshop_b2/lab3/schemas/dcim.yml
uncomment the section highlighted below that is be currently commented
- name: InterfaceL3
namespace: Dcim
description: Network Layer 3 Interface
label: Interface L3
icon: mdi:ethernet
menu_placement: DcimInterface
display_labels:
- name__value
order_by:
- name__value
inherit_from:
- DcimInterface
- DcimEndpoint
attributes:
- name: status
kind: Dropdown
optional: true
choices:
- name: active
description: Fully operational and currently in service.
color: "#7fbf7f"
- name: maintenance
description: Undergoing routine maintenance or repairs.
color: "#ffd27f"
- name: role
kind: Dropdown
optional: true
choices:
- name: loopback
- name: uplink
- name: peer
relationships:
- name: ip_addresses
peer: IpamIPAddress
optional: true
cardinality: many
Load the updated schema
infrahubctl schema load workshop_b2/lab3/schemas --branch schema01
After reloading the frontend (reload your browser tab), in the Interface L3 view, you should now see a column called Role
.
Load some additional data
In the file workshop_b2/lab3/data/interface_l3.yml
, first uncomment the lines that are defining the role of each interface and reload the data in to Infrahub with the following command:
infrahubctl object load workshop_b2/lab3/data/interface_l3.yml --branch schema01
This command is idempotent because the schema defines a Human Friendly ID for each interface based on the name of the related device and the name of the interface itself.