예제 #1
0
        /// <summary>
        /// Starts the named virtual machine.
        /// </summary>
        /// <param name="machineName">The machine name.</param>
        public void StartVm(string machineName)
        {
            if (isAdmin)
            {
                hypervClient.StartVm(machineName: machineName);
            }
            else
            {
                var request = new GrpcStartVmRequest(machineName: machineName);
                var reply   = desktopService.StartVmAsync(request).Result;

                reply.Error.EnsureSuccess();
            }
        }
예제 #2
0
        /// <inheritdoc/>
        public async Task <GrpcBaseReply> StartVmAsync(GrpcStartVmRequest request, CallContext context = default)
        {
            await SyncContext.Clear;

            try
            {
                hyperv.StartVm(machineName: request.MachineName);

                return(new GrpcBaseReply());
            }
            catch (Exception e)
            {
                return(new GrpcBaseReply(e));
            }
        }