示例#1
0
        /// <inheritdoc/>
        public async Task <GrpcVmExistsReply> VmExistsAsync(GrpcVmExistsRequest request, CallContext context = default)
        {
            await SyncContext.Clear;

            try
            {
                return(new GrpcVmExistsReply(hyperv.VmExists(request.MachineName)));
            }
            catch (Exception e)
            {
                return(new GrpcVmExistsReply(e));
            }
        }
示例#2
0
        /// <summary>
        /// Determines whether a named virtual machine exists.
        /// </summary>
        /// <param name="machineName">The machine name.</param>
        /// <returns><c>true</c> if the machine exists.</returns>
        public bool VmExists(string machineName)
        {
            if (isAdmin)
            {
                return(hypervClient.VmExists(machineName: machineName));
            }
            else
            {
                var request = new GrpcVmExistsRequest(machineName: machineName);
                var reply   = desktopService.VmExistsAsync(request).Result;

                reply.Error.EnsureSuccess();

                return(reply.Exists);
            }
        }