Skip to content

Instantly share code, notes, and snippets.

@hugoduncan
hugoduncan / gist:872984
Created March 16, 2011 18:15
pallet.action-plan
(ns pallet.action-plan
"An action plan contains actions for execution.
It might be possible to unify actions and crate functions, if we can solve
nested execution of actions (ie. real control flows within the action plan).
This might be possible by having a `do` action that creates a nested action
plan."
{:author "Hugo Duncan"}
(:require
@hugoduncan
hugoduncan / gist:872985
Created March 16, 2011 18:15
pallet.action-plan
(ns pallet.action-plan
"An action plan contains actions for execution.
The action plan is built by executing a phase function. Each phase function
calls actions which insert themselves into the action plan.
The action plan is transformed to provide aggregated operations, and to
resolve precedence relations between actions.
A translated plan is executed by passing an executor, which is a map
@hugoduncan
hugoduncan / gist:872992
Created March 16, 2011 18:17
pallet.action
(ns pallet.action
"Actions implement the conversion of phase functions to script and other
execution code.
An action has a :type. Known types include :script/bash and :fn/clojure.
An action has a :location, :origin for execution on the node running
pallet, and :target for the target node.
An action has an :execution, which is one of :aggregated, :in-sequence or
@hugoduncan
hugoduncan / gist:877186
Created March 19, 2011 03:11
pallet.phase
(ns pallet.phase
"A phase is a function of a single `request` argument, that contains
calls to crate functions or actions. A phase has an implicitly
defined pre and post phase."
(:require
[clojure.contrib.condition :as condition]))
(defn- pre-phase-name
"Return the name for the pre-phase for the given `phase`."
[phase]
@hugoduncan
hugoduncan / gist:880168
Created March 21, 2011 20:34
phases in the environment
:environment
{:phases {:bootstrap
(fn [request]
(pallet.resource.package/package-manager
request
:configure :proxy "http://192.168.1.37:3128"))}
:proxy "http://192.168.1.37:3128"}}
@hugoduncan
hugoduncan / gist:882592
Created March 23, 2011 04:00
pallet.execute
(ns pallet.execute
"Exectute commands. At the moment the only available transport is ssh."
(:require
[pallet.action-plan :as action-plan]
[pallet.compute :as compute]
[pallet.environment :as environment]
[pallet.script :as script]
[pallet.stevedore :as stevedore]
[pallet.stevedore.script :as script-impl]
[pallet.utils :as utils]
(ns pallet.core
"Core functionality is provided in `lift` and `converge`.
- node :: A node in the compute service
- node-spec :: A specification for a node. The node-spec provides an image
hardware, location and network template for starting new
nodes.
- server-spec :: A specification for a server. This is a map of phases and
a default node-spec. A server-spec has the following keys
:phase, :packager and node-spec keys.
@hugoduncan
hugoduncan / gist:883514
Created March 23, 2011 17:16
pallet.stevedore.script
(ns pallet.stevedore.script
"Uses pallet.script to provide script functions in stevedore.
Script functions (defined with `pallet.script/defscript`) can be implemented
using `defimpl`."
(:require
[pallet.script :as script]
[pallet.stevedore :as stevedore])
(:use
[clojure.contrib.core :only [-?>]]))
@hugoduncan
hugoduncan / swank-clj.el
Created April 29, 2011 02:38
elisp for swank-clj
(require 'slime)
(defun slime-line-breakpoint ()
"Set a breakpoint at the current line"
(interactive)
(slime-eval-with-transcript
`(swank:line-breakpoint
,(slime-current-package) ,(buffer-name) ,(line-number-at-pos))))
@hugoduncan
hugoduncan / gist:996901
Created May 28, 2011 14:34
Matching on map key-value pairs
(ns pallet.nodes
"Node templates. Provide node size and image selection for pallet."
(:require
[clojure.core.logic.match :as match]
[clojure.core.logic.minikanren :as mk]
[clojure.core.logic.prelude :as prelude])
(:use
clojure.test))
(def spec-data