private VirtualMachinePowerResult PowerOn(VirtualMachineConfig virtualMachineConfig) { VirtualMachinePowerResult powerResult = new VirtualMachinePowerResult(); powerResult.Name = virtualMachineConfig.Name; try { if (virtualMachineConfig.Snapshots.Count != 1) { throw new Exception(string.Format("Invalid number of snapshots in '{0}'", virtualMachineConfig.Name)); } VirtualMachinePowerDriver powerDriver = new VirtualMachinePowerDriver( virtualMachineConfig, virtualMachineConfig.Snapshots[0], _simulationOnly); _virtualMachinePowerDrivers.Add(powerDriver); powerDriver.ConnectToHost(); powerDriver.MapVirtualMachine(virtualMachineConfig.CopyMethod); powerDriver.PrepareSnapshot(); powerResult.Success = true; } catch (Exception ex) { ConsoleOutput.WriteLine(ex); powerResult.LastError = ex.Message; powerResult.Success = false; } return(powerResult); }
private VirtualMachinePowerResult PowerOn(VirtualMachineConfig virtualMachineConfig) { VirtualMachinePowerResult powerResult = new VirtualMachinePowerResult(); powerResult.Name = virtualMachineConfig.Name; try { if (virtualMachineConfig.Snapshots.Count != 1) { throw new Exception(string.Format("Invalid number of snapshots in '{0}'", virtualMachineConfig.Name)); } VirtualMachinePowerDriver powerDriver = new VirtualMachinePowerDriver( virtualMachineConfig, virtualMachineConfig.Snapshots[0], _simulationOnly); _virtualMachinePowerDrivers.Add(powerDriver); powerDriver.ConnectToHost(); powerDriver.MapVirtualMachine(virtualMachineConfig.CopyMethod); powerDriver.PrepareSnapshot(); powerResult.Success = true; } catch (Exception ex) { ConsoleOutput.WriteLine(ex); powerResult.LastError = ex.Message; powerResult.Success = false; } return powerResult; }