X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=mclu_list.ml;h=f685f54e8fbeafe31df3f1ac44ebd52e6635abdc;hb=a5c81badfee011ff1f7c22e83a5ecb8e7b4f87d1;hp=3534066c6d0c4947e8e26cc1a4576a364f026822;hpb=b29a837444aa5827b683bee5a7457fbb32305ae5;p=mclu.git diff --git a/mclu_list.ml b/mclu_list.ml index 3534066..f685f54 100644 --- a/mclu_list.ml +++ b/mclu_list.ml @@ -74,6 +74,31 @@ let active_guests ?(verbose = false) ?(nodes = Mclu_conf.nodes ()) () = ) nodes in List.map (fun s -> Marshal.from_bytes s 0) active_guests +let find_guest ?verbose ?(nodes = Mclu_conf.nodes ()) name = + let host, name = name_parse name in + let node = + match host with + | Some host -> + (try List.find (fun n -> host = n.Mclu_conf.hostname) nodes + with Not_found -> + eprintf "mclu: host '%s' not found\n" host; + exit 1) + | None -> + (* No 'host:' prefix given, so we need to find the host. *) + let guests = active_guests ?verbose ~nodes () in + let node, _ = + try + List.find ( + fun (node, doms) -> + List.exists (fun dom -> name = dom.dom_name) doms + ) guests + with + Not_found -> + eprintf "mclu: guest '%s' not found\n" name; + exit 1 in + node in + node, name + let list ~verbose () = let list_what = !list_what in