Skip to content

Commit

Permalink
Fix showing network type
Browse files Browse the repository at this point in the history
Signed-off-by: Ondra Machacek <[email protected]>
  • Loading branch information
machacekondra committed Nov 29, 2024
1 parent e952f7f commit 0aec793
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 65 deletions.
46 changes: 23 additions & 23 deletions api/v1alpha1/agent/spec.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions api/v1alpha1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,8 @@ components:
type: string
vlanId:
type: string
dvswitch:
type: string
datastores:
type: array
items:
Expand Down
50 changes: 25 additions & 25 deletions api/v1alpha1/spec.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions api/v1alpha1/types.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,6 @@ require (
)

replace (
github.com/konveyor/forklift-controller => github.com/kubev2v/forklift v0.0.0-20241128114951-4c1195e2a8f0
github.com/konveyor/forklift-controller => github.com/kubev2v/forklift v0.0.0-20241129095927-4890e072e015
github.com/vmware/govmomi => github.com/vmware/govmomi v0.34.1
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kubev2v/forklift v0.0.0-20241128114951-4c1195e2a8f0 h1:08QJ05m30zyQFU2bBNmQHZ+2robnTm6V2FEjGJYm0FQ=
github.com/kubev2v/forklift v0.0.0-20241128114951-4c1195e2a8f0/go.mod h1:fHaGLhv09dWXKv0/0GNl3rgLe/KH5Y6IyG6eGLYaA6k=
github.com/kubev2v/forklift v0.0.0-20241129095927-4890e072e015 h1:lKoe5Sy+faux6gdX/pCsBsEOQYvqAwhpAOglmGjhWMo=
github.com/kubev2v/forklift v0.0.0-20241129095927-4890e072e015/go.mod h1:fHaGLhv09dWXKv0/0GNl3rgLe/KH5Y6IyG6eGLYaA6k=
github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw=
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
Expand Down
32 changes: 21 additions & 11 deletions internal/agent/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,27 +305,37 @@ func histogram(d []int) struct {
}

func getNetworks(collector *vsphere.Collector) []struct {
Name string `json:"name"`
Type apiplanner.InfraNetworksType `json:"type"`
VlanId *string `json:"vlanId,omitempty"`
Dvswitch *string `json:"dvswitch,omitempty"`
Name string `json:"name"`
Type apiplanner.InfraNetworksType `json:"type"`
VlanId *string `json:"vlanId,omitempty"`
} {
r := []struct {
Name string `json:"name"`
Type apiplanner.InfraNetworksType `json:"type"`
VlanId *string `json:"vlanId,omitempty"`
Dvswitch *string `json:"dvswitch,omitempty"`
Name string `json:"name"`
Type apiplanner.InfraNetworksType `json:"type"`
VlanId *string `json:"vlanId,omitempty"`
}{}
networks := &[]vspheremodel.Network{}
err := collector.DB().List(networks, libmodel.FilterOptions{Detail: 1})
if err != nil {
return nil
}

for _, n := range *networks {
vlanId := "" // TODO: use: https://github.com/kubev2v/forklift/pull/1225

vlanId := n.VlanId
dvNet := &vspheremodel.Network{}
if n.Variant == vspheremodel.NetDvPortGroup {
dvNet.WithRef(n.DVSwitch)
_ = collector.DB().Get(dvNet)
}
r = append(r, struct {
Name string `json:"name"`
Type apiplanner.InfraNetworksType `json:"type"`
VlanId *string `json:"vlanId,omitempty"`
}{Name: n.Name, Type: apiplanner.InfraNetworksType(getNetworkType(&n)), VlanId: &vlanId})
Dvswitch *string `json:"dvswitch,omitempty"`
Name string `json:"name"`
Type apiplanner.InfraNetworksType `json:"type"`
VlanId *string `json:"vlanId,omitempty"`
}{Name: n.Name, Type: apiplanner.InfraNetworksType(getNetworkType(&n)), VlanId: &vlanId, Dvswitch: &dvNet.Name})
}

return r
Expand Down

0 comments on commit 0aec793

Please sign in to comment.