Netbox Sync All Task¤
task api name:
sync_all
The sync_all task synchronizes all device data from live devices into NetBox in a fixed
sequence:
- interfaces — calls
sync_device_interfaces - mac_addresses — calls
sync_mac_addresses - ip_addresses — calls
sync_device_ip - bgp_peerings — calls
sync_bgp_peerings
Each sub-task can be individually enabled or disabled. Pass dry_run=True to preview the
changes that would be made without writing anything to NetBox.
Result Format¤
{
# per-device results — one entry per resolved device
"result": {
"ceos-spine-1": {
"interfaces": {
"create": { ... },
"update": { ... },
"delete": { ... },
"in_sync": [ ... ],
},
"mac_addresses": {
"created": [ ... ],
"updated": [ ... ],
"in_sync": [ ... ],
},
"ip_addresses": {
"created": [ ... ],
"updated": [ ... ],
"in_sync": [ ... ],
},
"bgp_peerings": {
"create": { ... },
"update": { ... },
"delete": { ... },
"in_sync": [ ... ],
},
},
...
},
"diff": {},
}
When dry_run=True the same structure is returned but no changes are written to NetBox.
Sample Usage¤
NORFAB Netbox Sync All Command Shell Reference¤
NorFab shell supports these command options for Netbox sync_all task:
nf# man tree netbox.sync.all
root
└── netbox: Netbox service
└── sync: Sync Netbox data
└── all: Sync all device data: interfaces, MAC addresses, IP addresses and BGP peerings
├── 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
├── branch: Branching plugin branch name to use
├── devices: List of NetBox devices to sync all data for
├── dry-run: Return diff without writing to NetBox, default 'False'
├── process-deletions: Process deletions for interfaces and BGP peerings, default 'False'
├── 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
├── FX: Filter hosts excluding them by name
└── FN: Negate the match
nf#
Python API Reference¤
Synchronize all device data from live devices into NetBox in sequence: interfaces → MAC addresses → IP addresses → BGP peerings.
Pass dry_run=True to preview changes without writing to NetBox.
Result.result is keyed by device name, then by category::
{
"<device>": {
"interfaces": {"created": [...], "updated": {...}, "deleted": [...], "in_sync": [...]},
"mac_addresses": {"created": [...], "updated": [...], "in_sync": [...]},
"ip_addresses": {"created": [...], "updated": [...], "in_sync": [...]},
"bgp_peerings": {"create": [...], "update": {...}, "delete": [...], "in_sync": [...]},
}
}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job
|
Job
|
NorFab Job object. |
required |
instance
|
str
|
NetBox instance name. |
None
|
timeout
|
int
|
Timeout in seconds for Nornir jobs. Defaults to 60. |
60
|
devices
|
list
|
List of device names to sync. |
None
|
branch
|
str
|
NetBox branching plugin branch name. |
None
|
dry_run
|
bool
|
If True, preview changes without writing to NetBox. Defaults to False. |
False
|
process_deletions
|
bool
|
Process deletions for interfaces and BGP peerings. Defaults to False. |
False
|
interfaces_filter_by_name
|
str
|
Glob pattern to filter interfaces by name. |
None
|
interfaces_filter_by_description
|
str
|
Glob pattern to filter interfaces by description. |
None
|
interfaces_update_type
|
bool
|
Update existing NetBox interface types. |
False
|
interfaces_vlan_group
|
(str, int)
|
VLAN group name, slug, or ID for interface VLAN resolution. |
None
|
mac_filter_by_name
|
str
|
Glob pattern to filter MAC sync interfaces by name. |
None
|
mac_filter_by_description
|
str
|
Glob pattern to filter MAC sync interfaces by description. |
None
|
mac_filter_by_mac
|
str
|
Glob pattern to filter MAC addresses. |
None
|
ip_anycast_ranges
|
list
|
IP prefixes to classify as anycast. |
None
|
ip_ignore_ranges
|
list
|
IP prefixes to exclude from IP sync. |
None
|
ip_create_prefixes
|
bool
|
Create missing prefixes during IP sync. |
True
|
ip_filter_by_name
|
str
|
Glob pattern to filter IP sync interfaces by name. |
None
|
ip_filter_by_description
|
str
|
Glob pattern to filter IP sync interfaces by description. |
None
|
ip_filter_by_prefix
|
str
|
IP prefix to restrict synced IP addresses. |
None
|
ip_filter_by_ip
|
str
|
Glob pattern to restrict synced IP addresses. |
None
|
bgp_status
|
str
|
Status to set on created/updated BGP sessions. |
'active'
|
bgp_rir
|
str
|
RIR name to use when creating new ASNs. |
None
|
bgp_message
|
str
|
Changelog message for BGP operations. |
None
|
bgp_name_template
|
str
|
Template string for BGP session names. |
'{device}_{name}'
|
bgp_filter_by_remote_as
|
list
|
Only sync sessions matching remote AS numbers. |
None
|
bgp_filter_by_peer_group
|
list
|
Only sync sessions matching peer groups. |
None
|
bgp_filter_by_description
|
str
|
Only sync sessions matching description glob. |
None
|
bgp_ignore_peer_ranges
|
list
|
Prefixes to ignore BGP peers. |
None
|
bgp_vrf_custom_field
|
str
|
BGP session custom field name used to store VRF reference. |
'vrf'
|
**kwargs
|
Any
|
Nornir host filter arguments (e.g. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Result |
Result
|
Per-device sync results keyed by device name and category. |
Source code in norfab\workers\netbox_worker\devices_tasks.py
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 | |