hubblo-org / cabestan

Gather and normalize ICT inventory data from multiple sources, to enable automation of ICT carbon and environmental impacts (LCA-inspired) assessments.
Apache License 2.0
13 stars 2 forks source link

Netbox scanner #8

Open da-ekchajzer opened 2 years ago

da-ekchajzer commented 2 years ago

Problem

I want to use cabestan to gather my assets listed in my netbox instance.

Solution

We could use the API provided by netbox to retrieve the assets

Retrieving multiple assets by type

Documentation : https://docs.netbox.dev/en/stable/rest-api/overview/#retrieving-multiple-objects

A simple GET request at the resource endpoint will return the list of all the ressources.

curl -s -X GET http://netbox/api/ipam/ip-addresses/ | jq '.'

{
  "count": 42031,
  "next": "http://netbox/api/ipam/ip-addresses/?limit=50&offset=50",
  "previous": null,
  "results": [
    {
      "id": 5618,
      "address": "192.0.2.1/24",
      ...
    },
    {
      "id": 5619,
      "address": "192.0.2.2/24",
      ...
    },
    {
      "id": 5620,
      "address": "192.0.2.3/24",
      ...
    },
    ...
  ]
}

Type of assets

IP

Documentation : https://docs.netbox.dev/en/stable/core-functionality/ipam/

IP assets could be used in the network scanners process.

Devices

Documentation : https://docs.netbox.dev/en/stable/core-functionality/devices/

Devices represent all the physical assets in netbox. We could gather some information depending on the level of completeness of the net box instance :

Virtual machines

Documentation : https://docs.netbox.dev/en/stable/core-functionality/virtualization/

Clusters and VMs can be specified in netbox. We could retrieve information about the configuration and the status of each VM.

Additional context