private async Task<VmState> GetVmStateFromInstance(VirtualMachine vm)
 {
     var powerState = vm.InstanceView?.Statuses.FirstOrDefault(s => s.Code.StartsWith("PowerState/"));
     var state = new VmState
     {
         Id = vm.Id,
         Name = vm.Name,
         State = powerState == null ? "Unknown" : powerState.DisplayStatus,
     };
     var snapshotState = await GetSnapshotStateForVm(vm);
     snapshotState.Snapshots.ForEach(s => state.Snapshots.Add(s));
     return state;
 }
예제 #2
0
        private async Task <VmState> GetVmStateFromInstance(VirtualMachine vm)
        {
            var powerState = vm.InstanceView?.Statuses.FirstOrDefault(s => s.Code.StartsWith("PowerState/"));
            var state      = new VmState
            {
                Id    = vm.Id,
                Name  = vm.Name,
                State = powerState == null ? "Unknown" : powerState.DisplayStatus,
            };
            var snapshotState = await GetSnapshotStateForVm(vm);

            snapshotState.Snapshots.ForEach(s => state.Snapshots.Add(s));
            return(state);
        }