-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(inventory): enable syncing of sites for vlans
- Loading branch information
Showing
12 changed files
with
131 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package inventory | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/bl4ko/netbox-ssot/internal/constants" | ||
"github.com/bl4ko/netbox-ssot/internal/netbox/objects" | ||
"github.com/bl4ko/netbox-ssot/internal/utils" | ||
) | ||
|
||
// Inits default VlanGroup, which is required to group all Vlans that are not part of other | ||
// vlangroups into it. Each vlan is indexed by their (vlanGroup, vid). | ||
func (nbi *NetboxInventory) CreateDefaultVlanGroupForVlan(ctx context.Context, vlanSite *objects.Site) (*objects.VlanGroup, error) { | ||
var vlanGroupName string | ||
if vlanSite != nil { | ||
vlanGroupName = fmt.Sprintf("%sDefaultVlanGroup", vlanSite.Name) | ||
} else { | ||
vlanGroupName = constants.DefaultVlanGroupName | ||
} | ||
vlanGroup, err := nbi.AddVlanGroup(ctx, &objects.VlanGroup{ | ||
NetboxObject: objects.NetboxObject{ | ||
Tags: []*objects.Tag{nbi.SsotTag}, | ||
Description: constants.DefaultVlanGroupDescription, | ||
CustomFields: map[string]interface{}{ | ||
constants.CustomFieldSourceName: nbi.SsotTag.Name, | ||
}, | ||
}, | ||
Name: vlanGroupName, | ||
Slug: utils.Slugify(constants.DefaultVlanGroupName), | ||
VidRanges: []objects.VidRange{{constants.DefaultVID, constants.MaxVID}}, | ||
}) | ||
if err != nil { | ||
return nil, fmt.Errorf("add vlan group: %s", err) | ||
} | ||
return vlanGroup, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.