2 * Copyright (C) 2014-2015 Red Hat Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 (* Implement 'mclu console'. *)
25 let get_arg_speclist () = []
27 let console ~verbose ?host name =
28 let nodes = Mclu_conf.nodes () in
32 (try List.find (fun n -> host = n.Mclu_conf.hostname) nodes
34 eprintf "mclu: host '%s' not found\n" host;
37 (* No 'host:' prefix given, so we need to find the host. *)
38 let guests = Mclu_list.active_guests ~verbose ~nodes () in
45 name = dom.Mclu_list.dom_name
50 eprintf "mclu: guest '%s' not found\n" name;
54 let uri = node.Mclu_conf.libvirt_uri in
56 let cmd = sprintf "virsh -c %s console %s" (quote uri) (quote name) in
57 if verbose then printf "%s\n%!" cmd;
58 if Sys.command cmd <> 0 then (
59 eprintf "mclu: %s: command failed\n" cmd;
63 let run ~verbose = function
65 let host, name = name_parse name in
66 console ~verbose ?host name
68 eprintf "Usage: mclu boot <template> <[host:]name>\n";