From d1876ce60027d547802a0144c2a9f5899e3e1ca9 Mon Sep 17 00:00:00 2001 From: Atul Patel Date: Fri, 3 May 2024 06:28:48 +0100 Subject: [PATCH] fix(evpn): do not print empty vni/vtep Signed-off-by: Atul Patel --- cmd/network/evpn-utils.go | 22 ++++++++++++++++------ docker-compose.yml | 2 +- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/cmd/network/evpn-utils.go b/cmd/network/evpn-utils.go index 3921713..a9fb647 100644 --- a/cmd/network/evpn-utils.go +++ b/cmd/network/evpn-utils.go @@ -37,12 +37,17 @@ func ComposeGwIps(comp []*pc.IPPrefix) string { // PrintLB prints the logical bridge fields in human readable format func PrintLB(lb *pb.LogicalBridge) { - Vteip := fmt.Sprintf("%+v/%v", ipconv.IntToIPv4(lb.GetSpec().GetVtepIpPrefix().GetAddr().GetV4Addr()), lb.GetSpec().GetVtepIpPrefix().GetLen()) log.Println("name:", lb.GetName()) log.Println("status:", lb.GetStatus().GetOperStatus().String()) log.Println("vlan:", lb.GetSpec().GetVlanId()) - log.Println("vni:", lb.GetSpec().GetVni()) - log.Println("VtepIpPrefix:", Vteip) + if lb.GetSpec().GetVni() != 0 { + log.Println("vni:", lb.GetSpec().GetVni()) + } + if lb.GetSpec().GetVtepIpPrefix().GetAddr().GetV4Addr() != 0 { + Vteip := fmt.Sprintf("%+v/%v", ipconv.IntToIPv4(lb.GetSpec().GetVtepIpPrefix().GetAddr().GetV4Addr()), lb.GetSpec().GetVtepIpPrefix().GetLen()) + log.Println("vtep ip:", Vteip) + } + log.Println("Component Status:") log.Println(ComposeComponentsInfo(lb.GetStatus().GetComponents())) } @@ -74,12 +79,17 @@ func PrintSvi(svi *pb.Svi) { // PrintVrf prints the vrf fields in human readable format func PrintVrf(vrf *pb.Vrf) { - Vteip := fmt.Sprintf("%+v/%v", ipconv.IntToIPv4(vrf.GetSpec().GetVtepIpPrefix().GetAddr().GetV4Addr()), vrf.GetSpec().GetVtepIpPrefix().GetLen()) Loopback := fmt.Sprintf("%+v/%+v", ipconv.IntToIPv4(vrf.GetSpec().GetLoopbackIpPrefix().GetAddr().GetV4Addr()), vrf.GetSpec().GetLoopbackIpPrefix().GetLen()) log.Println("name:", vrf.GetName()) log.Println("operation status:", vrf.GetStatus().GetOperStatus().String()) - log.Println("vni:", vrf.GetSpec().GetVni()) - log.Println("vtep ip:", Vteip) + + if vrf.GetSpec().GetVni() != 0 { + log.Println("vni:", vrf.GetSpec().GetVni()) + } + if vrf.GetSpec().GetVtepIpPrefix().GetAddr().GetV4Addr() != 0 { + Vteip := fmt.Sprintf("%+v/%v", ipconv.IntToIPv4(vrf.GetSpec().GetVtepIpPrefix().GetAddr().GetV4Addr()), vrf.GetSpec().GetVtepIpPrefix().GetLen()) + log.Println("vtep ip:", Vteip) + } log.Println("loopback ip:", Loopback) log.Println("Component Status:") log.Println(ComposeComponentsInfo(vrf.GetStatus().GetComponents())) diff --git a/docker-compose.yml b/docker-compose.yml index 0b52d3b..f9b73e9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -142,7 +142,7 @@ services: - NET_ADMIN networks: - opi - command: /opi-evpn-bridge -grpc_port=50151 -http_port=8082 -redis_addr="redis:6379" -frr_addr="frr" + command: /opi-evpn-bridge --grpcport=50151 --httpport=8082 --dbaddress="redis:6379" --database=redis healthcheck: test: grpcurl -plaintext localhost:50151 list || exit 1 depends_on: