   (let [vm (vconstruct spec)]
     (info "stopping" machine)
     (.stop vm) 
-    (assert (not (= (.status vm) "running"))) ; might not match all providers
+    (not-running! vm)
     ))
 
 (deflow start 
   "Start a vm instance"
   [{:keys [machine] :as spec}]
   (let [vm (vconstruct spec)]
-    (assert (not (= (.status vm) "running"))) ; might not match all providers
+    (not-running! vm)
     (info "starting" machine)
     (.start vm) 
-    (assert (= (.status vm) "running")) ; might not match all providers
+    (running! vm)
     ))
 
 (deflow create

  [type {:keys [machine] :as spec}]
    (info "starting to provision") 
    (trace type spec) 
    (assert (= (.status (vconstruct spec)) "running")) ; might not match all providers
    (.apply- (pconstruct type spec)) 
    (info "done provisioning"))

(defn stage
  "create and provision"
  [type {:keys [system-id] :as spec}] 
  (create spec) 
  (when-not (= (.status (vconstruct spec)) "running"); some providers already start the vm (AWS, vCenter)
    (start spec))
  (puppetize type (assoc (s/get-system system-id) :system-id system-id)))

(deflow ^{:hook-args :run-info} run-action
  "Runs an action"

           (run-hooks ~hook-args ~(keyword name*) :error) 
           (throw t#))))))

(defn updated-system 
   "grabs system and associates system id" 
   [system-id]
   (assoc (s/get-system system-id) :system-id system-id))

(defn running! 
  "Asserts that a VM is running"
  [vm]
  (assert (= (.status vm) "running")) ; might not match all providers
  )
 
(defn not-running!
  "Assert that a vm is not running"
   [vm]
  (assert (not (= (.status vm) "running"))) ; might not match all providers
  )

(deflow reload 
  "Reloads a machine if one already exists, will distroy the old one"
  [{:keys [machine system-id] :as spec}]
