Skip to content

Instantly share code, notes, and snippets.

@davidrupp
Forked from hhutch/pallet.snippets.clj
Created October 25, 2011 15:48
Show Gist options
  • Save davidrupp/1313217 to your computer and use it in GitHub Desktop.
Save davidrupp/1313217 to your computer and use it in GitHub Desktop.
Pallet snippets that are useful
(defn nodes-in-group
"Build a list of nodes in a given security-group"
[security-group]
(filter #(= (% 0) security-group)
(map #(vector (pallet.compute/group-name %)
(pallet.compute/primary-ip %)
(pallet.compute/id %)
(pallet.compute.jclouds/node-locations %) )
(pallet.compute/nodes srvc))))
(defn process-phase-output
"Grab the output of a single phase"
[compute-service server-group phase-to-run]
(let [phase-output-data (core/converge server-group :compute compute-service :phase phase-to-run)
operated-on-node-key (-> phase-output-data :results keys first)
phase-results-key (first (filter #(re-find #"^phase\d+" (name %)) (-> phase-output-data :results opnode keys)))
command-output-string (-> phase-output-data :results operated-on-node-key phase-results-key first :out) ]
( .... do something with command-output-string .... ) ) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment