From ce0508b14feb969555e8f8ecb1c2a7e6a3d48339 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 29 May 2021 15:25:30 -0700 Subject: add LIBVIRT:STARTED Signed-off-by: Sean Whitton --- src/package.lisp | 3 ++- src/property/libvirt.lisp | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/package.lisp b/src/package.lisp index 90f5608..471a683 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -556,7 +556,8 @@ (:export #:installed #:default-network-started #:default-network-autostarted - #:defined)) + #:defined + #:started)) (defpackage :consfigurator.connection.local (:use #:cl #:consfigurator #:alexandria) diff --git a/src/property/libvirt.lisp b/src/property/libvirt.lisp index d2de264..0617e46 100644 --- a/src/property/libvirt.lisp +++ b/src/property/libvirt.lisp @@ -93,6 +93,19 @@ subcommand of virsh(1) to convert the running domain into a transient domain." (declare (ignore arguments)) (mrun "virsh" "undefine" (get-hostname host)))) +(defprop started :posix (host) + "Ensure the libvirt domain for the host designated by HOST is started. +(I.e., if HOST is a string, ensure the domain named HOST is started; if HOST +is a HOST value, start the libvirt domain whose name is HOST's hostname.)" + (:desc #?"libvirt domain ${(get-hostname host)} started") + (:check + ;; The "State" column in the output of 'virsh list' is to be ignored here; + ;; 'virsh start' will do nothing if the VM appears at all in the output of + ;; 'virsh list'. + (member (get-hostname host) (mapcar #'cadr (virsh-get-columns "list")) + :test #'string=)) + (:apply (mrun "virsh" "start" (get-hostname host)))) + (defun virsh-get-columns (&rest arguments) "Run a virsh command that is expected to yield tabular output, with the given list of ARGUMENTS, and return the rows." -- cgit v1.2.3