summaryrefslogtreecommitdiff
path: root/gnu/services/ganeti.scm
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/services/ganeti.scm')
-rw-r--r--gnu/services/ganeti.scm101
1 files changed, 61 insertions, 40 deletions
diff --git a/gnu/services/ganeti.scm b/gnu/services/ganeti.scm
index 85adbd7362e..f4fec3833e7 100644
--- a/gnu/services/ganeti.scm
+++ b/gnu/services/ganeti.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2020 Marius Bakke <marius@gnu.org>
+;;; Copyright © 2020, 2022 Marius Bakke <marius@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -683,7 +683,8 @@ information to OS install scripts or instances.")))
#~(#$schedule))
((? list?)
#~('#$schedule)))
- #$(ganeti-watcher-command config))))))
+ #$(ganeti-watcher-command config)
+ "ganeti-watcher")))))
(define ganeti-watcher-service-type
(service-type (name 'ganeti-watcher)
@@ -725,7 +726,8 @@ is declared offline by known master candidates.")))
#~('#$master-schedule)))
(lambda ()
(system* #$(file-append ganeti "/sbin/ganeti-cleaner")
- "master")))
+ "master"))
+ "ganeti master cleaner")
#~(job #$@(match node-schedule
((? string?)
#~(#$node-schedule))
@@ -733,7 +735,8 @@ is declared offline by known master candidates.")))
#~('#$node-schedule)))
(lambda ()
(system* #$(file-append ganeti "/sbin/ganeti-cleaner")
- "node")))))))
+ "node"))
+ "ganeti node cleaner")))))
(define ganeti-cleaner-service-type
(service-type (name 'ganeti-cleaner)
@@ -777,6 +780,8 @@ than 21 days from @file{/var/lib/ganeti/queue/archive}.")))
(default (ganeti-cleaner-configuration)))
(file-storage-paths ganeti-configuration-file-storage-paths ;list of strings | gexp
(default '()))
+ (hooks ganeti-configuration-hooks ;<file-like> | #f
+ (default #f))
(os ganeti-configuration-os ;list of <ganeti-os>
(default '())))
@@ -819,8 +824,9 @@ than 21 days from @file{/var/lib/ganeti/queue/archive}.")))
(define-record-type* <ganeti-os>
ganeti-os make-ganeti-os ganeti-os?
(name ganeti-os-name) ;string
- (extension ganeti-os-extension) ;string
- (variants ganeti-os-variants ;list of <ganeti-os-variant>
+ (extension ganeti-os-extension ;#f | string
+ (default #f))
+ (variants ganeti-os-variants ;<file-like> | list of <ganeti-os-variant>
(default '())))
(define-record-type* <ganeti-os-variant>
@@ -909,7 +915,7 @@ trap - EXIT
(partition-alignment debootstrap-configuration-partition-alignment ;#f | integer
(default 2048)))
-(define (hooks->directory hooks)
+(define (debootstrap-hooks->directory hooks)
(match hooks
((? file-like?)
hooks)
@@ -917,7 +923,7 @@ trap - EXIT
(let ((names (map car hooks))
(files (map cdr hooks)))
(with-imported-modules '((guix build utils))
- (computed-file "hooks-union"
+ (computed-file "debootstrap-hooks"
#~(begin
(use-modules (guix build utils)
(ice-9 match))
@@ -941,7 +947,7 @@ trap - EXIT
(($ <debootstrap-configuration> hooks proxy mirror arch suite extra-pkgs
components generate-cache? clean-cache
partition-style partition-alignment)
- (let ((customize-dir (hooks->directory hooks)))
+ (let ((customize-dir (debootstrap-hooks->directory hooks)))
(gexp->derivation
"debootstrap-variant"
#~(call-with-output-file (ungexp output "out")
@@ -992,37 +998,48 @@ trap - EXIT
(define (ganeti-os->directory os)
"Return the derivation to build the configuration directory to be installed
in /etc/ganeti/instance-$os for OS."
- (let* ((name (ganeti-os-name os))
- (extension (ganeti-os-extension os))
- (variants (ganeti-os-variants os))
- (names (map ganeti-os-variant-name variants))
- (configs (map ganeti-os-variant-configuration variants)))
- (with-imported-modules '((guix build utils))
- (define builder
- #~(begin
- (use-modules (guix build utils)
- (ice-9 format)
- (ice-9 match)
- (srfi srfi-1))
- (mkdir-p #$output)
- (unless (null? '#$names)
- (let ((variants-dir (string-append #$output "/variants")))
- (mkdir-p variants-dir)
- (call-with-output-file (string-append variants-dir "/variants.list")
- (lambda (port)
- (format port "~a~%"
- (string-join '#$names "\n"))))
- (for-each (match-lambda
- ((name file)
- (symlink file
- (string-append variants-dir "/" name
- #$extension))))
-
- '#$(zip names configs))))))
-
- (computed-file (string-append name "-os") builder))))
-
-(define (ganeti-directory file-storage-file os)
+ (let ((name (ganeti-os-name os))
+ (extension (ganeti-os-extension os))
+ (variants (ganeti-os-variants os)))
+ (define builder
+ (with-imported-modules '((guix build utils))
+ (if (file-like? variants)
+ #~(begin
+ (use-modules (guix build utils))
+ (mkdir-p #$output)
+ (symlink #$variants
+ (string-append #$output "/variants")))
+ #~(begin
+ (use-modules (guix build utils)
+ (ice-9 format)
+ (ice-9 match)
+ (srfi srfi-1))
+ (mkdir-p #$output)
+ (let ((variants-dir (string-append #$output "/variants"))
+ (names '#$(map ganeti-os-variant-name variants))
+ (configs '#$(map ganeti-os-variant-configuration variants)))
+ (mkdir-p variants-dir)
+ (unless (null? names)
+ (call-with-output-file (string-append variants-dir
+ "/variants.list")
+ (lambda (port)
+ (format port "~a~%"
+ (string-join names "\n"))))
+ (for-each (match-lambda
+ ((name file)
+ (let ((file-name
+ (if #$extension
+ (string-append name #$extension)
+ name)))
+ (symlink file
+ (string-append variants-dir "/"
+ file-name)))))
+ (zip names configs))))))))
+
+ (computed-file (string-append name "-os") builder
+ #:local-build? #t)))
+
+(define (ganeti-directory file-storage-file hooks os)
(let ((dirs (map ganeti-os->directory os))
(names (map ganeti-os-name os)))
(define builder
@@ -1032,6 +1049,9 @@ in /etc/ganeti/instance-$os for OS."
(when #$file-storage-file
(symlink #$file-storage-file
(string-append #$output "/file-storage-paths")))
+ (when #$hooks
+ (symlink #$hooks
+ (string-append #$output "/hooks")))
(for-each (match-lambda
((name dest)
(symlink dest
@@ -1051,6 +1071,7 @@ in /etc/ganeti/instance-$os for OS."
(list `("ganeti" ,(ganeti-directory
(file-storage-file
(ganeti-configuration-file-storage-paths config))
+ (ganeti-configuration-hooks config)
(ganeti-configuration-os config)))))
(define (debootstrap-os variants)