From: Richard W.M. Jones Date: Sat, 21 Mar 2015 23:06:50 +0000 (+0000) Subject: Implement 'mclu reboot' command for rebooting guests. X-Git-Url: http://git.annexia.org/?p=mclu.git;a=commitdiff_plain;h=21746ef0144c70168d5fb424ed086bf641412853 Implement 'mclu reboot' command for rebooting guests. --- diff --git a/Makefile.am b/Makefile.am index 0107cf0..329e29b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -32,6 +32,7 @@ SOURCES_MLI = \ mclu_destroy.mli \ mclu_list.mli \ mclu_onoff.mli \ + mclu_reboot.mli \ mclu_status.mli \ mclu_viewer.mli \ parallel.mli \ @@ -50,6 +51,7 @@ SOURCES_ML = \ mclu_onoff.ml \ mclu_boot.ml \ mclu_destroy.ml \ + mclu_reboot.ml \ mclu_console.ml \ mclu_viewer.ml \ mclu.ml diff --git a/mclu.ml b/mclu.ml index ff8103b..a6e6e1d 100644 --- a/mclu.ml +++ b/mclu.ml @@ -67,6 +67,9 @@ let anon_fun, get_anon_args = | "on" -> speclist := Mclu_onoff.get_arg_speclist (); subcommand_run := Mclu_onoff.run ~on:true + | "reboot" -> + speclist := Mclu_reboot.get_arg_speclist (); + subcommand_run := Mclu_reboot.run | "status" -> speclist := Mclu_status.get_arg_speclist (); subcommand_run := Mclu_status.run diff --git a/mclu.pod b/mclu.pod index 45b9bd5..3817afd 100644 --- a/mclu.pod +++ b/mclu.pod @@ -129,6 +129,10 @@ for each host: host0 mac=11:22:33:44:55:66 host1 mac=11:22:33:44:55:67 +=item B + +Reboot the guest. + =item B Display the status of the cloud. This shows you which nodes are on diff --git a/mclu_reboot.ml b/mclu_reboot.ml new file mode 100644 index 0000000..6b86916 --- /dev/null +++ b/mclu_reboot.ml @@ -0,0 +1,42 @@ +(* mclu: Mini Cloud + * Copyright (C) 2014-2015 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *) + +(* Implement 'mclu reboot'. *) + +open Printf + +open Utils + +let get_arg_speclist () = [] + +let reboot ~verbose ?host name = + let node, name = Mclu_list.find_guest ~verbose name in + let uri = node.Mclu_conf.libvirt_uri in + + let cmd = sprintf "virsh -c %s reboot %s" (quote uri) (quote name) in + if verbose then printf "%s\n%!" cmd; + if Sys.command cmd <> 0 then ( + eprintf "mclu: %s: command failed\n" cmd; + exit 1 + ) + +let run ~verbose = function + | [ name ] -> reboot ~verbose name + | _ -> + eprintf "Usage: mclu reboot <[host:]name>\n"; + exit 1 diff --git a/mclu_reboot.mli b/mclu_reboot.mli new file mode 100644 index 0000000..46ae35e --- /dev/null +++ b/mclu_reboot.mli @@ -0,0 +1,21 @@ +(* mclu: Mini Cloud + * Copyright (C) 2014-2015 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *) + +val get_arg_speclist : unit -> (Arg.key * Arg.spec * Arg.doc) list + +val run : verbose:bool -> string list -> unit