Exemple #1
0
        /// <inheritdoc/>
        public async Task <GrpcListVmsReply> ListVmsAsync(GrpcListVmsRequest request, CallContext context = default)
        {
            await SyncContext.Clear;

            try
            {
                return(new GrpcListVmsReply(virtualMachines: hyperv.ListVms().Select(vm => vm.ToProto()).ToList()));
            }
            catch (Exception e)
            {
                return(new GrpcListVmsReply(e));
            }
        }
Exemple #2
0
        /// <summary>
        /// Lists the virtual machines.
        /// </summary>
        /// <returns><see cref="IEnumerable{VirtualMachine}"/>.</returns>
        public IEnumerable <VirtualMachine> ListVms()
        {
            if (isAdmin)
            {
                return(hypervClient.ListVms());
            }
            else
            {
                var request = new GrpcListVmsRequest();
                var reply   = desktopService.ListVmsAsync(request).Result;

                reply.Error.EnsureSuccess();

                return(reply.VirtualMachines.Select(vm => vm.ToLocal()));
            }
        }