Skip to content

Instantly share code, notes, and snippets.

(defn mount-shared-folder
"Mount a shared folder in vmware."
[request]
(-> request
(directory/directory "/Users/David" :owner "david")
(exec-script/exec-script
(defvar uid @(id "-u" "david"))
(defvar gid @(id "-g" "david"))
(if (!= 0 @(mountpoint -q "/Users/David"))
(sudo mount "-t" vboxsf "-o"
java.lang.String cannot be cast to clojure.lang.IFn
[Thrown class java.lang.ClassCastException]
Restarts:
0: [QUIT] Quit to the SLIME top level
1: [ABORT] ABORT to SLIME level 0
Backtrace:
0: pallet.compute.vmfest$image_from_template.invoke(vmfest.clj:245)
1: pallet.compute.vmfest.VmfestService.run_nodes(vmfest.clj:301)
java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: java.lang.AssertionError: Assert failed: (instance? IMedium medium)
[Thrown class java.lang.RuntimeException]
Restarts:
0: [QUIT] Quit to the SLIME top level
1: [CAUSE1] Invoke debugger on cause java.util.concurrent.ExecutionException: java.lang.AssertionError: Assert failed: (instance? IMedium medium) [Thrown class java.util.concurrent.ExecutionException]
2: [CAUSE2] Invoke debugger on cause java.lang.AssertionError: Assert failed: (instance? IMedium medium) [Thrown class java.util.concurrent.ExecutionException]
3: [CAUSE3] Invoke debugger on cause Assert failed: (instance? IMedium medium) [Thrown class java.lang.AssertionError]
Backtrace:
clj-html
"Elapsed time: 13.81 msecs"
"Elapsed time: 12.244 msecs"
"Elapsed time: 18.233 msecs"
hiccup
"Elapsed time: 5.397 msecs"
"Elapsed time: 3.905 msecs"
"Elapsed time: 3.058 msecs"
hiccup (type-hint)
"Elapsed time: 4.597 msecs"
David-Santiagos-Computer:servlet David$ cake pallet nodes -- -P virtualbox
INFO jclouds - extensions (:log4j :ssh)
David-Santiagos-Computer:servlet David$ cake pallet lift com.battletheory.deploy.nodes/server :deploy @dev -- -P virtualbox
INFO jclouds - extensions (:log4j :ssh)
INFO core - retrieving nodes
INFO core - apply-phase :pre-deploy for :server with 0 nodes
INFO core - apply-phase :deploy for :server with 0 nodes
INFO core - apply-phase :after-deploy for :server with 0 nodes
;; When the wrap! is as below, the admin functions are properly wrapped, but the
;; site functions will error 500 with an NPE on session.clj:47. If I comment it and
;; uncomment the wrap! at the bottom, then the site URLs will work, but the admin
;; functions will not successfully log in, despite having the form parameters and
;; session in apparently the correct place. In fact, the post request to login is
;; identical in both cases, but it will only work if the code is as below.
;;
;; Ideally, I'd like to be able to break my routes into manageable chunks, compose
;; them, and then just wrap! once. In my reading of the source, I thought routes
;; were just functions that take a request and return a response, so shouldn't
(defn maven-artifact
"Copy a jar to a filesystem location from a maven repo. Artifacts are a sequence
consisting of group, artifact, and version. Doesn't support SNAPSHOTS right now."
[request dir-path maven-repo-url artifacts]
(let [[group artifact version] (first artifacts)]
(if (not (and group artifact version))
;; Ran out of artifacts, return the request.
request
(let [file-name (str artifact "-" version ".jar")
group-path (join "/" (split group #"\."))
;; My two attempts. The first is to make create-database ignore the error return
;; with chain-or. I can't get anything to compile here. Have tried with/without
;; stevedore/script, with/without ~(apply...).
;; Second attempt: ensure-database-exists function. Uses a defscript. This will
;; output the if statement desired, but at a seemingly random place earlier in the
;; script unrelated to the conditional. It will also not escape as-user or db-name,
;; although it will escape the (format ...).
(defn create-database
(defn ensure-database-exists
[request db-name & rest]
(-> request
(resource-when/resource-when
(= 0 @(psql "-t -c"
~(format "\"select count(1) from pg_database where datname='%s'\""
db-name)))
(apply create-database request db-name rest))))
;; Throws a stack trace complaining about too many args (5) to PersistentHashMap.
2010-10-29 22:17:05,273 INFO [pallet.core] (Thread-1) apply-phase :after-configure for :the-server with 1 nodes
2010-10-29 22:19:25,130 DEBUG [pallet.main-invoker] (Thread-1) OS Mac OS X 10.6.4
2010-10-29 22:19:25,130 DEBUG [pallet.main-invoker] (Thread-1) Arch i386
2010-10-29 22:19:25,131 DEBUG [pallet.main-invoker] (Thread-1) Admin user david
2010-10-29 22:19:25,131 DEBUG [pallet.main-invoker] (Thread-1) private-key-path /Users/David/.ssh/id_rsa true
2010-10-29 22:19:25,131 DEBUG [pallet.main-invoker] (Thread-1) public-key-path /Users/David/.ssh/id_rsa.pub true
2010-10-29 22:19:25,132 DEBUG [pallet.main-invoker] (Thread-1) Running as null@null
2010-10-29 22:19:25,143 TRACE [pallet.core] (Thread-1) lift* phases []
2010-10-29 22:19:25,143 INFO [pallet.core] (Thread-1) retrieving nodes