Exemplo n.º 1
0
        /// <inheritdoc/>
        public async Task <GrpcGetVmReply> GetVmAsync(GrpcGetVmRequest request, CallContext context = default)
        {
            await SyncContext.Clear;

            try
            {
                return(new GrpcGetVmReply(machine: hyperv.GetVm(request.MachineName).ToProto()));
            }
            catch (Exception e)
            {
                return(new GrpcGetVmReply(e));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the current status for a named virtual machine.
        /// </summary>
        /// <param name="machineName">The machine name.</param>
        /// <returns>The <see cref="VirtualMachine"/> or <c>null</c> when the virtual machine doesn't exist..</returns>
        public VirtualMachine GetVm(string machineName)
        {
            if (isAdmin)
            {
                return(hypervClient.GetVm(machineName: machineName));
            }
            else
            {
                var request = new GrpcGetVmRequest(machineName: machineName);
                var reply   = desktopService.GetVmAsync(request).Result;

                reply.Error.EnsureSuccess();

                return(reply.Machine.ToLocal());
            }
        }