From 8c1c71674f525f5614ade5095ce529eb0058ea0e Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 10 Nov 2018 15:38:03 -0700 Subject: add virshGetColumns --- src/Propellor/Property/Libvirt.hs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/Propellor') 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 -- cgit v1.2.3