Skip to content

Commit 7f573f9

Browse files
chore(ansible): custom fields for openstack_subnet_pools
1 parent 1151cd2 commit 7f573f9

5 files changed

Lines changed: 90 additions & 18 deletions

File tree

ansible/roles/custom_fields/tasks/main.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,69 @@
8484
content_types:
8585
- dcim.interface
8686
filter_logic: exact
87+
88+
- name: Create Custom Field Subnet Pool Name
89+
networktocode.nautobot.custom_field:
90+
state: present
91+
url: "{{ nautobot_url }}"
92+
token: "{{ nautobot_token }}"
93+
description: Name of the OpenStack subnet pool to create from this prefix
94+
label: Subnet Pool Name
95+
key: subnet_pool_name
96+
type: text
97+
required: false
98+
weight: 100
99+
content_types:
100+
- ipam.prefix
101+
filter_logic: exact
102+
103+
- name: Create Custom Field Subnet Pool Default Prefixlen
104+
networktocode.nautobot.custom_field:
105+
state: present
106+
url: "{{ nautobot_url }}"
107+
token: "{{ nautobot_token }}"
108+
description: Default prefix length for subnets created from this pool
109+
label: Default Prefixlen
110+
key: subnet_pool_default_prefixlen
111+
type: integer
112+
required: false
113+
weight: 100
114+
content_types:
115+
- ipam.prefix
116+
validation_minimum: 1
117+
validation_maximum: 32
118+
filter_logic: exact
119+
120+
- name: Create Custom Field Subnet Pool Min Prefixlen
121+
networktocode.nautobot.custom_field:
122+
state: present
123+
url: "{{ nautobot_url }}"
124+
token: "{{ nautobot_token }}"
125+
description: Minimum prefix length for subnets created from this pool
126+
label: Min Prefixlen
127+
key: subnet_pool_min_prefixlen
128+
type: integer
129+
required: false
130+
weight: 100
131+
content_types:
132+
- ipam.prefix
133+
validation_minimum: 1
134+
validation_maximum: 32
135+
filter_logic: exact
136+
137+
- name: Create Custom Field Subnet Pool Max Prefixlen
138+
networktocode.nautobot.custom_field:
139+
state: present
140+
url: "{{ nautobot_url }}"
141+
token: "{{ nautobot_token }}"
142+
description: Maximum prefix length for subnets created from this pool
143+
label: Max Prefixlen
144+
key: subnet_pool_max_prefixlen
145+
type: integer
146+
required: false
147+
weight: 100
148+
content_types:
149+
- ipam.prefix
150+
validation_minimum: 1
151+
validation_maximum: 32
152+
filter_logic: exact

components/nautobot/job-nautobot-post-deploy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ spec:
2323
type: RuntimeDefault
2424
containers:
2525
- name: ansible
26-
image: ghcr.io/rackerlabs/understack/ansible:latest
26+
image: ghcr.io/rackerlabs/understack/ansible:pr-2081
2727
imagePullPolicy: Always
2828
command: ["ansible-runner", "run", "/runner", "--playbook", "nautobot-post-deploy.yaml"]
2929
resources:

go/nautobotop/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ require (
1414
k8s.io/api v0.33.0
1515
k8s.io/apimachinery v0.33.0
1616
k8s.io/client-go v0.33.0
17+
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738
1718
sigs.k8s.io/controller-runtime v0.21.0
1819
)
1920

@@ -118,7 +119,6 @@ require (
118119
k8s.io/component-base v0.33.0 // indirect
119120
k8s.io/klog/v2 v2.130.1 // indirect
120121
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff // indirect
121-
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
122122
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2 // indirect
123123
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
124124
sigs.k8s.io/randfill v1.0.0 // indirect

go/nautobotop/internal/nautobot/models/prefix.go

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,21 @@ type Prefixes struct {
55
}
66

77
type Prefix struct {
8-
ID string `json:"id" yaml:"id"`
9-
Prefix string `json:"prefix" yaml:"prefix"`
10-
Namespace string `json:"namespace" yaml:"namespace"`
11-
Type string `json:"type" yaml:"type"`
12-
Status string `json:"status" yaml:"status"`
13-
Role string `json:"role" yaml:"role"`
14-
Rir string `json:"rir" yaml:"rir"`
15-
DateAllocated string `json:"date_allocated" yaml:"date_allocated"`
16-
Description string `json:"description" yaml:"description"`
17-
Vrfs []string `json:"vrfs" yaml:"vrfs"`
18-
Locations []string `json:"locations" yaml:"locations"`
19-
VlanGroup string `json:"vlan_group" yaml:"vlan_group"`
20-
Vlan string `json:"vlan" yaml:"vlan"`
21-
TenantGroup string `json:"tenant_group" yaml:"tenant_group"`
22-
Tenant string `json:"tenant" yaml:"tenant"`
23-
Tags []string `json:"tags" yaml:"tags"`
8+
ID string `json:"id" yaml:"id"`
9+
Prefix string `json:"prefix" yaml:"prefix"`
10+
Namespace string `json:"namespace" yaml:"namespace"`
11+
Type string `json:"type" yaml:"type"`
12+
Status string `json:"status" yaml:"status"`
13+
Role string `json:"role" yaml:"role"`
14+
Rir string `json:"rir" yaml:"rir"`
15+
DateAllocated string `json:"date_allocated" yaml:"date_allocated"`
16+
Description string `json:"description" yaml:"description"`
17+
Vrfs []string `json:"vrfs" yaml:"vrfs"`
18+
Locations []string `json:"locations" yaml:"locations"`
19+
VlanGroup string `json:"vlan_group" yaml:"vlan_group"`
20+
Vlan string `json:"vlan" yaml:"vlan"`
21+
TenantGroup string `json:"tenant_group" yaml:"tenant_group"`
22+
Tenant string `json:"tenant" yaml:"tenant"`
23+
Tags []string `json:"tags" yaml:"tags"`
24+
CustomFields map[string]interface{} `json:"custom_fields" yaml:"custom_fields"`
2425
}

go/nautobotop/internal/nautobot/sync/prefix.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ func (s *PrefixSync) syncSinglePrefix(ctx context.Context, prefix models.Prefix)
170170
if len(prefix.Locations) > 1 {
171171
customFields["locations"] = s.buildLocationIDs(ctx, prefix.Locations[1:])
172172
}
173+
if prefix.CustomFields != nil {
174+
for k, v := range prefix.CustomFields {
175+
customFields[k] = v
176+
}
177+
}
173178
if len(customFields) > 0 {
174179
prefixRequest.CustomFields = customFields
175180
}

0 commit comments

Comments
 (0)