/// <summary> /// Creates a host handle /// </summary> /// <returns>true if succeeded, otherwise false</returns> public bool Connect(string hostName, string userName, string password) { int hostType = string.IsNullOrEmpty(hostName) ? VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_WORKSTATION : VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_SERVER; int vixVersion = VixCOM.Constants.VIX_API_VERSION; vixVersion = 1; // Bugfix: http://communities.vmware.com/message/649925#649925 //VixCOM.IJob jobHandle = vixLib.Connect(vixVersion, hostType, hostName, 0, userName, password, 0, null, null); // for use with player: http://www.vmware.com/pdf/vix180_player_technote.pdf VixCOM.IJob jobHandle = vixLib.Connect(VixCOM.Constants.VIX_API_VERSION, VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_PLAYER, null, 0, null, null, VixCOM.Constants.VIX_INVALID_HANDLE, null, null); int[] propertyIds = new int[1] { VixCOM.Constants.VIX_PROPERTY_JOB_RESULT_HANDLE }; object results = new object(); m_vixError = jobHandle.Wait(propertyIds, ref results); if (m_vixError == VixCOM.Constants.VIX_OK) { object[] objectArray = (object[])results; m_hostHandle = (VixCOM.IHost)objectArray[0]; return(true); } return(false); }
private void WaitForToolsInGuest() { VixCOM.IJob job = _virtualMachine.WaitForToolsInGuest(0, null); UInt64 err = job.WaitWithoutResults(); if (lib.ErrorIndicatesFailure(err)) { short errCode = lib.ErrorCode(err); string errMsg; errMsg = lib.GetErrorText(err, null); throw new Exception("WaitForToolsInGuest: " + errMsg); } }
public void CreateDirectory(string name) { VixCOM.IJob job = _virtualMachine.CreateDirectoryInGuest(name, null, null); UInt64 err = job.WaitWithoutResults(); if (lib.ErrorIndicatesFailure(err)) { short errCode = lib.ErrorCode(err); string errMsg; errMsg = lib.GetErrorText(err, null); throw new Exception("CreateDirectory: " + errMsg); } }
public void LoginInGuest(string username, string password) { VixCOM.IJob job = _virtualMachine.LoginInGuest(username, password, 0, null); UInt64 err = job.WaitWithoutResults(); if (lib.ErrorIndicatesFailure(err)) { short errCode = lib.ErrorCode(err); string errMsg; errMsg = lib.GetErrorText(err, null); throw new Exception("LoginInGuest: " + errMsg); } }
public void CopyFileToHost(string source, string destination) { VixCOM.IJob job = _virtualMachine.CopyFileFromGuestToHost(source, destination, 0, null, null); UInt64 err = job.WaitWithoutResults(); if (lib.ErrorIndicatesFailure(err)) { short errCode = lib.ErrorCode(err); string errMsg; errMsg = lib.GetErrorText(err, null); throw new Exception("CopyFileToHost: " + errMsg); } }
public void PowerOff() { VixCOM.IJob job = _virtualMachine.PowerOff(0, null); UInt64 err = job.WaitWithoutResults(); if (lib.ErrorIndicatesFailure(err)) { short errCode = lib.ErrorCode(err); string errMsg; errMsg = lib.GetErrorText(err, null); throw new Exception("PowerOff: " + errMsg); } }
public void RunProgramInGuest(string fullPath, string param) { VixCOM.IJob job = _virtualMachine.RunProgramInGuest(fullPath, param, 0, null, null); UInt64 err = job.WaitWithoutResults(); if (lib.ErrorIndicatesFailure(err)) { short errCode = lib.ErrorCode(err); string errMsg; errMsg = lib.GetErrorText(err, null); throw new Exception("RunProgramInGuest: " + errMsg); } }
public void OpenVM(string path) { object results = null; VixCOM.IJob job = _vmwareHost.OpenVM(path, null); UInt64 err = job.Wait(new int[] { VixCOM.Constants.VIX_PROPERTY_JOB_RESULT_HANDLE }, ref results); if (lib.ErrorIndicatesFailure(err)) { short errCode = lib.ErrorCode(err); string errMsg; errMsg = lib.GetErrorText(err, null); throw new Exception("OpenVM:" + errMsg); } _virtualMachine = (VixCOM.IVM)((object[])results)[0]; }
public void RevertToSnapshot(string snapshotName) { VixCOM.ISnapshot snapshot; _virtualMachine.GetNamedSnapshot(snapshotName, out snapshot); VixCOM.IJob job = _virtualMachine.RevertToSnapshot(snapshot, 0, null, null); UInt64 err = job.WaitWithoutResults(); if (lib.ErrorIndicatesFailure(err)) { short errCode = lib.ErrorCode(err); string errMsg; errMsg = lib.GetErrorText(err, null); throw new Exception("RevertToSnapshot: " + errMsg); } WaitForToolsInGuest(); }
public void Connect() { object results = null; VixCOM.IJob job = lib.Connect(VixCOM.Constants.VIX_API_VERSION, VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_WORKSTATION, "", 0, "", "", 0, null, null); object[] data = { VixCOM.Constants.VIX_PROPERTY_JOB_RESULT_HANDLE }; UInt64 err = job.Wait(new int[] { VixCOM.Constants.VIX_PROPERTY_JOB_RESULT_HANDLE }, ref results); if (lib.ErrorIndicatesFailure(err)) { short errCode = lib.ErrorCode(err); string errMsg; errMsg = lib.GetErrorText(err, null); throw new Exception("Connect: " + errMsg); } _vmwareHost = (VixCOM.IHost)((object[])results)[0]; }
/// <summary> /// Creates a host handle /// </summary> /// <returns>true if succeeded, otherwise false</returns> public bool Connect(string hostName, string userName, string password, int serviceProvider) { int hostType = -1; // Edited by Mitchell Lutz if (serviceProvider == 1) { hostType = VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_WORKSTATION; } else if (serviceProvider == 2) { hostType = VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_SERVER; } //int hostType = string.IsNullOrEmpty(hostName) ? // VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_WORKSTATION : // VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_SERVER; int vixVersion = VixCOM.Constants.VIX_API_VERSION; vixVersion = 1; // Bugfix: http://communities.vmware.com/message/649925#649925 VixCOM.IJob jobHandle = vixLib.Connect(vixVersion, hostType, hostName, 0, userName, password, 0, null, null); int[] propertyIds = new int[1] { VixCOM.Constants.VIX_PROPERTY_JOB_RESULT_HANDLE }; object results = new object(); m_vixError = jobHandle.Wait(propertyIds, ref results); if (m_vixError == VixCOM.Constants.VIX_OK) { object[] objectArray = (object[])results; m_hostHandle = (VixCOM.IHost)objectArray[0]; return(true); } return(false); }