Skip to content

CE-2436: Integrate backend with netbox

Hosts are accessible from two different REST endpoints from NetBox since we are dealing with two independent entities (Devices and Virtual Machines). To display them as one list with pagination applied, it is necessary to cache the entire list of hosts. However, associating FQDN, VLAN name, and VLAN group name with each host would take a significant amount of time. Therefore, we only load these details for the paginated set. NetBox host data model: netbox_host_model

The default caching time for hosts is set to 1 minute, but it is configurable via the configuration.

The unambiguous identification of hosts is another important aspect to mention because their IDs only apply to their types. So, in our system we have to generate a unique identifier for them, which carries both the host's ID and its type (which is a boolean indicating whether the host is a Virtual Machine or not). Basically: base64(hostId + "_" + isVm) Eg.:

"hostInfo": {
	"id": 130,
	"fqdn": "ccce-test-ioc-01.cslab.esss.lu.se",
	"name": "ccce-test-ioc-01",
	"scope": null,
	"description": "",
	"network": null,
	"deviceType": "VirtualMachine",
	"hostId": "MTMwX3RydWU=",
	"vm": true
}

The content of the development includes:

  1. Mapping the NetBox host data model.
  2. Queries towards NetBox.
  3. Code refactor: Retrieving hosts from NetBox instead of CSEntry.
  4. API changes: Mostly, the host ID has changed, and a few host fields disappeared that do not exist in NetBox.

How to test it:

  1. Modify Playbook
  2. Undo the V23 migration script (or just delete the entry)
  3. Deploy to TEST
  4. Migrate hosts via /api/v1/migrate (Auth required)

Closes CE-2436

Edited by Domonkos Gulyas

Merge request reports