Skip to content

Commit

Permalink
Fix Add SR Policy and PCInitiate log
Browse files Browse the repository at this point in the history
  • Loading branch information
Motok1 committed Oct 17, 2022
1 parent 2fd0b5d commit b618ac8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
15 changes: 14 additions & 1 deletion pkg/server/grpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,20 @@ func (s *APIServer) CreateSrPolicy(ctx context.Context, input *pb.CreateSrPolicy
return &pb.SrPolicyStatus{IsSuccess: false}, errors.New("input is invalid")
}

s.pce.logger.Info("Get request CreateSrPolicy API", zap.Any("SR Policy", input.GetSrPolicy()), zap.String("server", "grpc"))
inputJson := map[string]interface{}{
"asn": fmt.Sprint(input.GetAsn()),
"srPolicy": map[string]interface{}{
"pcepSessionAddr": net.IP(input.GetSrPolicy().GetPcepSessionAddr()).String(),
"color": input.GetSrPolicy().GetColor(),
"dstRouterId": input.GetSrPolicy().GetDstRouterId(),
"srcRouterId": input.GetSrPolicy().GetSrcRouterId(),
"type": input.GetSrPolicy().GetType().String(),
"segmentList": input.GetSrPolicy().GetSegmentList(),
"metric": input.GetSrPolicy().GetMetric().String(),
},
}

s.pce.logger.Info("Get request CreateSrPolicy API", zap.Any("input", inputJson), zap.String("server", "grpc"))
pcepSessionAddr := net.IP(input.GetSrPolicy().GetPcepSessionAddr())
pcepSession := s.pce.getSession(pcepSessionAddr)
if pcepSession == nil {
Expand Down
10 changes: 9 additions & 1 deletion pkg/server/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,15 @@ func (s *Session) SendPCInitiate(policyName string, labels []pcep.Label, color u
if err != nil {
return err
}
s.logger.Info("Send PCInitiate", zap.String("session", s.peerAddr.String()), zap.Uint32("srpId", s.srpIdHead), zap.String("policyName", policyName), zap.Any("labels", labels), zap.Uint32("color", color), zap.Uint32("preference", preference), zap.Any("srcIPv4", srcIPv4), zap.Any("dstIPv4", dstIPv4))
labelsJson := []map[string]interface{}{}
for _, l := range labels {
labelJson := map[string]interface{}{
"Sid": l.Sid,
"LoAddr": net.IP(l.LoAddr).String(),
}
labelsJson = append(labelsJson, labelJson)
}
s.logger.Info("Send PCInitiate", zap.String("session", s.peerAddr.String()), zap.Uint32("srpId", s.srpIdHead), zap.String("policyName", policyName), zap.Any("labels", labelsJson), zap.Uint32("color", color), zap.Uint32("preference", preference), zap.String("srcIPv4", net.IP(srcIPv4).String()), zap.Any("dstIPv4", net.IP(dstIPv4).String()))
if _, err := s.tcpConn.Write(bytePCInitiateMessage); err != nil {
return err
}
Expand Down

0 comments on commit b618ac8

Please sign in to comment.