Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions internal/config/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,19 @@ var (
Cfg Config
)

type FilterKV struct {
Filter string
Value string
}

type Config struct {
Authentication AuthConfig
NetBox struct {
URL string
APIKey string
DatacenterFilterKey Filter
LimitPerPage int
DeviceFilters []FilterKV
}
Log struct {
Level string
Expand Down
6 changes: 3 additions & 3 deletions internal/ingestor/dcim/network_inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import (
)

// GetNetworkInventory returns network device inventory from NetBox DCIM.
// TODO: at the moment, to list the device we use the filter "role__n=server".
// > This filter should be configurable by the user.
func GetNetworkInventory() ([]*dcim.NetworkDevice, error) {
response := netbox.NetboxResponse[dcim.NetworkDevice]{}

params := url.Values{}
params.Set(string(config.Cfg.NetBox.DatacenterFilterKey), config.Cfg.Datacenter)
params.Set("role__n", "server")
for _, filter := range config.Cfg.NetBox.DeviceFilters {
params.Add(filter.Filter, filter.Value)
}

if err := netbox.Get("/api/dcim/devices/", &response, params); err != nil {
return nil, fmt.Errorf("network inventory fetching failure: %w", err)
Expand Down
Loading