Skip to content

Instantly share code, notes, and snippets.

@hhutch
Created July 20, 2011 14:15
Show Gist options
  • Save hhutch/1095036 to your computer and use it in GitHub Desktop.
Save hhutch/1095036 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