Exemplo n.º 1
0
        public override void StartVMProcess(string BinaryPath, string[] args, bool hidden, int timeout)
        {
            VMObjects     vo = Instanciate();
            IGuestProcess ip = null;

            ip = vo.GSession.ProcessCreate(BinaryPath, args, new string[] { }, new ProcessCreateFlag[] { hidden?ProcessCreateFlag.ProcessCreateFlag_Hidden: ProcessCreateFlag.ProcessCreateFlag_None }, (uint)timeout);
            //ip.WaitFor((uint)ProcessWaitForFlag.ProcessWaitForFlag_Terminate, (uint)timeout);
            releaseObjects(vo);
        }
Exemplo n.º 2
0
        public override void SuspendVM()
        {
            VMObjects vo = Instanciate();

            if (machine.State == MachineState.MachineState_Running)
            {
                vo.Console.PowerDown().WaitForCompletion(40000);
            }

            releaseObjects(vo);
        }
Exemplo n.º 3
0
        public override void CopyFileFromHost(string HostPath, string VMPath)
        {
            VMObjects vo = Instanciate();
            IProgress ip = vo.GSession.CopyTo(HostPath, VMPath, new CopyFileFlag[] { CopyFileFlag.CopyFileFlag_None });

            ip.WaitForCompletion(-1);
            releaseObjects(vo);
            if (ip.ErrorInfo != null)
            {
                throw new Exception(ip.ErrorInfo.Text);
            }
        }
Exemplo n.º 4
0
        public override void KillVMProcess(string ProcessName)
        {
            VMObjects vo = Instanciate();

            foreach (var proc in vo.GSession.Processes)
            {
                if (proc.Name == ProcessName)
                {
                    proc.Terminate();
                }
            }
            releaseObjects(vo);
        }
Exemplo n.º 5
0
 private void releaseObjects(VMObjects vo)
 {
     try
     {
         vo.GSession.Close();
     }
     catch (Exception)
     {
     }
     if (vo.Session.State == SessionState.SessionState_Locked)
     {
         vo.Session.UnlockMachine();
     }
 }
Exemplo n.º 6
0
        public override void RevertSnapshotVM(string SnapshotName)
        {
            SuspendVM();
            VMObjects vo = Instanciate();
            //vo.Session = new SessionClass();
            //machine.LockMachine(vo.Session, LockType.LockType_Shared);
            //vo.Console = vo.Session.Console;
            var snapshot = machine.FindSnapshot(SnapshotName);
            var prog     = vo.Console.RestoreSnapshot(snapshot);

            prog.WaitForCompletion(100000);
            //vo.Session.UnlockMachine();
            releaseObjects(vo);
        }
Exemplo n.º 7
0
        private VMObjects Instanciate()
        {
            VMObjects vo = new VMObjects();

            vo.Session = new SessionClass();
            machine.LockMachine(vo.Session, LockType.LockType_Shared);
            vo.Console = vo.Session.Console;
            try
            {
                vo.GSession = vo.Console.Guest.CreateSession(username, password, domain, "ViniSandbox");
            }
            catch (Exception)
            {
            }
            return(vo);
        }
Exemplo n.º 8
0
        public override void StartVMProcess(string BinaryPath, string[] args, bool hidden, int timeout, Mutex m)
        {
            VMObjects     vo = Instanciate();
            IGuestProcess ip = null;

            ip = vo.GSession.ProcessCreate(BinaryPath, args, new string[] { }, new ProcessCreateFlag[] { hidden?ProcessCreateFlag.ProcessCreateFlag_Hidden: ProcessCreateFlag.ProcessCreateFlag_None }, (uint)timeout);
            m.ReleaseMutex();
            ip.WaitFor((uint)ProcessWaitForFlag.ProcessWaitForFlag_Terminate, (uint)timeout);
            releaseObjects(vo);

            /*VMObjects vo = Instanciate();
             * var ret = vo.GSession.ProcessCreate(BinaryPath, args, new string[] { }, new ProcessCreateFlag[] { hidden ? ProcessCreateFlag.ProcessCreateFlag_Hidden : ProcessCreateFlag.ProcessCreateFlag_None }, (uint)timeout);
             * m.ReleaseMutex();
             * if(ret.Status == ProcessStatus.ProcessStatus_Started || ret.Status == ProcessStatus.ProcessStatus_Starting)
             *  ret.WaitFor((uint)ProcessWaitForFlag.ProcessWaitForFlag_Terminate, (uint)timeout);
             * releaseObjects(vo);
             * if (ret.Status == ProcessStatus.ProcessStatus_Error)
             *  throw new Exception("Error on start process " + BinaryPath);*/
        }