// GetVM returns the virtual machine identified by instanceID
GetVM returns the virtual machine identified by instanceID
// GetVM returns the virtual machine identified by instanceID
func (m *Manager) GetVM(instanceID string) (*VirtualMachine, error) {
	fields := []string{}
	qParams := []wmi.Query{
		&wmi.AndQuery{
			wmi.QueryFields{
				Key:   "VirtualSystemType",
				Value: VirtualSystemTypeRealized,
				Type:  wmi.Equals},
		},
		&wmi.AndQuery{
			wmi.QueryFields{
				Key:   "VirtualSystemIdentifier",
				Value: instanceID,
				Type:  wmi.Equals},
		},
	}
	result, err := m.con.Gwmi(VirtualSystemSettingDataClass, fields, qParams)
	if err != nil {
		return nil, errors.Wrap(err, "VirtualSystemSettingDataClass")
	}
	vssd, err := result.ItemAtIndex(0)
	if err != nil {
		return nil, errors.Wrap(err, "fetching element")
	}
	cs, err := vssd.Get("associators_", nil, ComputerSystemClass)
	if err != nil {
		return nil, errors.Wrap(err, "getting ComputerSystemClass")
	}
	elem, err := cs.Elements()
	if err != nil || len(elem) == 0 {
		return nil, errors.Wrap(err, "getting elements")
	}
	pth, err := elem[0].Path()
	if err != nil {
		return nil, errors.Wrap(err, "VM path")
	}
	return &VirtualMachine{
		mgr:                m,
		activeSettingsData: vssd,
		computerSystem:     elem[0],
		path:               pth,
	}, nil
}
func ( m * Manager ) GetVM ( instanceID string ) ( * VirtualMachine , error ) { fields := [ ] string { } qParams := [ ] wmi . Query { & wmi . AndQuery { wmi . QueryFields { Key : " " , Value : VirtualSystemTypeRealized , Type : wmi . Equals } , } , & wmi . AndQuery { wmi . QueryFields { Key : " " , Value : instanceID , Type : wmi . Equals } , } , } result , err := m . con . Gwmi ( VirtualSystemSettingDataClass , fields , qParams ) if err != nil { return nil , errors . Wrap ( err , " " ) } vssd , err := result . ItemAtIndex ( 0 ) if err != nil { return nil , errors . Wrap ( err , " " ) } cs , err := vssd . Get ( " " , nil , ComputerSystemClass ) if err != nil { return nil , errors . Wrap ( err , " " ) } elem , err := cs . Elements ( ) if err != nil || len ( elem ) == 0 { return nil , errors . Wrap ( err , " " ) } pth , err := elem [ 0 ] . Path ( ) if err != nil { return nil , errors . Wrap ( err , " " ) } return & VirtualMachine { mgr : m , activeSettingsData : vssd , computerSystem : elem [ 0 ] , path : pth , } , nil }
GetVM returns the virtual machine identified by instanceID
GetVM returns the virtual machine identified by instanceID