-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzookeeper.spec
27 lines (22 loc) · 965 Bytes
/
zookeeper.spec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
(import "labels")
(import "strings")
(import "log")
(define image "quilt/zookeeper")
// generates a list of "prefix-(0 + offset)" to "prefix-(n + offset - 1)"
(define (RangeWithOffset prefix n offset)
(map (lambda (i) (sprintf "%s-%d" prefix (+ i offset))) (range n)))
// generates a list of integers (that are strings) from offset to n - 1
(define (RangeWithOffsetNoPrefix n offset)
(map (lambda (i) (sprintf "%d" (+ i offset))) (range n)))
(define (create prefix n)
(let ((labelNames (RangeWithOffset prefix n 1))
// XXX labels.StrToHostname breaks abstraction
(zooHosts (strings.Join (map labels.StrToHostname labelNames) ","))
(zooDockers (RangeWithOffsetNoPrefix n 1))
(mapMyId (lambda (id) (docker image id zooHosts)))
(zooDockers (map mapMyId zooDockers)))
(map label labelNames zooDockers)))
(define (New prefix n)
(let ((zoos (create prefix n)))
(connect (list 1000 65535) zoos zoos)
zoos))