Merge 'EvacNode' and 'NodeEvacMode'
[ganeti-local] / src / Ganeti / HTools / Types.hs
index af533dc..b4f8c86 100644 (file)
@@ -53,6 +53,7 @@ module Ganeti.HTools.Types
   , unitMem
   , unitCpu
   , unitDsk
+  , unitSpindle
   , unknownField
   , Placement
   , IMove(..)
@@ -68,7 +69,6 @@ module Ganeti.HTools.Types
   , FailStats
   , OpResult
   , opToResult
-  , EvacMode(..)
   , ISpec(..)
   , MinMaxISpecs(..)
   , IPolicy(..)
@@ -141,6 +141,7 @@ data RSpec = RSpec
   { rspecCpu  :: Int  -- ^ Requested VCPUs
   , rspecMem  :: Int  -- ^ Requested memory
   , rspecDsk  :: Int  -- ^ Requested disk
+  , rspecSpn  :: Int  -- ^ Requested spindles
   } deriving (Show, Eq)
 
 -- | Allocation stats type. This is used instead of 'RSpec' (which was
@@ -153,6 +154,7 @@ data AllocInfo = AllocInfo
   , allocInfoNCpus :: Double -- ^ Normalised CPUs
   , allocInfoMem   :: Int    -- ^ Memory
   , allocInfoDisk  :: Int    -- ^ Disk
+  , allocInfoSpn   :: Int    -- ^ Spindles
   } deriving (Show, Eq)
 
 -- | Currently used, possibly to allocate, unallocable.
@@ -231,6 +233,7 @@ rspecFromISpec :: ISpec -> RSpec
 rspecFromISpec ispec = RSpec { rspecCpu = iSpecCpuCount ispec
                              , rspecMem = iSpecMemorySize ispec
                              , rspecDsk = iSpecDiskSize ispec
+                             , rspecSpn = iSpecSpindleUse ispec
                              }
 
 -- | The default instance policy.
@@ -317,6 +320,10 @@ unitDsk = 256
 unitCpu :: Int
 unitCpu = 1
 
+-- | Base spindles unit.
+unitSpindle :: Int
+unitSpindle = 1
+
 -- | Reason for an operation's falure.
 data FailMode = FailMem  -- ^ Failed due to not enough RAM
               | FailDisk -- ^ Failed due to not enough disk
@@ -370,14 +377,6 @@ class Element a where
   -- | Updates the index of the element
   setIdx  :: a -> Int -> a
 
--- | The iallocator node-evacuate evac_mode type.
-$(THH.declareSADT "EvacMode"
-       [ ("ChangePrimary",   'C.iallocatorNevacPri)
-       , ("ChangeSecondary", 'C.iallocatorNevacSec)
-       , ("ChangeAll",       'C.iallocatorNevacAll)
-       ])
-$(THH.makeJSONInstance ''EvacMode)
-
 -- | The repair modes for the auto-repair tool.
 $(THH.declareSADT "AutoRepairType"
        -- Order is important here: from least destructive to most.