summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton2018-11-09 16:39:56 -0700
committerSean Whitton2018-11-09 16:39:56 -0700
commit8c56394cb329f1d914435cabd9f0f197f2b84ad0 (patch)
tree1e3e3946afaa93aecdfacf34ae0f94fafb0e5e1c
parent95c8e36992f143a5f204d1dd859dcada9fc4c271 (diff)
newtypes for NumVCPUs and MiBMemory
Less chance of requesting 2048 CPU cores and 2MiB of memory. Suggested-by: Joey Hess <id@joeyh.name>
-rw-r--r--src/Propellor/Property/Libvirt.hs14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/Propellor/Property/Libvirt.hs b/src/Propellor/Property/Libvirt.hs
index 601f6236..7ab8e563 100644
--- a/src/Propellor/Property/Libvirt.hs
+++ b/src/Propellor/Property/Libvirt.hs
@@ -1,8 +1,8 @@
-- | Maintainer: Sean Whitton <spwhitton@spwhitton.name>
module Propellor.Property.Libvirt (
- NumVCPUs,
- MiBMemory,
+ NumVCPUs(..),
+ MiBMemory(..),
AutoStart(..),
DiskImageType(..),
installed,
@@ -18,10 +18,10 @@ import Propellor.Property.Chroot.Util (removeChroot)
import qualified Propellor.Property.Apt as Apt
-- | The number of virtual CPUs to assign to the virtual machine
-type NumVCPUs = Int
+newtype NumVCPUs = NumVCPUs Int
-- | The number of MiB of memory to assign to the virtual machine
-type MiBMemory = Int
+newtype MiBMemory = MiBMemory Int
-- | Whether the virtual machine should be started after it is defined, and at
-- host system boot
@@ -61,7 +61,9 @@ defaultNetworkAutostarted = check (not <$> doesFileExist autostartFile)
-- > & Libvirt.defaultNetworkAutostarted
-- > `onChange` (cmdProperty "virsh" ["net-start", "default"]
-- > `assume` MadeChange)
--- > & Libvirt.kvmDefined Libvirt.Raw 2048 2 Libvirt.NoAutoStart subbox
+-- > & Libvirt.kvmDefined Libvirt.Raw
+-- > (Libvirt.MiBMemory 2048) (Libvirt.NumVCPUs 2)
+-- > Libvirt.NoAutoStart subbox
-- >
-- > subbox = host "subbox.mybox.example.com" $ props
-- > & osDebian Unstable X86_64
@@ -85,7 +87,7 @@ kvmDefined
-> AutoStart
-> Host
-> Property (HasInfo + DebianLike)
-kvmDefined imageType mem cpus auto h =
+kvmDefined imageType (MiBMemory mem) (NumVCPUs cpus) auto h =
(built `before` nuked `before` defined `before` started)
`requires` installed
where