Skip to content

Trying to create a L2VPN Termination #19575

Closed Answered by pheus
beufanet asked this question in Help Wanted!
Discussion options

You must be logged in to vote

Hi there,

You're on the right track! When creating an L2VPNTermination, you can manually specify assigned_object_type and assigned_object_id, but it’s cleaner and less error-prone to let NetBox handle that part automatically.

Instead of doing:

macvrf = L2VPNTermination(
    l2vpn=MacVRF_L2VPN,
    assigned_object_type=VLAN,
    assigned_object_id=vlan_id,
)

You can just use the assigned_object parameter directly:

macvrf = L2VPNTermination(
    l2vpn=MacVRF_L2VPN,
    assigned_object=MacVRF_VLAN,
)

This way, NetBox will automatically set the correct ContentType and object ID under the hood.

If for some reason you do need to set the content type manually (not recommended unless necessary), …

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@pheus
Comment options

Answer selected by beufanet
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants