示例#1
0
        /// <summary>
        /// Ejects any DVD/CD that's currently inserted into a virtual machine.
        /// </summary>
        /// <param name="machineName">The machine name.</param>
        public void EjectVmDvd(string machineName)
        {
            if (isAdmin)
            {
                hypervClient.EjectVmDvd(machineName: machineName);
            }
            else
            {
                var request = new GrpcEjectVmDvdRequest(machineName: machineName);
                var reply   = desktopService.EjectVmDvdAsync(request).Result;

                reply.Error.EnsureSuccess();
            }
        }
示例#2
0
        /// <inheritdoc/>
        public async Task <GrpcBaseReply> EjectVmDvdAsync(GrpcEjectVmDvdRequest request, CallContext context = default)
        {
            await SyncContext.Clear;

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

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