Skip to content

[BUG] vcsim: criteria does not work in FetchDVPorts #2733

@Syuparn

Description

@Syuparn

Describe the bug
When FetchDVPorts is requested to vcsim, criteria field is ignored and all ports are responded

To Reproduce
Steps to reproduce the behavior:

  1. Start vcsim
  2. Request FetchDVPorts with criteria as below
var vCenterURL = "https://user:[email protected]:8989/sdk"

func main() {
	ctx := context.TODO()
	url, _ := url.Parse(vCenterURL)

	c, _ := govmomi.NewClient(ctx, url, true)
	f := find.NewFinder(c.Client)
	n, _ := f.Network(ctx, "/DC0/network/DVS0")

	dvs := object.NewDistributedVirtualSwitch(c.Client, n.Reference())

	criteria := &types.DistributedVirtualSwitchPortCriteria{
		PortgroupKey: []string{"dvportgroup-11"},
		Inside:       types.NewBool(true),
	}
	ports, err := dvs.FetchDVPorts(ctx, criteria)
	if err != nil {
		fmt.Printf("%+v\n", err)
		return
	}

	for _, port := range ports {
		fmt.Printf("key: %s, portgroupKey: %s\n", port.Key, port.PortgroupKey)
	}
}

Expected behavior
A clear and concise description of what you expected to happen.

  • vcsim responds only ports that belong to portgroups specified in the criteria
> go run main.go
key: 0, portgroupKey: dvportgroup-11

Affected version
Please provide details on the version used, e.g. release tag, commit, module version, etc.

  • vcsim 0.27.2

Screenshots/Debug Output
If applicable, add screenshots or debug output to help explain your problem.

  • vcsim responds all ports in the DVS
> go run main.go
key: dvportgroup-11, portgroupKey:
key: dvportgroup-13, portgroupKey:

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions