NetBox Create VLAN Group Task¤
task API name:
create_vlan_group
The create_vlan_group task creates or updates one VLAN group scoped to a NetBox site. The design engine uses it before allocating VLANs for a site.
Inputs¤
| Parameter | Required | Default | Description |
|---|---|---|---|
name |
Yes | — | VLAN group name |
site |
Yes | — | Existing site used as the group scope |
vid_ranges |
Yes | — | Inclusive VLAN ID ranges, such as [[10, 99]] |
instance |
No | Worker default | NetBox instance to target |
dry_run |
No | False |
Return the proposed action without writing |
branch |
No | None |
NetBox Branching plugin branch name |
Example¤
result = client.run_job(
"netbox",
"create_vlan_group",
workers="any",
kwargs={
"name": "SITE-001 VLANS",
"site": "SITE-001",
"vid_ranges": [[10, 99]],
},
)
In a design:
{% set vlan_group = netbox.create_vlan_group(name=context.site ~ " VLANS", site=context.site, vid_ranges=[[10, 99]]) %}
The site must exist before the task runs.
Python API Reference¤
Create or update a VLAN group scoped to one NetBox site.
Groups are matched by name, not by site. An existing group is patched with the supplied site and VID ranges. A dry run reports the planned action without writing to NetBox.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job
|
Job
|
Current NorFab job for events and branch provisioning. |
required |
name
|
str
|
VLAN group name used to find an existing group. |
required |
site
|
str
|
Name of the site that scopes the group; it must exist. |
required |
vid_ranges
|
list
|
Allowed VLAN ID ranges in the NetBox API format. |
required |
instance
|
Union[None, str]
|
NetBox instance name, or the worker default when omitted. |
None
|
dry_run
|
bool
|
Report the planned create or update without writing. |
False
|
branch
|
Union[None, str]
|
Optional NetBox Branching plugin branch name. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Result |
Result
|
Group name, site, and ranges with a created or updated status. |
Raises:
| Type | Description |
|---|---|
ValueError
|
The named site does not exist. |
Source code in norfab\workers\netbox_worker\vlan_tasks.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | |