TITLE: Extensions of number fields which are unramified at all finite primes
QUESTION [5 upvotes]: Let $k$ be a totally real number field of degree $n$. 
I'd like to know how I can determine whether or not there exists a quadratic field extension $L$ of $k$ such that the extension $L/k$ is unramified at all finite primes and ramified at only at $n-1$ of the real primes of $k$. I assume that this can be determined by class field theory. For the application that I have in mind however, I'm going to need a computer algebra system like sage to be able to explicitly perform this test. How explicit can this be made?
Thanks.

REPLY [4 votes]: In pari/gp (probably built into sage somehow).
poly=x^7 - x^6 - 12*x^5 + 7*x^4 + 28*x^3 - 14*x^2 - 9*x - 1;
/* The roots of this polynomial define the degree 7 subfield K of Q(zeta_29).
*/
nf=nfinit(poly); /* This defines the number field K */
bnf=bnfinit(nf); /* This computes data associated to the number field K, like the unit group.*/
bnfcertify(bnf) /* This checks that the output of bnf is correct, and doesn't depend on GRH. The output should be $1$ */
bnrclass(bnf,[1,[1,1,1,1,1,1,0]]) /* This computes the ray class group of conductor m, where m has trivial finite place and contains 6 of the 7 infinite places. */