Netbox Sync Device Interfaces Taskยค
task api name:
sync_device_interfaces
The Netbox Sync Device Interfaces Task is a feature of the NorFab Netbox Service that allows you to synchronize and update the interface data of your network devices in Netbox. This task ensures that the interface configurations in Netbox are accurate and up-to-date, reflecting the current state of your network infrastructure.
Keeping interface data accurate and up-to-date is crucial for effective network management. The Netbox Update Device Interfaces Task automates the process of updating interface information, such as interface names, statuses, mac addresses, and other relevant details.
Branching Supportยค
Update device interfaces task is branch aware and can push updates to the branch. Netbox Branching Plugin need to be installed on Netbox instance.
How it works - Netbox worker on a call to update interfaces task fetches live data from network devices using nominated datasource, by default it is Nornir service parse task using NAPALM get_interfaces getter. Once data retrieved from network, Netbox worker updates records in Netbox database for device interfaces.

-
Client submits and on-demand request to NorFab Netbox worker to update device interfaces
-
Netbox worker sends job request to nominated datasource service to fetch live data from network devices
-
Datasource service fetches data from the network
-
Datasource returns devices interfaces data back to Netbox Service worker
-
Netbox worker processes device interfaces data and updates records in Netbox for requested devices
Limitationsยค
Datasource nornir uses NAPALM get_interfaces getter and as such only supports these device platforms:
- Arista EOS
- Cisco IOS
- Cisco IOSXR
- Cisco NXOS
- Juniper JUNOS
Update Device Interfaces Sample Usageยค
NORFAB Netbox Update Device Interfaces Command Shell Referenceยค
NorFab shell supports these command options for Netbox sync_device_interfaces task:
nf# man tree netbox.update.device.interfaces
root
โโโ netbox: Netbox service
โโโ sync: Update Netbox data
โโโ device: Update device data
โโโ interfaces: Update device interfaces
โโโ timeout: Job timeout
โโโ workers: Filter worker to target, default 'any'
โโโ verbose-result: Control output details, default 'False'
โโโ progress: Display progress events, default 'True'
โโโ instance: Netbox instance name to target
โโโ dry-run: Return information that would be pushed to Netbox but do not push it
โโโ devices: List of Netbox devices to update
โโโ datasource: Service to use to retrieve device data, default 'nornir'
โ โโโ nornir: Use Nornir service to retrieve data from devices
โ โโโ FO: Filter hosts using Filter Object
โ โโโ FB: Filter hosts by name using Glob Patterns
โ โโโ FH: Filter hosts by hostname
โ โโโ FC: Filter hosts containment of pattern in name
โ โโโ FR: Filter hosts by name using Regular Expressions
โ โโโ FG: Filter hosts by group
โ โโโ FP: Filter hosts by hostname using IP Prefix
โ โโโ FL: Filter hosts by names list
โ โโโ FM: Filter hosts by platform
โ โโโ FN: Negate the match
โ โโโ add-details: Add task details to results, default 'False'
โ โโโ num-workers: RetryRunner number of threads for tasks execution
โ โโโ num-connectors: RetryRunner number of threads for device connections
โ โโโ connect-retry: RetryRunner number of connection attempts
โ โโโ task-retry: RetryRunner number of attempts to run task
โ โโโ reconnect-on-fail: RetryRunner perform reconnect to host on task failure
โ โโโ connect-check: RetryRunner test TCP connection before opening actual connection
โ โโโ connect-timeout: RetryRunner timeout in seconds to wait for test TCP connection to establish
โ โโโ creds-retry: RetryRunner list of connection credentials and parameters to retry
โ โโโ tf: File group name to save task results to on worker file system
โ โโโ tf-skip-failed: Save results to file for failed tasks
โ โโโ diff: File group name to run the diff for
โ โโโ diff-last: File version number to diff, default is 1 (last)
โ โโโ progress: Display progress events, default 'True'
โโโ batch-size: Number of devices to process at a time, default '10'
โโโ branch: Branching plugin branch name to use
nf#
Python API Referenceยค
Update or create device interfaces in Netbox using devices interfaces
data sourced via Nornir service parse task using NAPALM getter.
Interface parameters updated:
- interface name
- interface description
- mtu
- mac address
- admin status
- speed
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job
|
Job
|
NorFab Job object containing relevant metadata. |
required |
instance
|
str
|
The Netbox instance name to use. |
None
|
dry_run
|
bool
|
If True, no changes will be made to Netbox. |
False
|
datasource
|
str
|
The data source to use. Supported datasources:
|
'nornir'
|
timeout
|
int
|
The timeout for the job. |
60
|
devices
|
list
|
List of devices to update. |
None
|
create
|
bool
|
If True, new interfaces will be created if they do not exist. |
True
|
batch_size
|
int
|
The number of devices to process in each batch. |
10
|
branch
|
str
|
Branch name to use, need to have branching plugin installed, automatically creates branch if it does not exist in Netbox. |
None
|
**kwargs
|
Any
|
Additional keyword arguments to pass to the datasource job. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Result
|
A dictionary containing the results of the update operation. |
Raises:
| Type | Description |
|---|---|
Exception
|
If a device does not exist in Netbox. |
UnsupportedServiceError
|
If the specified datasource is not supported. |
Source code in norfab\workers\netbox_worker.py
2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 | |