                   (:hosts req))]
     (patience
      (fn [] (let [sbad (filter #(not (ssh/connected? %)) sess)]
-               (doseq [s sbad] (ssh/connect s))
-               (assoc req :sessions sess)))
+              (doseq [s sbad] (ssh/connect s))
+              (assoc req :sessions sess)))
      #(every? ssh/connected? (:sessions %1))
-     #(give-up-and-cancel req "Failed to add sesions")
+     nil ;#(give-up-and-cancel req "Failed to add sesions")
      60 10
      )))
 

        acyclic.utils.pinhole)
  (:require [clj-ssh.ssh :as ssh]
            [taoensso.timbre :as timbre]
            [ clojure.core.async :as async 
             :refer [<! >! <!! >!! timeout chan alt!! go close!]]))
(timbre/refer-timbre)

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

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



(def ^{:private true} paths {:zone  [:launch-specification :placement :availability-zone]
                             :itype  [:launch-specification :instance-type]
                             :price [:spot-price]
                             :n     [:instance-count]})

(defmacro go-try [& forms]
  `(go (try (do ~@forms)


(def ag (ssh/ssh-agent {}))

(defn ssh-session [host]
  (let [sess (ssh/session ag host {:strict-host-key-checking :no
                                   :username "ec2-user"})]
    (<!! (async/go-loop [n 10]
           (cond
            (ssh/connected? sess) sess
            (zero? n) (do (debug "Failed to connect to" host) nil)
            :else     (do
                        (ssh/connect sess)
                        (if (ssh/connected? sess)
                          sess
                          (do
                            (<! (timeout 1000))
                            (recur (dec n))))))))))


(defn ssh-sessions [hosts]
  (let [sess (map #()
                  hosts)]
    (loop [n 10]
           (let [o (map #(or (ssh/connected? %) (ssh/connect %)) sess)]
