summaryrefslogtreecommitdiff
path: root/tests/machine/hetzner/http.scm
diff options
context:
space:
mode:
authorSergey Trofimov <sarg@sarg.org.ru>2025-04-18 17:08:08 +0200
committerLudovic Courtès <ludo@gnu.org>2025-04-21 23:55:50 +0200
commit7a4193ec4a09fecc68dc726c1e0bbb5ad03d404a (patch)
treedbb9740caaf85b85bc39c6b333b01c3609a4507e /tests/machine/hetzner/http.scm
parent5f1ee7ba730b5e2c0bb4b33878d0462dd22d2eb6 (diff)
machine: hetzner: Allow attaching existing public IPs.
* gnu/machine/hetzner.scm (hetzner-configuration): Add ipv4 and ipv6 fields. Export accessors. * gnu/machine/hetzner/http.scm (hetnzer-api-primary-ips): New function. (<hetzner-primary-ip>): New json mapping. (hetzner-api-server-create): Pass IP addresses in request. * doc/guix.texi (Invoking guix deploy): Document it. Change-Id: I44509cc98e041762dc483e876566e79bde85b26a Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'tests/machine/hetzner/http.scm')
-rw-r--r--tests/machine/hetzner/http.scm38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/machine/hetzner/http.scm b/tests/machine/hetzner/http.scm
index 618d9a4c94e..6c6d848a578 100644
--- a/tests/machine/hetzner/http.scm
+++ b/tests/machine/hetzner/http.scm
@@ -239,6 +239,30 @@
239 ("status" . "running") 239 ("status" . "running")
240 ("volumes" . #()))) 240 ("volumes" . #())))
241 241
242(define primary-ip
243 (make-hetzner-primary-ip
244 #(55 2 19 28 9 123 6 300 -1 0 #f)
245 42
246 "131.232.99.1"
247 '()
248 "static-ip"
249 "ipv4"))
250
251(define primary-ip-alist
252 `(("created" . "2023-10-28T19:02:55+00:00")
253 ("id" . 42)
254 ("labels")
255 ("name" . "static-ip")
256 ("blocked" . #f)
257 ("ip" . "131.232.99.1")
258 ("datacenter")
259 ("dns_ptr")
260 ("protection" . (("delete" . #f)))
261 ("type" . "ipv4")
262 ("auto_delete" . #t)
263 ("assignee_type" . "server")
264 ("assignee_id" . 17)))
265
242(define ssh-key-root 266(define ssh-key-root
243 (make-hetzner-ssh-key 267 (make-hetzner-ssh-key
244 #(55 2 19 28 9 123 6 300 -1 0 #f) 268 #(55 2 19 28 9 123 6 300 -1 0 #f)
@@ -512,6 +536,20 @@
512 ("ssh_keys" . #(,ssh-key-root-alist))))))) 536 ("ssh_keys" . #(,ssh-key-root-alist)))))))
513 (hetzner-api-ssh-keys (hetzner-api)))) 537 (hetzner-api-ssh-keys (hetzner-api))))
514 538
539(test-equal "hetzner-api-primary-ips-unit"
540 (list primary-ip)
541 (mock ((gnu machine hetzner http) hetzner-api-request-send
542 (lambda* (request #:key expected)
543 (assert (equal? 'GET (hetzner-api-request-method request)))
544 (assert (equal? "https://api.hetzner.cloud/v1/primary_ips"
545 (hetzner-api-request-url request)))
546 (assert (unspecified? (hetzner-api-request-body request)))
547 (assert (equal? '(("page" . 1)) (hetzner-api-request-params request)))
548 (hetzner-api-response
549 (body `(("meta" . ,meta-page-alist)
550 ("primary_ips" . #(,primary-ip-alist)))))))
551 (hetzner-api-primary-ips (hetzner-api))))
552
515;; Integration tests 553;; Integration tests
516 554
517(test-skip %when-no-token) 555(test-skip %when-no-token)