Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added InterfaceID and VNI to prefix table view, … #633

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cli/dpservice-cli/cmd/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
)

func Command() *cobra.Command {
cobra.EnableCaseInsensitive = true

dpdkClientOptions := &DPDKClientOptions{}
rendererOptions := &RendererOptions{}

Expand Down
2 changes: 1 addition & 1 deletion cli/dpservice-cli/cmd/create_loadbalancer_prefix.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func CreateLoadBalancerPrefix(
Short: "Create a loadbalancer prefix",
Example: "dpservice-cli create lbprefix --prefix=10.10.10.0/24 --interface-id=vm1",
Args: cobra.ExactArgs(0),
Aliases: PrefixAliases,
Aliases: LoadBalancerPrefixAliases,
RunE: func(cmd *cobra.Command, args []string) error {

return RunCreateLoadBalancerPrefix(
Expand Down
16 changes: 13 additions & 3 deletions cli/dpservice-cli/cmd/list_loadbalancer_prefixes.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,27 @@ func RunListLoadBalancerPrefixes(
}

for _, iface := range ifaces.Items {
prefix, err := client.ListLoadBalancerPrefixes(ctx, iface.ID)
if err != nil && prefix.Status.Code == 0 {
prefixes, err := client.ListLoadBalancerPrefixes(ctx, iface.ID)
if err != nil && prefixes.Status.Code == 0 {
return fmt.Errorf("error getting loadbalancer prefixes: %w", err)
}
prefixList.Items = append(prefixList.Items, prefix.Items...)
for id := range prefixes.Items {
prefixes.Items[id].Vni = iface.Spec.VNI
}
prefixList.Items = append(prefixList.Items, prefixes.Items...)
}
} else {
prefixList, err = client.ListLoadBalancerPrefixes(ctx, opts.InterfaceID)
if err != nil {
return fmt.Errorf("error listing loadbalancer prefixes: %w", err)
}
iface, err := client.GetInterface(ctx, opts.InterfaceID)
if err != nil {
return fmt.Errorf("error getting interface: %w", err)
}
for id := range prefixList.Items {
prefixList.Items[id].Vni = iface.Spec.VNI
}
}

// sort items in list
Expand Down
16 changes: 13 additions & 3 deletions cli/dpservice-cli/cmd/list_prefixes.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,27 @@ func RunListPrefixes(
}

for _, iface := range ifaces.Items {
prefix, err := client.ListPrefixes(ctx, iface.ID)
if err != nil && prefix.Status.Code == 0 {
prefixes, err := client.ListPrefixes(ctx, iface.ID)
if err != nil && prefixes.Status.Code == 0 {
return fmt.Errorf("error getting prefixes: %w", err)
}
prefixList.Items = append(prefixList.Items, prefix.Items...)
for id := range prefixes.Items {
prefixes.Items[id].Vni = iface.Spec.VNI
}
prefixList.Items = append(prefixList.Items, prefixes.Items...)
}
} else {
prefixList, err = client.ListPrefixes(ctx, opts.InterfaceID)
if err != nil {
return fmt.Errorf("error listing prefixes: %w", err)
}
iface, err := client.GetInterface(ctx, opts.InterfaceID)
if err != nil {
return fmt.Errorf("error getting interface: %w", err)
}
for id := range prefixList.Items {
prefixList.Items[id].Vni = iface.Spec.VNI
}
}
// sort items in list
prefixes := prefixList.Items
Expand Down
4 changes: 2 additions & 2 deletions cli/dpservice-cli/renderer/renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,11 @@ func (t defaultTableConverter) interfaceTable(ifaces []api.Interface) (*TableDat
}

func (t defaultTableConverter) prefixTable(prefixes []api.Prefix) (*TableData, error) {
headers := []any{"Prefix", "UnderlayRoute"}
headers := []any{"VNI", "Prefix", "UnderlayRoute", "InterfaceID"}

columns := make([][]any, len(prefixes))
for i, prefix := range prefixes {
columns[i] = []any{prefix.Spec.Prefix, prefix.Spec.UnderlayRoute}
columns[i] = []any{prefix.Vni, prefix.Spec.Prefix, prefix.Spec.UnderlayRoute, prefix.InterfaceID}
}

return &TableData{
Expand Down
1 change: 1 addition & 0 deletions go/dpservice-go/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ type Prefix struct {

type PrefixMeta struct {
InterfaceID string `json:"interface_id"`
Vni uint32 `json:"vni"`
}

func (m *Prefix) GetName() string {
Expand Down
Loading