// GetVMSwitch returns a *VirtualSwitch given the ID of the switch
GetVMSwitch returns a *VirtualSwitch given the ID of the switch
// GetVMSwitch returns a * VirtualSwitch given the ID of the switch
func (m *Manager) GetVMSwitch(switchID string) (VirtualSwitch, error) {
	qParams := []wmi.Query{
		&wmi.AndQuery{
			wmi.QueryFields{
				Key:   "Name",
				Value: switchID,
				Type:  wmi.Equals,
			},
		},
	}
	switches, err := m.getVirtualSwitches(qParams)
	if err != nil {
		return VirtualSwitch{}, errors.Wrap(err, "getVirtualSwitches")
	}
	if len(switches) == 0 {
		return VirtualSwitch{}, wmi.ErrNotFound
	}
	if len(switches) != 1 {
		return VirtualSwitch{}, fmt.Errorf("got multiple switches from query. Expected 1")
	}
	return switches[0], nil
}
func ( m * Manager ) GetVMSwitch ( switchID string ) ( VirtualSwitch , error ) { qParams := [ ] wmi . Query { & wmi . AndQuery { wmi . QueryFields { Key : " " , Value : switchID , Type : wmi . Equals , } , } , } switches , err := m . getVirtualSwitches ( qParams ) if err != nil { return VirtualSwitch { } , errors . Wrap ( err , " " ) } if len ( switches ) == 0 { return VirtualSwitch { } , wmi . ErrNotFound } if len ( switches ) != 1 { return VirtualSwitch { } , fmt . Errorf ( " " ) } return switches [ 0 ] , nil }
GetVMSwitch returns a *VirtualSwitch given the ID of the switch
GetVMSwitch returns a * VirtualSwitch given the ID of the switch