summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/ZFS
diff options
context:
space:
mode:
Diffstat (limited to 'src/Propellor/Property/ZFS')
-rw-r--r--src/Propellor/Property/ZFS/Properties.hs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/Propellor/Property/ZFS/Properties.hs b/src/Propellor/Property/ZFS/Properties.hs
index 5ceaf9ba..47d5a9d1 100644
--- a/src/Propellor/Property/ZFS/Properties.hs
+++ b/src/Propellor/Property/ZFS/Properties.hs
@@ -3,6 +3,7 @@
-- Functions defining zfs Properties.
module Propellor.Property.ZFS.Properties (
+ ZFSOS,
zfsExists,
zfsSetProperties
) where
@@ -11,9 +12,12 @@ import Propellor.Base
import Data.List (intercalate)
import qualified Propellor.Property.ZFS.Process as ZP
+-- | OS's that support ZFS
+type ZFSOS = Linux + FreeBSD
+
-- | Will ensure that a ZFS volume exists with the specified mount point.
-- This requires the pool to exist as well, but we don't create pools yet.
-zfsExists :: ZFS -> Property NoInfo
+zfsExists :: ZFS -> Property ZFSOS
zfsExists z = check (not <$> ZP.zfsExists z) create
`describe` unwords ["Creating", zfsName z]
where
@@ -21,16 +25,16 @@ zfsExists z = check (not <$> ZP.zfsExists z) create
create = cmdProperty p a
-- | Sets the given properties. Returns True if all were successfully changed, False if not.
-zfsSetProperties :: ZFS -> ZFSProperties -> Property NoInfo
+zfsSetProperties :: ZFS -> ZFSProperties -> Property ZFSOS
zfsSetProperties z setProperties = setall
`requires` zfsExists z
where
spcmd :: String -> String -> (String, [String])
spcmd p v = ZP.zfsCommand "set" [Just (intercalate "=" [p, v]), Nothing] z
- setprop :: (String, String) -> Property NoInfo
+ setprop :: (String, String) -> Property ZFSOS
setprop (p, v) = check (ZP.zfsExists z) $
cmdProperty (fst (spcmd p v)) (snd (spcmd p v))
setall = combineProperties (unwords ["Setting properties on", zfsName z]) $
- map setprop $ toPropertyList setProperties
+ toProps $ map setprop $ toPropertyList setProperties