Skip to content
Open
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 api/v1/ipaddress_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ type IpAddressSpec struct {
//+kubebuilder:validation:XValidation:rule="self == oldSelf",message="Field 'tenant' is immutable"
Tenant string `json:"tenant,omitempty"`

// The NetBox VRF to be assigned to this resource in NetBox. Use the `name` value instead of the `id` value
// Field is immutable, not required
// Example: "blue" or "red"
//+kubebuilder:validation:XValidation:rule="self == oldSelf",message="Field 'vrf' is immutable"
Vrf string `json:"vrf,omitempty"`

// The NetBox Custom Fields that should be added to the resource in NetBox.
// Note that currently only Text Type is supported (GitHub #129)
// More info on NetBox Custom Fields:
Expand Down
6 changes: 6 additions & 0 deletions api/v1/ipaddressclaim_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ type IpAddressClaimSpec struct {
//+kubebuilder:validation:XValidation:rule="self == oldSelf",message="Field 'tenant' is immutable"
Tenant string `json:"tenant,omitempty"`

// The NetBox VRF to be assigned to this resource in NetBox. Use the `name` value instead of the `id` value
// Field is immutable, not required
// Example: "blue" or "red"
//+kubebuilder:validation:XValidation:rule="self == oldSelf",message="Field 'vrf' is immutable"
Vrf string `json:"vrf,omitempty"`

// The NetBox Custom Fields that should be added to the resource in NetBox.
// Note that currently only Text Type is supported (GitHub #129)
// More info on NetBox Custom Fields:
Expand Down
6 changes: 6 additions & 0 deletions api/v1/iprange_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ type IpRangeSpec struct {
//+kubebuilder:validation:XValidation:rule="self == oldSelf",message="Field 'tenant' is immutable"
Tenant string `json:"tenant,omitempty"`

// The NetBox VRF to be assigned to this resource in NetBox. Use the `name` value instead of the `id` value
// Field is immutable, not required
// Example: "blue" or "red"
//+kubebuilder:validation:XValidation:rule="self == oldSelf",message="Field 'vrf' is immutable"
Vrf string `json:"vrf,omitempty"`

// The NetBox Custom Fields that should be added to the resource in NetBox.
// Note that currently only Text Type is supported (GitHub #129)
// More info on NetBox Custom Fields:
Expand Down
6 changes: 6 additions & 0 deletions api/v1/iprangeclaim_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ type IpRangeClaimSpec struct {
//+kubebuilder:validation:XValidation:rule="self == oldSelf",message="Field 'tenant' is immutable"
Tenant string `json:"tenant,omitempty"`

// The NetBox VRF to be assigned to this resource in NetBox. Use the `name` value instead of the `id` value
// Field is immutable, not required
// Example: "blue" or "red"
//+kubebuilder:validation:XValidation:rule="self == oldSelf",message="Field 'vrf' is immutable"
Vrf string `json:"vrf,omitempty"`

// The NetBox Custom Fields that should be added to the resource in NetBox.
// Note that currently only Text Type is supported (GitHub #129)
// More info on NetBox Custom Fields:
Expand Down
6 changes: 6 additions & 0 deletions api/v1/prefix_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ type PrefixSpec struct {
//+kubebuilder:validation:XValidation:rule="self == oldSelf",message="Field 'tenant' is immutable"
Tenant string `json:"tenant,omitempty"`

// The NetBox VRF to be assigned to this resource in NetBox. Use the `name` value instead of the `id` value
// Field is immutable, not required
// Example: "blue" or "red"
//+kubebuilder:validation:XValidation:rule="self == oldSelf",message="Field 'vrf' is immutable"
Vrf string `json:"vrf,omitempty"`

// The NetBox Custom Fields that should be added to the resource in NetBox.
// Note that currently only Text Type is supported (GitHub #129)
// More info on NetBox Custom Fields:
Expand Down
6 changes: 6 additions & 0 deletions api/v1/prefixclaim_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ type PrefixClaimSpec struct {
//+kubebuilder:validation:XValidation:rule="self == oldSelf",message="Field 'tenant' is immutable"
Tenant string `json:"tenant,omitempty"`

// The NetBox VRF to be assigned to this resource in NetBox. Use the `name` value instead of the `id` value
// Field is immutable, not required
// Example: "blue" or "red"
//+kubebuilder:validation:XValidation:rule="self == oldSelf",message="Field 'vrf' is immutable"
Vrf string `json:"vrf,omitempty"`

// Description that should be added to the resource in NetBox
// Field is mutable, not required
Description string `json:"description,omitempty"`
Expand Down
9 changes: 9 additions & 0 deletions config/crd/bases/netbox.dev_ipaddressclaims.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ spec:
x-kubernetes-validations:
- message: Field 'tenant' is immutable
rule: self == oldSelf
vrf:
description: |-
The NetBox VRF to be assigned to this resource in NetBox. Use the `name` value instead of the `id` value
Field is immutable, not required
Example: "blue" or "red"
type: string
x-kubernetes-validations:
- message: Field 'vrf' is immutable
rule: self == oldSelf
required:
- parentPrefix
type: object
Expand Down
9 changes: 9 additions & 0 deletions config/crd/bases/netbox.dev_ipaddresses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,15 @@ spec:
x-kubernetes-validations:
- message: Field 'tenant' is immutable
rule: self == oldSelf
vrf:
description: |-
The NetBox VRF to be assigned to this resource in NetBox. Use the `name` value instead of the `id` value
Field is immutable, not required
Example: "blue" or "red"
type: string
x-kubernetes-validations:
- message: Field 'vrf' is immutable
rule: self == oldSelf
required:
- ipAddress
type: object
Expand Down
9 changes: 9 additions & 0 deletions config/crd/bases/netbox.dev_iprangeclaims.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ spec:
x-kubernetes-validations:
- message: Field 'tenant' is immutable
rule: self == oldSelf
vrf:
description: |-
The NetBox VRF to be assigned to this resource in NetBox. Use the `name` value instead of the `id` value
Field is immutable, not required
Example: "blue" or "red"
type: string
x-kubernetes-validations:
- message: Field 'vrf' is immutable
rule: self == oldSelf
required:
- parentPrefix
- size
Expand Down
9 changes: 9 additions & 0 deletions config/crd/bases/netbox.dev_ipranges.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ spec:
x-kubernetes-validations:
- message: Field 'tenant' is immutable
rule: self == oldSelf
vrf:
description: |-
The NetBox VRF to be assigned to this resource in NetBox. Use the `name` value instead of the `id` value
Field is immutable, not required
Example: "blue" or "red"
type: string
x-kubernetes-validations:
- message: Field 'vrf' is immutable
rule: self == oldSelf
required:
- endAddress
- startAddress
Expand Down
9 changes: 9 additions & 0 deletions config/crd/bases/netbox.dev_prefixclaims.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,15 @@ spec:
x-kubernetes-validations:
- message: Field 'tenant' is immutable
rule: self == oldSelf
vrf:
description: |-
The NetBox VRF to be assigned to this resource in NetBox. Use the `name` value instead of the `id` value
Field is immutable, not required
Example: "blue" or "red"
type: string
x-kubernetes-validations:
- message: Field 'vrf' is immutable
rule: self == oldSelf
required:
- prefixLength
type: object
Expand Down
9 changes: 9 additions & 0 deletions config/crd/bases/netbox.dev_prefixes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ spec:
x-kubernetes-validations:
- message: Field 'tenant' is immutable
rule: self == oldSelf
vrf:
description: |-
The NetBox VRF to be assigned to this resource in NetBox. Use the `name` value instead of the `id` value
Field is immutable, not required
Example: "blue" or "red"
type: string
x-kubernetes-validations:
- message: Field 'vrf' is immutable
rule: self == oldSelf
required:
- prefix
type: object
Expand Down
6 changes: 6 additions & 0 deletions config/samples/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@ resources:
- netbox_v1_prefixclaim_parentprefixselector.yaml
- netbox_v1_iprangeclaim.yaml
- netbox_v1_iprange.yaml
- netbox_v1_ipaddress_vrf.yaml
- netbox_v1_ipaddressclaim_vrf.yaml
- netbox_v1_prefix_vrf.yaml
- netbox_v1_prefixclaim_vrf.yaml
- netbox_v1_iprange_vrf.yaml
- netbox_v1_iprangeclaim_vrf.yaml
# +kubebuilder:scaffold:manifestskustomizesamples
15 changes: 15 additions & 0 deletions config/samples/netbox_v1_ipaddress_vrf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
apiVersion: netbox.dev/v1
kind: IpAddress
metadata:
labels:
app.kubernetes.io/name: netbox-operator
app.kubernetes.io/managed-by: kustomize
name: ipaddress-vrf-sample
spec:
tenant: "MY_TENANT"
vrf: "MY_VRF"
description: "some description"
comments: "your comments"
preserveInNetbox: true
ipAddress: "4.0.0.100/32"
15 changes: 15 additions & 0 deletions config/samples/netbox_v1_ipaddressclaim_vrf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
apiVersion: netbox.dev/v1
kind: IpAddressClaim
metadata:
labels:
app.kubernetes.io/name: netbox-operator
app.kubernetes.io/managed-by: kustomize
name: ipaddressclaim-vrf-sample
spec:
tenant: "MY_TENANT"
vrf: "MY_VRF"
description: "some description"
comments: "your comments"
preserveInNetbox: true
parentPrefix: "4.0.0.0/24"
16 changes: 16 additions & 0 deletions config/samples/netbox_v1_iprange_vrf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
apiVersion: netbox.dev/v1
kind: IpRange
metadata:
labels:
app.kubernetes.io/name: netbox-operator
app.kubernetes.io/managed-by: kustomize
name: iprange-vrf-sample
spec:
tenant: "MY_TENANT"
vrf: "MY_VRF"
description: "some description"
comments: "your comments"
preserveInNetbox: true
startAddress: "4.1.0.200/32"
endAddress: "4.1.0.202/32"
16 changes: 16 additions & 0 deletions config/samples/netbox_v1_iprangeclaim_vrf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
apiVersion: netbox.dev/v1
kind: IpRangeClaim
metadata:
labels:
app.kubernetes.io/name: netbox-operator
app.kubernetes.io/managed-by: kustomize
name: iprangeclaim-vrf-sample
spec:
tenant: "MY_TENANT"
vrf: "MY_VRF"
description: "some description"
comments: "your comments"
preserveInNetbox: true
parentPrefix: "4.1.0.0/24"
size: 3
16 changes: 16 additions & 0 deletions config/samples/netbox_v1_prefix_vrf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
apiVersion: netbox.dev/v1
kind: Prefix
metadata:
labels:
app.kubernetes.io/name: netbox-operator
app.kubernetes.io/managed-by: kustomize
name: prefix-vrf-sample
spec:
tenant: "MY_TENANT"
# vrf: "MY_VRF"
vrf: "xxx"
description: "some description"
comments: "your comments"
preserveInNetbox: true
prefix: "4.2.0.0/28"
16 changes: 16 additions & 0 deletions config/samples/netbox_v1_prefixclaim_vrf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
apiVersion: netbox.dev/v1
kind: PrefixClaim
metadata:
labels:
app.kubernetes.io/name: netbox-operator
app.kubernetes.io/managed-by: kustomize
name: prefixclaim-vrf-sample
spec:
tenant: "MY_TENANT"
vrf: "MY_VRF"
description: "some description"
comments: "your comments"
preserveInNetbox: true
parentPrefix: "4.2.0.0/24"
prefixLength: "/28"
20 changes: 20 additions & 0 deletions gen/mock_interfaces/netbox_mocks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/controller/ipaddress_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ func generateNetboxIpAddressModelFromIpAddressSpec(spec *netboxv1.IpAddressSpec,
Custom: netboxCustomFields,
Description: req.NamespacedName.String() + " // " + spec.Description,
Tenant: spec.Tenant,
Vrf: spec.Vrf,
},
}, nil
}
1 change: 1 addition & 0 deletions internal/controller/ipaddressclaim_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ func (r *IpAddressClaimReconciler) Reconcile(ctx context.Context, req ctrl.Reque
ParentPrefix: o.Spec.ParentPrefix,
Metadata: &models.NetboxMetadata{
Tenant: o.Spec.Tenant,
Vrf: o.Spec.Vrf,
},
})
if err != nil {
Expand Down
5 changes: 4 additions & 1 deletion internal/controller/ipaddressclaim_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func generateIpAddressSpec(claim *netboxv1.IpAddressClaim, ip string, logger log
return netboxv1.IpAddressSpec{
IpAddress: ip,
Tenant: claim.Spec.Tenant,
Vrf: claim.Spec.Vrf,
CustomFields: customFields,
Description: claim.Spec.Description,
Comments: claim.Spec.Comments,
Expand All @@ -68,8 +69,9 @@ func generateIpAddressRestorationHash(claim *netboxv1.IpAddressClaim) string {
Name: claim.Name,
ParentPrefix: claim.Spec.ParentPrefix,
Tenant: claim.Spec.Tenant,
Vrf: claim.Spec.Vrf,
}
return fmt.Sprintf("%x", sha1.Sum([]byte(rd.Namespace+rd.Name+rd.ParentPrefix+rd.Tenant)))
return fmt.Sprintf("%x", sha1.Sum([]byte(rd.Namespace+rd.Name+rd.ParentPrefix+rd.Tenant+rd.Vrf)))
}

type IpAddressClaimRestorationData struct {
Expand All @@ -78,4 +80,5 @@ type IpAddressClaimRestorationData struct {
Name string
ParentPrefix string
Tenant string
Vrf string
}
1 change: 1 addition & 0 deletions internal/controller/iprange_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ func (r *IpRangeReconciler) generateNetboxIpRangeModelFromIpRangeSpec(o *netboxv
Custom: netboxCustomFields,
Description: description,
Tenant: o.Spec.Tenant,
Vrf: o.Spec.Vrf,
},
}, nil
}
Expand Down
1 change: 1 addition & 0 deletions internal/controller/iprangeclaim_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ func (r *IpRangeClaimReconciler) restoreOrAssignIpRangeAndSetCondition(ctx conte
Size: o.Spec.Size,
Metadata: &models.NetboxMetadata{
Tenant: o.Spec.Tenant,
Vrf: o.Spec.Vrf,
},
},
)
Expand Down
5 changes: 4 additions & 1 deletion internal/controller/iprangeclaim_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func generateIpRangeSpec(claim *netboxv1.IpRangeClaim, startIp string, endIp str
StartAddress: startIp,
EndAddress: endIp,
Tenant: claim.Spec.Tenant,
Vrf: claim.Spec.Vrf,
CustomFields: customFields,
Description: claim.Spec.Description,
Comments: claim.Spec.Comments,
Expand All @@ -72,9 +73,10 @@ func generateIpRangeRestorationHash(claim *netboxv1.IpRangeClaim) string {
Name: claim.Name,
ParentPrefix: claim.Spec.ParentPrefix,
Tenant: claim.Spec.Tenant,
Vrf: claim.Spec.Vrf,
Size: fmt.Sprintf("%d", claim.Spec.Size),
}
return fmt.Sprintf("%x", sha1.Sum([]byte(rd.Namespace+rd.Name+rd.ParentPrefix+rd.Tenant+rd.Size)))
return fmt.Sprintf("%x", sha1.Sum([]byte(rd.Namespace+rd.Name+rd.ParentPrefix+rd.Tenant+rd.Vrf+rd.Size)))
}

type IpRangeClaimRestorationData struct {
Expand All @@ -83,5 +85,6 @@ type IpRangeClaimRestorationData struct {
Name string
ParentPrefix string
Tenant string
Vrf string
Size string
}
Loading