 (ns freenas.provider
   "Freenas jails provider"
   (:require 
+    [supernal.core :refer (ns- lifecycle run execute env)]
     [taoensso.timbre :as timbre]
     [clojure.core.strint :refer (<<)] 
     [celestial.provider :refer (wait-for-ssh mappings wait-for)]

  (let [js (call client/get "jails/jails/") ]
    (first (filter #(= (:jail_host %) host) js))))

(defn enable-ssh [host]
  ;; jexec 19 sed -i.bak 's/^sshd_enable=.*/sshd_enable="YES"/' /etc/rc.conf
  ;; jexec  19 /etc/rc.d/sshd start
  )

(defrecord Jail [spec]
  Vm

    [freenas.validations :refer [validate-provider jail-mappings]]
    [slingshot.slingshot :refer  [throw+]]
    [celestial.persistency.systems :as s]
    [org.httpkit.client :as client]
    [celestial.core :refer (Vm)] 
    [celestial.common :refer (get*)]
    [celestial.model :refer (hypervisor* hypervisor translate vconstruct)])
 )

(timbre/refer-timbre)
