Skip to content

Commit

Permalink
fix(paloalto): fixing scenario when valn is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
bl4ko committed Mar 21, 2024
1 parent c527493 commit 67bbd8d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions internal/source/paloalto/paloalto_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,15 @@ func (pas *PaloAltoSource) SyncInterfaces(nbi *inventory.NetboxInventory) error
if subIfaceName == "" {
continue
}
var subIfaceVlan *objects.Vlan
subIfaceVlans := []*objects.Vlan{}
var subifaceMode *objects.InterfaceMode
if subIface.Tag != 0 {
// Extract Vlan
vlanGroup, err := common.MatchVlanToGroup(pas.Ctx, nbi, fmt.Sprintf("Vlan%d", subIface.Tag), pas.VlanGroupRelations)
if err != nil {
return fmt.Errorf("match vlan to group: %s", err)
}
subIfaceVlan, err = nbi.AddVlan(pas.Ctx, &objects.Vlan{
subIfaceVlan, err := nbi.AddVlan(pas.Ctx, &objects.Vlan{
NetboxObject: objects.NetboxObject{
Tags: pas.SourceTags,
Description: subIface.Comment,
Expand All @@ -169,6 +170,8 @@ func (pas *PaloAltoSource) SyncInterfaces(nbi *inventory.NetboxInventory) error
return fmt.Errorf("add vlan: %s", err)
}
ifaceVlans = append(ifaceVlans, subIfaceVlan)
subIfaceVlans = append(subIfaceVlans, subIfaceVlan)
subifaceMode = &objects.InterfaceModeTagged
}
nbSubIface, err := nbi.AddInterface(pas.Ctx, &objects.Interface{
NetboxObject: objects.NetboxObject{
Expand All @@ -178,8 +181,8 @@ func (pas *PaloAltoSource) SyncInterfaces(nbi *inventory.NetboxInventory) error
Name: subIface.Name,
Type: &objects.VirtualInterfaceType,
Device: pas.NBFirewall,
Mode: &objects.InterfaceModeTagged,
TaggedVlans: []*objects.Vlan{subIfaceVlan},
Mode: subifaceMode,
TaggedVlans: subIfaceVlans,
ParentInterface: nbIface,
MTU: subIface.Mtu,
Vdcs: []*objects.VirtualDeviceContext{pas.getVirtualDeviceContext(nbi, subIfaceName)},
Expand Down

0 comments on commit 67bbd8d

Please sign in to comment.