/// <summary> /// Removes a named virtual switch, it it exists as well as any associated NAT (with the same name). /// </summary> /// <param name="switchName">The target switch name.</param> /// <param name="ignoreMissing">Optionally ignore missing items.</param> public void RemoveSwitch(string switchName, bool ignoreMissing = false) { if (isAdmin) { hypervClient.RemoveSwitch(switchName: switchName, ignoreMissing: ignoreMissing); } else { var request = new GrpcRemoveSwitchRequest(switchName: switchName, ignoreMissing: ignoreMissing); var reply = desktopService.RemoveSwitchAsync(request).Result; reply.Error.EnsureSuccess(); } }
/// <inheritdoc/> public async Task <GrpcBaseReply> RemoveSwitchAsync(GrpcRemoveSwitchRequest request, CallContext context = default) { await SyncContext.Clear; try { hyperv.RemoveSwitch(switchName: request.SwitchName, ignoreMissing: request.IgnoreMissing ?? false); return(new GrpcBaseReply()); } catch (Exception e) { return(new GrpcBaseReply(e)); } }