Ejemplo n.º 1
0
        /// <summary>
        /// Removes a named virtual machine and all of its drives (by default).
        /// </summary>
        /// <param name="machineName">The machine name.</param>
        /// <param name="keepDrives">Optionally retains the VM disk files.</param>
        public void RemoveVm(string machineName, bool keepDrives = false)
        {
            if (isAdmin)
            {
                hypervClient.RemoveVm(machineName: machineName, keepDrives: keepDrives);
            }
            else
            {
                var request = new GrpcRemoveVmRequest(machineName: machineName, keepDrives: keepDrives);

                desktopService.RemoveVmAsync(request).Result.Error.EnsureSuccess();
            }
        }
Ejemplo n.º 2
0
        /// <inheritdoc/>
        public async Task <GrpcBaseReply> RemoveVmAsync(GrpcRemoveVmRequest request, CallContext context = default)
        {
            await SyncContext.Clear;

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

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