aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-05-29 15:25:30 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-05-30 10:03:03 -0700
commitce0508b14feb969555e8f8ecb1c2a7e6a3d48339 (patch)
tree4274b4c5da07fc58776eba2284af7ae8e11b2058
parentedbba484918f6de83680a5b29e561fba981e05e9 (diff)
downloadconsfigurator-ce0508b14feb969555e8f8ecb1c2a7e6a3d48339.tar.gz
add LIBVIRT:STARTED
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r--src/package.lisp3
-rw-r--r--src/property/libvirt.lisp13
2 files changed, 15 insertions, 1 deletions
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."