Exemple #1
0
        public void CleanUp()
        {
            if (usedMachines.Count > 0)
            {
                foreach (IMachine machine in provider.GetMachines())
                {
                    if (usedMachines.Contains(machine.Id))
                    {
                        // Revert to initial snapshot
                        string ssId = GetInitSnapshotId(machine);
                        if (ssId != null)
                        {
                            machine.Start(ssId);
                        }

                        // Remove the junk from our trunk
                        ssFunc.CleanupSnapshots();

                        // Shutdown VM
                        machine.Shutdown();
                    }
                }

                usedMachines.Clear();
            }
        }
Exemple #2
0
        IMachine GetMachine(string nameOrId)
        {
            // Search for machine by id:
            IEnumerable <IMachine> machines =
                provider.GetMachines().Where(m => m.Id == nameOrId);

            if (machines.Any())
            {
                return(machines.First());
            }

            machines = provider.GetMachines().Where(m => m.Name == nameOrId);

            if (machines.Any())
            {
                return(machines.First());
            }

            throw new Exception("Unable to find machine for string: " + nameOrId);
        }