      (cons v (chan->seq c terminate?)))))
 
 
-(def ^{:private true} paths {:zone  [:launch-specification :placement :availability-zone]
-                             :itype [:launch-specification :instance-type]
-                             :subnet [:launch-specification :instance-network-interface-specification 0 :subnet-id]
-                             :group [:launch-specification :network-interfaces 0 :groups 0]
-                             :public? [:launch-specification :network-interfaces 0 :associate-public-ip-address]
-                             :price [:spot-price]
-                             :n     [:instance-count]
-                             :udata [s->b64 :launch-specification :user-data]})
 
 
 (def my-ec2-info nil)



(def cred (read-string (slurp "AWS.clj")))

(apply defcredential (map cred [:access-key :secret-key :endpoint]))

(defn s->b64 [s] (String. (b64/encode (.getBytes s))))

(defn b64->s [s] (String. (b64/decode (.getBytes s))))

(defn- m->pair [[_ k v]] [(keyword k) v])

(defn b64->ec2-data [s]
  (let [xs  (-> s b64->s clojure.string/split-lines)
        es  (map #(->> % 
                       (re-matches #"^([\w\-]+):\s*(.*)")

     (string? (:ip info))
     (pos? (count (:ip info))))))

(defn bring-up-spots
  "Bring up at least nmin instances as specified by reqmap.  The sequence
of cmds will be excecuted at startup.  Any other request-spot-instance arguments
can be specified optionally."
  [reqmap nmin cmds & opts]
  (let [id  (.toString (UUID/randomUUID))
        cmd (str (send-up id) (clojure.string/join "\n" cmds) "\n")
        req (apply ph-assoc reqmap paths opts)
