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

Fix showing network type #88

Merged
merged 1 commit into from
Nov 28, 2024
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
45 changes: 23 additions & 22 deletions api/v1alpha1/agent/spec.gen.go

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

4 changes: 3 additions & 1 deletion api/v1alpha1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -458,9 +458,11 @@ components:
properties:
type:
type: string
enum: [standard, distributed]
enum: [standard, distributed, dvswitch, unsupported]
name:
type: string
vlanId:
type: string
datastores:
type: array
items:
Expand Down
62 changes: 31 additions & 31 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: 5 additions & 2 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 cmd/planner-agent/COLLECTOR.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ EOF
Create VMware credentials file.

```
cat <<EOF > /tmp/data/creds.json
cat <<EOF > /tmp/data/credentials.json
{
"username": "[email protected]",
"password": "userpassword",
Expand Down
31 changes: 19 additions & 12 deletions internal/agent/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,35 +305,42 @@ func histogram(d []int) struct {
}

func getNetworks(collector *vsphere.Collector) []struct {
Name string `json:"name"`
Type apiplanner.InfraNetworksType `json:"type"`
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"`
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
r = append(r, struct {
Name string `json:"name"`
Type apiplanner.InfraNetworksType `json:"type"`
}{Name: n.Name, Type: apiplanner.InfraNetworksType(getNetworkType(&n))})
Name string `json:"name"`
Type apiplanner.InfraNetworksType `json:"type"`
VlanId *string `json:"vlanId,omitempty"`
}{Name: n.Name, Type: apiplanner.InfraNetworksType(getNetworkType(&n)), VlanId: &vlanId})
}

return r
}

// FIXME:
func getNetworkType(n *vspheremodel.Network) string {
if n.Key == "hosted" {
return "standard"
} else {
return "distributed"
if n.Variant == vspheremodel.NetDvPortGroup {
return string(apiplanner.Distributed)
} else if n.Variant == vspheremodel.NetStandard {
return string(apiplanner.Standard)
} else if n.Variant == vspheremodel.NetDvSwitch {
return string(apiplanner.Dvswitch)
}

return string(apiplanner.Unsupported)
}

func getHostsPerCluster(clusters []vspheremodel.Cluster) []int {
Expand Down