Example #1
0
        public void Snap()
        {
            machine.LockMachine(session, LockType.LockType_Write);

            if (machine.SnapshotCount > 0)
            {
                var snapshot = machine.FindSnapshot("origin");
                machine.DeleteSnapshot(snapshot.Id).WaitForCompletion(-1);
            }

            string id;

            machine.TakeSnapshot("origin", "чистое состояние", 1, out id).WaitForCompletion(-1);
            session.UnlockMachine();
        }
Example #2
0
        public override void StartVM(string mode)
        {
            Session session = new SessionClass();

            if (machine.State == MachineState.MachineState_PoweredOff || machine.State == MachineState.MachineState_Aborted || machine.State == MachineState.MachineState_Saved)
            {
                var prog = machine.LaunchVMProcess(session, mode, "");
                prog.WaitForCompletion(10000);

                while (machine.State != MachineState.MachineState_Running)
                {
                    Thread.Sleep(100);
                }

                if (session.State == SessionState.SessionState_Locked)
                {
                    session.UnlockMachine();
                }
            }
            else if (machine.State != MachineState.MachineState_Running)
            {
                throw new Exception(machine.Name + " cannot be launched, because the current status is not Poweredoff or Aborted");
            }
        }