Exemplo n.º 1
0
        public List <VirtualMachine> listVirtualMachines()
        {
            string [] vms = service.IVirtualBox_getMachines(vboxRef);

            List <VirtualMachine> vmList = new List <VirtualMachine>();

            for (int i = 0; i < vms.Length; i++)
            {
                string name = service.IMachine_getName(vms [i]);
                vmList.Add(new VirtualBoxVirtualMachine(service, vms[i], vboxRef));
                System.Console.WriteLine(i + ": " + vms [i]);
                System.Console.WriteLine(service.IMachine_getState(vms [i]));
                System.Console.WriteLine(name);
            }

            return(vmList);
        }
        public VirtualMachineState getState()
        {
            MachineState ms = service.IMachine_getState(machineRef);

            switch (ms)
            {
            case MachineState.Running:
                return(VirtualMachineState.POWERED_ON);

            case MachineState.PoweredOff:
                return(VirtualMachineState.POWERED_OFF);

            case MachineState.Paused:
                return(VirtualMachineState.SUSPENDED);
            }

            return(VirtualMachineState.UNKNOWN);
        }