aboutsummaryrefslogtreecommitdiff
path: root/src/deployment.lisp
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-07-02 12:40:54 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-07-06 21:19:39 -0700
commit2ec9cea43c46854dd36e0cf9ba0b0d42d428a286 (patch)
tree74c2b6e256aac883eae9ffde58fcd5aaa76d6f48 /src/deployment.lisp
parent2259c1e367b0bf35825f77adac34f796b027c295 (diff)
downloadconsfigurator-2ec9cea43c46854dd36e0cf9ba0b0d42d428a286.tar.gz
add AT-END, REBOOT:REBOOTED-AT-END
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/deployment.lisp')
-rw-r--r--src/deployment.lisp28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/deployment.lisp b/src/deployment.lisp
index 68acdd0..ce4fb95 100644
--- a/src/deployment.lisp
+++ b/src/deployment.lisp
@@ -20,7 +20,21 @@
;;;; Deployments
-(defun %consfigure (connections host)
+(defparameter *at-end-functions* nil)
+
+(defun at-end (function)
+ "Request that FUNCTION be called at the end of the current (sub)deployment.
+Called by property :APPLY and :UNAPPLY subroutines. FUNCTION will be passed a
+single argument representing whether or not the deployment made a change.
+
+Properties which call this are responsible for ensuring that the I/O performed
+by FUNCTION is compatible with the connection type. This amounts to the
+following requirement: if FUNCTION performs I/O beyond what :POSIX property
+:APPLY subroutines are permitted to perform, the property calling AT-END to
+register FUNCTION must be declared to be a :LISP property."
+ (push (ensure-function function) *at-end-functions*))
+
+(defun %consfigure (connections host &key (collect-at-end t))
"Consfigurator's primary loop, recursively binding *CONNECTION* and *HOST*.
Assumes arguments to connections in CONNECTIONS have been both normalised and
@@ -29,7 +43,12 @@ preprocessed."
((apply-*host*-propspec ()
(let ((propapp (eval-propspec (host-propspec *host*))))
(assert-connection-supports (propapptype propapp))
- (propappapply propapp)))
+ (if collect-at-end
+ (let (*at-end-functions*)
+ (let ((result (propappapply propapp)))
+ (dolist (function *at-end-functions* result)
+ (funcall function result))))
+ (propappapply propapp))))
(connect (connections)
(destructuring-bind ((type . args) . remaining) connections
;; implementations of ESTABLISH-CONNECTION which call
@@ -53,7 +72,7 @@ preprocessed."
(t
(connect '((:local))))))))
-(defun consfigure (propspec-expression)
+(defun consfigure (propspec-expression &key collect-at-end)
"Immediately preprocess and apply PROPSPEC-EXPRESSION in the context of the
current target host and connection. This function is provided for use by
specialised property combinators. It should not be used in property
@@ -69,7 +88,8 @@ will not be discarded."
nil (make-host
:hostattrs (hostattrs *host*)
:propspec (with-*host*-*consfig*
- (make-propspec :propspec propspec-expression)))))
+ (make-propspec :propspec propspec-expression)))
+ :collect-at-end collect-at-end))
(defmacro with-deployment-report (&rest forms)
(with-gensyms (failures)