Skip to content

Support creating NetBox Custom Field Types other than text #129

@jstudler

Description

@jstudler

What would you like to be added?

Creating the following CR does currently not work since the NetBox Operator only supports creating IPAM Resources with Custom Fields of type Text in .spec.customFields.

apiVersion: netbox.dev/v1
kind: PrefixClaim
metadata:
  name: prefixclaim-sample
spec:
  parentPrefix: "2.0.0.0/16"
  prefixLength: "/28"
  customFields:
    cfDataTypeBool: "false"
    cfDataTypeInteger: "2"
    environment: "Production"

Events of both PrefixClaim and Prefix:

  Type     Reason                       Age    From                     Message
  ----     ------                       ----   ----                     -------
  Normal   ParentPrefixSelected         4m24s  prefix-claim-controller  The parent prefix was selected successfully. parentPrefix is provided in CR: 2.0.0.0/16
  Normal   PrefixCRCreated              4m23s  prefix-claim-controller  New prefix fetched from NetBox and prefix CR was created
  Warning  PrefixClaimResourceNotReady  4m23s  prefix-claim-controller  PrefixClaim Resource is not ready
  Warning  FailedToReservePrefixInNetbox  21s   prefix-controller  Failed to reserve prefix in NetBox. 2.0.0.0/28

Operator Log showing that the NetBox API rejects invalid types:

2024-11-14T11:07:26+01:00       ERROR   Reconciler error        {"controller": "prefix", "controllerGroup": "netbox.dev", "controllerKind": "Prefix", "Prefix": {"name":"prefixclaim-sample","namespace":"default"}, "namespace": "default", "name": "prefixclaim-sample", "reconcileID": "077e5ee9-5e16-406e-8440-39aea154cab0", "error": "failed at update prefix status: %!w(<nil>), after reservation of prefix in netbox failed: failed to create Prefix: [POST /ipam/prefixes/][400] ipam_prefixes_create default  map[__all__:[Invalid value for custom field 'cfDataTypeBool': Value must be true or false.]]"}
2024-11-14T11:10:30+01:00       ERROR   Reconciler error        {"controller": "prefix", "controllerGroup": "netbox.dev", "controllerKind": "Prefix", "Prefix": {"name":"prefixclaim-sample","namespace":"default"}, "namespace": "default", "name": "prefixclaim-sample", "reconcileID": "94ee4f8d-4738-49ef-8d44-72515c371cdd", "error": "failed at update prefix status: %!w(<nil>), after reservation of prefix in netbox failed: failed to create Prefix: [POST /ipam/prefixes/][400] ipam_prefixes_create default  map[__all__:[Invalid value for custom field 'cfDataTypeInteger': Value must be an integer.]]"}

It would be nice to support Custom Field types other than Text.

Why is this needed?

For certain use cases, the user wants to create NetBox resources with the NetBox Operator that contains Custom Fields of type Boolean, Integer and other.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions