aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2022-07-23 13:30:46 -0700
committerSean Whitton <spwhitton@spwhitton.name>2022-07-23 16:40:16 -0700
commitd356d175f5ee9a844816cb593ec8f1fe7ceee2f0 (patch)
tree0d97edce3486107a636c584762f0bf3fcad5f319
parent0f547668a92025fe0741a9dfcf5abfc84e6ba9f9 (diff)
downloadconsfigurator-d356d175f5ee9a844816cb593ec8f1fe7ceee2f0.tar.gz
factor out DISK::HOST-VOLUMES-JUST-ONE-PHYSICAL-DISK
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r--src/property/disk.lisp36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/property/disk.lisp b/src/property/disk.lisp
index ab9b6f3..980c268 100644
--- a/src/property/disk.lisp
+++ b/src/property/disk.lisp
@@ -915,6 +915,21 @@ the LVM physical volumes corresponding to those volume groups."
(ensure-directory-pathname
(strcat (unix-namestring image-pathname) ".chroot")))
+(defun host-volumes-just-one-physical-disk (host fun)
+ (loop
+ with found
+ for volume in (get-hostattrs :volumes (preprocess-host host))
+ for physical-disk-p = (subtypep (type-of volume) 'physical-disk)
+ if (and physical-disk-p (not found) (slot-boundp volume 'volume-contents))
+ do (setq found t)
+ and collect (aprog1 (copy-volume-and-contents volume) (funcall fun it))
+ else unless physical-disk-p
+ collect volume
+ finally
+ (unless found
+ (inapplicable-property
+ "Volumes list for host has no DISK:PHYSICAL-DISK with contents."))))
+
(defpropspec raw-image-built-for :lisp
(options host image-pathname &key rebuild)
"Build a raw disk image for HOST at IMAGE-PATHNAME.
@@ -941,23 +956,10 @@ of the host's volumes changes, although the contents of the image's
filesystems will be incrementally updated when other properties change."
(:desc #?"Built image for ${(get-hostname host)} @ ${image-pathname}")
(let ((chroot (image-chroot image-pathname))
- (volumes
- (loop
- with found
- for volume in (get-hostattrs :volumes (preprocess-host host))
- for physical-disk-p = (subtypep (type-of volume) 'physical-disk)
- if (and physical-disk-p (not found)
- (slot-boundp volume 'volume-contents))
- do (setq found t)
- and collect (aprog1 (copy-volume-and-contents volume)
- (change-class it 'raw-disk-image)
- (setf (image-file it) image-pathname))
- else unless physical-disk-p
- collect volume
- finally
- (unless found
- (inapplicable-property
- "Volumes list for host has no DISK:PHYSICAL-DISK with contents.")))))
+ (volumes (host-volumes-just-one-physical-disk
+ host (lambda (volume)
+ (change-class volume 'raw-disk-image)
+ (setf (image-file volume) image-pathname)))))
`(on-change (eseqprops
,(propapp (chroot:os-bootstrapped-for. options chroot host
(caches-cleaned)))