Skip to content

Commit

Permalink
chore: add few logs
Browse files Browse the repository at this point in the history
Signed-off-by: Boris Glimcher <Boris.Glimcher@emc.com>
  • Loading branch information
glimchb committed Aug 11, 2023
1 parent d33b4f9 commit ac57ea2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/evpn/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func (s *Server) CreateLogicalBridge(_ context.Context, in *pb.CreateLogicalBrid
// TODO: remove hard-coded 167772260 == "10.0.0.100"
binary.BigEndian.PutUint32(myip, 167772260)
vxlan := &netlink.Vxlan{LinkAttrs: netlink.LinkAttrs{Name: resourceID}, VxlanId: int(in.LogicalBridge.Spec.Vni), Port: 4789, Learning: false, SrcAddr: myip}
log.Printf("Creating Vxlan %v", vxlan)
// TODO: take Port from proto instead of hard-coded
if err := netlink.LinkAdd(vxlan); err != nil {
fmt.Printf("Failed to create Vxlan link: %v", err)
Expand Down Expand Up @@ -132,6 +133,7 @@ func (s *Server) DeleteLogicalBridge(_ context.Context, in *pb.DeleteLogicalBrid
log.Printf("error: %v", err)
return nil, err
}
log.Printf("Deleting Vxlan %v", vxlan)
// bring link down
if err := netlink.LinkSetDown(vxlan); err != nil {
fmt.Printf("Failed to up link: %v", err)
Expand Down
2 changes: 2 additions & 0 deletions pkg/evpn/svi.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func (s *Server) CreateSvi(_ context.Context, in *pb.CreateSviRequest) (*pb.Svi,
},
VlanId: int(bridgeObject.Spec.VlanId),
}
log.Printf("Creating VLAN %v", vlandev)
if err := netlink.LinkAdd(vlandev); err != nil {
fmt.Printf("Failed to create vlan link: %v", err)
return nil, err
Expand Down Expand Up @@ -175,6 +176,7 @@ func (s *Server) DeleteSvi(_ context.Context, in *pb.DeleteSviRequest) (*emptypb
log.Printf("error: %v", err)
return nil, err
}
log.Printf("Deleting VLAN %v", vlandev)
// bring link down
if err := netlink.LinkSetDown(vlandev); err != nil {
fmt.Printf("Failed to up link: %v", err)
Expand Down
2 changes: 2 additions & 0 deletions pkg/evpn/vrf.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func (s *Server) CreateVrf(_ context.Context, in *pb.CreateVrfRequest) (*pb.Vrf,
tableID := uint32(1000 + math.Mod(float64(in.Vrf.Spec.Vni), 10.0))
// Example: ip link add blue type vrf table 1000
vrf := &netlink.Vrf{LinkAttrs: netlink.LinkAttrs{Name: vrfName}, Table: tableID}
log.Printf("Creating VRF %v", vrf)
if err := netlink.LinkAdd(vrf); err != nil {
fmt.Printf("Failed to create VRF link: %v", err)
return nil, err
Expand Down Expand Up @@ -166,6 +167,7 @@ func (s *Server) DeleteVrf(_ context.Context, in *pb.DeleteVrfRequest) (*emptypb
resourceID := path.Base(obj.Name)
// use netlink to find VRF
vrf, err := netlink.LinkByName(resourceID)
log.Printf("Deleting VRF %v", vrf)
if err != nil {
err := status.Errorf(codes.NotFound, "unable to find key %s", resourceID)
log.Printf("error: %v", err)
Expand Down

0 comments on commit ac57ea2

Please sign in to comment.