 
 (comment
   (set-ip "red1" {:user "ronen" :password "foobar" :sudo true} 
-     {:ip "192.168.5.91" :mask "255.255.255.0" :network "192.168.5.0" :gateway "192.168.5.1" :search "local" :names ["192.168.5.1"]}) 
+          {:ip "192.168.5.91" :mask "255.255.255.0" :network "192.168.5.0" :gateway "192.168.5.1" :search "local" :names ["192.168.5.1"]}) 
   (download-file "/tmp/project.clj" "/tmp/project.clj" "foo" {:user "root" :pass "foobar"})
   (upload-file "project.clj" "/tmp/project.clj" "red1" {:user "ronen" :pass "foobar"}) 
   (download-file "/tmp/project.clj" "/tmp/project.clj" "foo" {:user "ronen" :pass "foobar"}) 

         (when-not (= (exit-code m pid auth) 0)
           (throw+ {:type ::vc:guest-run-fail :message (<< "Failed running ~{cmd} ~{args} in guest") :timeout timeout})))))

(defn fetch-log 
   "fetched remote log file by uuid"
   [hostname uuid auth]
  (slurp (download-file (<< "/tmp/run-~{uuid}.log") hostname auth)))

(defn set-ip 
  "set guest static ip" 
  [hostname auth config]
  (let [uuid (gen-uuid) tmp-file (<< "/tmp/intrefaces_~{uuid}")]
    (debug "setting up guest static ip")
    (upload-file (render-resource "static-ip.mustache" (update-in config [:names] (partial join ","))) tmp-file hostname auth)
    (guest-run hostname "/bin/cp" (<< "-v ~{tmp-file} /etc/network/interfaces") auth uuid [2 :seconds])
    (guest-run hostname "/usr/sbin/service" "networking restart" auth uuid [3 :seconds])

    com.vmware.vim25.GuestProgramSpec
    com.vmware.vim25.GuestFileAttributes) 
  (:require 
    [slingshot.slingshot :refer  [throw+ try+]]
    [clj-http.client :as client])
  (:use 
    [clojure.string :only (join split)]
    [celestial.provider :only (wait-for)]
    [celestial.common :only (gen-uuid import-logging)]
    [clostache.parser :only (render-resource)] 
