-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Atul Patel <Atul.Patel@intel.com> Co-authored-by: Dimitrios Markou <dimitrios.markou@ericsson.com> Co-authored-by: Venkatesh Vemula <venkatesh.vemula@intel.com> Co-authored-by: Banoth Saikumar <banoth.saikumar@intel.com>
- Loading branch information
1 parent
6e3f317
commit acb3a85
Showing
7 changed files
with
145 additions
and
47 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
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,86 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright (c) 2022-2023 Intel Corporation, or its subsidiaries. | ||
// Copyright (c) 2022-2023 Dell Inc, or its subsidiaries. | ||
// Copyright (c) 2024 Ericsson AB. | ||
|
||
// Package network implements the network related CLI commands | ||
package network | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
|
||
"github.com/PraserX/ipconv" | ||
pb "github.com/opiproject/opi-api/network/evpn-gw/v1alpha1/gen/go" | ||
pc "github.com/opiproject/opi-api/network/opinetcommon/v1alpha1/gen/go" | ||
) | ||
|
||
// ComposeComponentsInfo composes the components with their details | ||
func ComposeComponentsInfo(comp []*pb.Component) string { | ||
var status string | ||
for i := 0; i < len(comp); i++ { | ||
str := fmt.Sprintf(" %+v\n", comp[i]) | ||
status += str | ||
} | ||
return status | ||
} | ||
|
||
// ComposeGwIps compose the gw ips string | ||
func ComposeGwIps(comp []*pc.IPPrefix) string { | ||
var status string | ||
for i := 0; i < len(comp); i++ { | ||
str := fmt.Sprintf("%+v/%v ", ipconv.IntToIPv4(comp[i].GetAddr().GetV4Addr()), comp[i].GetLen()) | ||
status += str | ||
} | ||
return status | ||
} | ||
|
||
// 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) | ||
log.Println("Component Status:") | ||
log.Println(ComposeComponentsInfo(lb.GetStatus().GetComponents())) | ||
} | ||
|
||
// PrintBP prints the bridge Port fields in human readable format | ||
func PrintBP(bp *pb.BridgePort) { | ||
log.Println("name:", bp.GetName()) | ||
log.Println("status:", bp.GetStatus().GetOperStatus().String()) | ||
log.Println("ptype:", bp.GetSpec().GetPtype()) | ||
log.Println("mac:", bp.GetSpec().GetMacAddress()) | ||
log.Println("bridges:", bp.GetSpec().GetLogicalBridges()) | ||
log.Println("Component Status:") | ||
log.Println(ComposeComponentsInfo(bp.GetStatus().GetComponents())) | ||
} | ||
|
||
// PrintSvi prints the svi fields in human readable format | ||
func PrintSvi(svi *pb.Svi) { | ||
log.Println("name:", svi.GetName()) | ||
log.Println("status:", svi.GetStatus().GetOperStatus().String()) | ||
log.Println("Vrf:", svi.GetSpec().GetVrf()) | ||
log.Println("LogicalBridge:", svi.GetSpec().GetLogicalBridge()) | ||
log.Println("MacAddress:", svi.GetSpec().GetMacAddress()) | ||
log.Println("EnableBgp:", svi.GetSpec().GetEnableBgp()) | ||
log.Println("GwIPs:", ComposeGwIps(svi.GetSpec().GetGwIpPrefix())) | ||
log.Println("remoteAS:", svi.GetSpec().GetRemoteAs()) | ||
log.Println("Component Status:") | ||
log.Println(ComposeComponentsInfo(svi.GetStatus().GetComponents())) | ||
} | ||
|
||
// 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) | ||
log.Println("loopback ip:", Loopback) | ||
log.Println("Component Status:") | ||
log.Println(ComposeComponentsInfo(vrf.GetStatus().GetComponents())) | ||
} |
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.