Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support NetBox Custom Field Types other than text #129

Open
jstudler opened this issue Nov 14, 2024 · 0 comments
Open

Support NetBox Custom Field Types other than text #129

jstudler opened this issue Nov 14, 2024 · 0 comments
Labels

Comments

@jstudler
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant