summaryrefslogtreecommitdiff
path: root/src/Propellor
diff options
context:
space:
mode:
authorSean Whitton2018-11-10 15:38:03 -0700
committerSean Whitton2018-11-10 15:40:42 -0700
commit8c1c71674f525f5614ade5095ce529eb0058ea0e (patch)
tree3b37d76531c9bdac5dfb509494a12fd7885dcbb3 /src/Propellor
parent37e934ee1a2bd235c64eb27c58da3d99648c44ea (diff)
add virshGetColumns
Diffstat (limited to 'src/Propellor')
-rw-r--r--src/Propellor/Property/Libvirt.hs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/Propellor/Property/Libvirt.hs b/src/Propellor/Property/Libvirt.hs
index 62593532..201d1185 100644
--- a/src/Propellor/Property/Libvirt.hs
+++ b/src/Propellor/Property/Libvirt.hs
@@ -17,6 +17,8 @@ import Propellor.Property.DiskImage
import Propellor.Property.Chroot.Util (removeChroot)
import qualified Propellor.Property.Apt as Apt
+import Utility.Split
+
-- | The number of virtual CPUs to assign to the virtual machine
newtype NumVCPUs = NumVCPUs Int
@@ -176,5 +178,11 @@ osVariant h = hostSystem h >>= \s -> case s of
System (Debian _ _) _ -> Nothing
System (Buntish _) _ -> Nothing
+-- Run a virsh command with the given list of arguments, that is expected to
+-- yield tabular output, and return the rows
+virshGetColumns :: [String] -> IO [[String]]
+virshGetColumns args = map (filter (not . null) . split " ") . drop 2 . lines
+ <$> readProcess "virsh" args
+
hostSystem :: Host -> Maybe System
hostSystem = fromInfoVal . fromInfo . hostInfo